File tree 1 file changed +13
-0
lines changed
compiler/rustc_ast_lowering/src
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 {
220
220
}
221
221
222
222
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.
223
236
for map in self . generics_def_id_map . iter ( ) . rev ( ) {
224
237
if let Some ( r) = map. get ( & local_def_id) {
225
238
debug ! ( "def_id_remapper: remapping from `{local_def_id:?}` to `{r:?}`" ) ;
You can’t perform that action at this time.
0 commit comments