about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSantiago Pastorino <spastorino@gmail.com>2022-08-04 12:47:58 -0300
committerSantiago Pastorino <spastorino@gmail.com>2022-08-04 15:13:44 -0300
commit065e497630db6d9be3e1fd984270c9807408b55e (patch)
tree84b7b41446381c81c2736145e1bfbf3cf1790bff
parentbf1c7da1476c8193a0e92262c3e4dd2d88392569 (diff)
downloadrust-065e497630db6d9be3e1fd984270c9807408b55e.tar.gz
rust-065e497630db6d9be3e1fd984270c9807408b55e.zip
Improve opt_local_def_id docs
-rw-r--r--compiler/rustc_ast_lowering/src/lib.rs16
1 files changed, 9 insertions, 7 deletions
diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs
index 84388d3d653..f86dcb9c4c8 100644
--- a/compiler/rustc_ast_lowering/src/lib.rs
+++ b/compiler/rustc_ast_lowering/src/lib.rs
@@ -489,14 +489,16 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
     /// Given the id of some node in the AST, finds the `LocalDefId` associated with it by the name
     /// resolver (if any), after applying any remapping from `get_remapped_def_id`.
     ///
-    /// For example: for each captured lifetime (e.g., 'a), we create a new lifetime parameter that is a generic
-    /// defined on the TAIT, so we have type Foo<'a1> = ... and we establish a mapping from the
-    /// original parameter 'a to the new parameter 'a1.
+    /// For example, in a function like `fn foo<'a>(x: &'a u32)`,
+    /// invoking with the id from the `ast::Lifetime` node found inside
+    /// the `&'a u32` type would return the `LocalDefId` of the
+    /// `'a` parameter declared on `foo`.
     ///
-    /// This method will return, given `'a` node id, `'a1` def id, going through, as a mid step,
-    /// the def_id of `'a`.
-    /// For cases when there are no mappings, it will just return the def_id that correspond to the
-    /// given node_id.
+    /// This function also applies remapping from `get_remapped_def_id`.
+    /// These are used when synthesizing opaque types from `-> impl Trait` return types and so forth.
+    /// For example, in a function like `fn foo<'a>() -> impl Debug + 'a`,
+    /// we would create an opaque type `type FooReturn<'a1> = impl Debug + 'a1`.
+    /// When lowering the `Debug + 'a` bounds, we add a remapping to map `'a` to `'a1`.
     fn opt_local_def_id(&self, node: NodeId) -> Option<LocalDefId> {
         self.resolver
             .node_id_to_def_id