diff options
| author | Santiago Pastorino <spastorino@gmail.com> | 2022-08-09 16:39:02 -0300 |
|---|---|---|
| committer | Santiago Pastorino <spastorino@gmail.com> | 2022-08-09 16:39:02 -0300 |
| commit | 750a04ea7fabd46b6156e32b1e910a06daf8c33c (patch) | |
| tree | 753b1d7ae68d0ee3d81b0279c115a48474b52c35 | |
| parent | 457ff7c56cedbf67e7716d88762595ed73d75077 (diff) | |
| download | rust-750a04ea7fabd46b6156e32b1e910a06daf8c33c.tar.gz rust-750a04ea7fabd46b6156e32b1e910a06daf8c33c.zip | |
Add docs for get_remapped_def_id
| -rw-r--r-- | compiler/rustc_ast_lowering/src/lib.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 46f2a435669..38d30d0ffde 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -220,6 +220,19 @@ impl ResolverAstLoweringExt for ResolverAstLowering { } fn get_remapped_def_id(&self, mut local_def_id: LocalDefId) -> LocalDefId { + // `generics_def_id_map` is a stack of mappings. As we go deeper in impl traits nesting we + // push new mappings so we need to try first the latest mappings, hence `iter().rev()`. + // + // Consider: + // + // `fn test<'a, 'b>() -> impl Trait<&'a u8, Ty = impl Sized + 'b> {}` + // + // We would end with a generics_def_id_map like: + // + // `[[fn#'b -> impl_trait#'b], [fn#'b -> impl_sized#'b]]` + // + // for the opaque type generated on `impl Sized + 'b`, We want the result to be: + // impl_sized#'b, so iterating forward is the wrong thing to do. for map in self.generics_def_id_map.iter().rev() { if let Some(r) = map.get(&local_def_id) { debug!("def_id_remapper: remapping from `{local_def_id:?}` to `{r:?}`"); |
