File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
compiler/rustc_ast_lowering/src Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -220,6 +220,19 @@ impl ResolverAstLoweringExt for ResolverAstLowering {
220220 }
221221
222222 fn get_remapped_def_id ( & self , mut local_def_id : LocalDefId ) -> LocalDefId {
223+ // `generics_def_id_map` is a stack of mappings. As we go deeper in impl traits nesting we
224+ // push new mappings so we need to try first the latest mappings, hence `iter().rev()`.
225+ //
226+ // Consider:
227+ //
228+ // `fn test<'a, 'b>() -> impl Trait<&'a u8, Ty = impl Sized + 'b> {}`
229+ //
230+ // We would end with a generics_def_id_map like:
231+ //
232+ // `[[fn#'b -> impl_trait#'b], [fn#'b -> impl_sized#'b]]`
233+ //
234+ // for the opaque type generated on `impl Sized + 'b`, We want the result to be:
235+ // impl_sized#'b, so iterating forward is the wrong thing to do.
223236 for map in self . generics_def_id_map . iter ( ) . rev ( ) {
224237 if let Some ( r) = map. get ( & local_def_id) {
225238 debug ! ( "def_id_remapper: remapping from `{local_def_id:?}` to `{r:?}`" ) ;
You can’t perform that action at this time.
0 commit comments