Improve opt_local_def_id docs

This commit is contained in:
Santiago Pastorino 2022-08-04 12:47:58 -03:00
parent bf1c7da147
commit 065e497630
No known key found for this signature in database
GPG key ID: 8131A24E0C79EFAF

View file

@ -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