From 065e497630db6d9be3e1fd984270c9807408b55e Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Thu, 4 Aug 2022 12:47:58 -0300 Subject: [PATCH] Improve opt_local_def_id docs --- compiler/rustc_ast_lowering/src/lib.rs | 16 +++++++++------- 1 file 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 { self.resolver .node_id_to_def_id