diff options
| author | bors <bors@rust-lang.org> | 2024-02-14 15:45:34 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-02-14 15:45:34 +0000 |
| commit | 502ce8287bc3c86dca07acc38c5ff9431a6097be (patch) | |
| tree | 1cc1ea4473b70ba3822b56848e9d96ecf00cb4be /compiler/rustc_middle/src | |
| parent | 340bb19fea20fd5f9357bbfac542fad84fc7ea2b (diff) | |
| parent | 2062325145147f9fb958be874f51cad8a8e0594d (diff) | |
| download | rust-502ce8287bc3c86dca07acc38c5ff9431a6097be.tar.gz rust-502ce8287bc3c86dca07acc38c5ff9431a6097be.zip | |
Auto merge of #121086 - GuillaumeGomez:rollup-y82fs9y, r=GuillaumeGomez
Rollup of 6 pull requests Successful merges: - #120893 (Move some tests) - #120966 (Remove importing suggestions when there is a shadowed typo candidate) - #121035 (Format `async` trait bounds in rustfmt) - #121075 (Fix false positive with if let and ranges) - #121083 (Extend documentation for `Ty::to_opt_closure_kind` method) - #121084 (Make sure `tcx.create_def` also depends on the forever red node, instead of just `tcx.at(span).create_def`) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_middle/src')
| -rw-r--r-- | compiler/rustc_middle/src/ty/context.rs | 12 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/sty.rs | 14 |
2 files changed, 20 insertions, 6 deletions
diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 61e449b8b56..7033a4a833d 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -1053,12 +1053,6 @@ impl<'tcx> TyCtxtAt<'tcx> { name: Symbol, def_kind: DefKind, ) -> TyCtxtFeed<'tcx, LocalDefId> { - // This function modifies `self.definitions` using a side-effect. - // We need to ensure that these side effects are re-run by the incr. comp. engine. - // Depending on the forever-red node will tell the graph that the calling query - // needs to be re-evaluated. - self.dep_graph.read_index(DepNodeIndex::FOREVER_RED_NODE); - // The following call has the side effect of modifying the tables inside `definitions`. // These very tables are relied on by the incr. comp. engine to decode DepNodes and to // decode the on-disk cache. @@ -1087,6 +1081,12 @@ impl<'tcx> TyCtxt<'tcx> { let data = def_kind.def_path_data(name); let def_id = self.untracked.definitions.write().create_def(parent, data); + // This function modifies `self.definitions` using a side-effect. + // We need to ensure that these side effects are re-run by the incr. comp. engine. + // Depending on the forever-red node will tell the graph that the calling query + // needs to be re-evaluated. + self.dep_graph.read_index(DepNodeIndex::FOREVER_RED_NODE); + let feed = self.feed_local_def_id(def_id); feed.def_kind(def_kind); // Unique types created for closures participate in type privacy checking. diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index ae6544b9dbe..66086ac87f1 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -2373,6 +2373,20 @@ impl<'tcx> Ty<'tcx> { /// to represent the closure kind, because it has not yet been /// inferred. Once upvar inference (in `rustc_hir_analysis/src/check/upvar.rs`) /// is complete, that type variable will be unified. + /// + /// To be noted that you can use [`ClosureArgs::kind()`] or [`CoroutineClosureArgs::kind()`] + /// to get the same information, which you can get by calling [`GenericArgs::as_closure()`] + /// or [`GenericArgs::as_coroutine_closure()`], depending on the type of the closure. + /// + /// Otherwise, this method can be used as follows: + /// + /// ```rust,ignore (snippet of compiler code) + /// let TyKind::Closure(def_id, [closure_fn_kind_ty, ..]) = closure_ty.kind() + /// && let Some(closure_kind) = closure_fn_kind_ty.expect_ty().to_opt_closure_kind() + /// { + /// // your code + /// } + /// ``` pub fn to_opt_closure_kind(self) -> Option<ty::ClosureKind> { match self.kind() { Int(int_ty) => match int_ty { |
