about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2024-10-05 12:13:24 +0000
committerCamille GILLOT <gillot.camille@gmail.com>2024-10-30 16:20:02 +0000
commitd804ef8be8a7ce9c680812776276248cdf174e29 (patch)
tree4d38abd52ebc38a9646662d74bdb7614423a581d
parentd693e1926894824bc4fb2249a17a9cd71c926ac2 (diff)
downloadrust-d804ef8be8a7ce9c680812776276248cdf174e29.tar.gz
rust-d804ef8be8a7ce9c680812776276248cdf174e29.zip
Adapt comments.
-rw-r--r--compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs24
1 files changed, 12 insertions, 12 deletions
diff --git a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs
index 675e033e949..1378e620316 100644
--- a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs
+++ b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs
@@ -152,11 +152,14 @@ enum Scope<'a> {
         s: ScopeRef<'a>,
     },
 
-    /// Resolve the lifetimes in the bounds to the lifetime defs in the generics.
-    /// `fn foo<'a>() -> impl MyTrait<'a> { ... }` desugars to
+    /// Remap lifetimes that appear in opaque types to fresh lifetime parameters. Given:
+    /// `fn foo<'a>() -> impl MyTrait<'a> { ... }`
+    ///
+    /// HIR tells us that `'a` refer to the lifetime bound on `foo`.
+    /// However, typeck and borrowck for opaques are work based on using a new generics type.
     /// `type MyAnonTy<'b> = impl MyTrait<'b>;`
-    ///                 ^                  ^ this gets resolved in the scope of
-    ///                                      the opaque_ty generics
+    ///
+    /// This scope collects the mapping `'a -> 'b`.
     Opaque {
         /// The opaque type we are traversing.
         def_id: LocalDefId,
@@ -547,11 +550,11 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
         }
     }
 
-    /// Resolve the lifetimes that are applied to the opaque type.
-    /// These are resolved in the current scope.
-    /// `fn foo<'a>() -> impl MyTrait<'a> { ... }` desugars to
-    /// `fn foo<'a>() -> MyAnonTy<'a> { ... }`
-    ///          ^                 ^this gets resolved in the current scope
+    /// Resolve the lifetimes inside the opaque type, and save them into
+    /// `opaque_captured_lifetimes`.
+    ///
+    /// This method has special handling for opaques that capture all lifetimes,
+    /// like async desugaring.
     #[instrument(level = "debug", skip(self))]
     fn visit_opaque_ty(&mut self, opaque: &'tcx rustc_hir::OpaqueTy<'tcx>) {
         let mut captures = FxIndexMap::default();
@@ -815,9 +818,6 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
                 };
                 self.with(scope, |this| this.visit_ty(mt.ty));
             }
-            hir::TyKind::OpaqueDef(opaque_ty) => {
-                self.visit_opaque_ty(opaque_ty);
-            }
             _ => intravisit::walk_ty(self, ty),
         }
     }