Skip to content

Commit fb2194a

Browse files
committed
Auto merge of #100412 - Mark-Simulacrum:beta-next, r=Mark-Simulacrum
Rollup of beta backports This rolls up bumping stage0 to released stable and: * Iterate generics_def_id_map in reverse order to fix P-critical issue #100340 * [BETA 1.64] Only override published resolver when the workspace is different rust-lang/cargo#10970 r? `@Mark-Simulacrum`
2 parents 56714e5 + 8ae6300 commit fb2194a

File tree

4 files changed

+312
-344
lines changed

4 files changed

+312
-344
lines changed

compiler/rustc_ast_lowering/src/lib.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,20 @@ impl ResolverAstLoweringExt for ResolverAstLowering {
220220
}
221221

222222
fn get_remapped_def_id(&self, mut local_def_id: LocalDefId) -> LocalDefId {
223-
for map in &self.generics_def_id_map {
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.
236+
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:?}`");
226239
local_def_id = *r;

0 commit comments

Comments
 (0)