Skip to content

Commit

Permalink
Auto merge of #100412 - Mark-Simulacrum:beta-next, r=Mark-Simulacrum
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
bors committed Aug 14, 2022
2 parents 56714e5 + 8ae6300 commit fb2194a
Show file tree
Hide file tree
Showing 4 changed files with 312 additions and 344 deletions.
15 changes: 14 additions & 1 deletion compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,20 @@ impl ResolverAstLoweringExt for ResolverAstLowering {
}

fn get_remapped_def_id(&self, mut local_def_id: LocalDefId) -> LocalDefId {
for map in &self.generics_def_id_map {
// `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:?}`");
local_def_id = *r;
Expand Down
Loading

0 comments on commit fb2194a

Please sign in to comment.