Skip to content

Commit 065e497

Browse files
committed
Improve opt_local_def_id docs
1 parent bf1c7da commit 065e497

File tree

1 file changed

+9
-7
lines changed
  • compiler/rustc_ast_lowering/src

1 file changed

+9
-7
lines changed

compiler/rustc_ast_lowering/src/lib.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -489,14 +489,16 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
489489
/// Given the id of some node in the AST, finds the `LocalDefId` associated with it by the name
490490
/// resolver (if any), after applying any remapping from `get_remapped_def_id`.
491491
///
492-
/// For example: for each captured lifetime (e.g., 'a), we create a new lifetime parameter that is a generic
493-
/// defined on the TAIT, so we have type Foo<'a1> = ... and we establish a mapping from the
494-
/// original parameter 'a to the new parameter 'a1.
492+
/// For example, in a function like `fn foo<'a>(x: &'a u32)`,
493+
/// invoking with the id from the `ast::Lifetime` node found inside
494+
/// the `&'a u32` type would return the `LocalDefId` of the
495+
/// `'a` parameter declared on `foo`.
495496
///
496-
/// This method will return, given `'a` node id, `'a1` def id, going through, as a mid step,
497-
/// the def_id of `'a`.
498-
/// For cases when there are no mappings, it will just return the def_id that correspond to the
499-
/// given node_id.
497+
/// This function also applies remapping from `get_remapped_def_id`.
498+
/// These are used when synthesizing opaque types from `-> impl Trait` return types and so forth.
499+
/// For example, in a function like `fn foo<'a>() -> impl Debug + 'a`,
500+
/// we would create an opaque type `type FooReturn<'a1> = impl Debug + 'a1`.
501+
/// When lowering the `Debug + 'a` bounds, we add a remapping to map `'a` to `'a1`.
500502
fn opt_local_def_id(&self, node: NodeId) -> Option<LocalDefId> {
501503
self.resolver
502504
.node_id_to_def_id

0 commit comments

Comments
 (0)