Skip to content

Commit

Permalink
Rollup merge of rust-lang#91875 - b-naber:mir-transform-norm-erase-re…
Browse files Browse the repository at this point in the history
…g, r=Aaron1011

Use try_normalize_erasing_regions in RevealAllVisitor

Fixes rust-lang#91745

Thanks to `@Aaron1011` for [pointing out the problem](rust-lang#91745 (comment)).

r? `@Aaron1011`
  • Loading branch information
matthiaskrgr authored Dec 14, 2021
2 parents 3fc0a01 + f3ecd64 commit 1dc4b24
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
5 changes: 4 additions & 1 deletion compiler/rustc_mir_transform/src/reveal_all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ impl<'tcx> MutVisitor<'tcx> for RevealAllVisitor<'tcx> {

#[inline]
fn visit_ty(&mut self, ty: &mut Ty<'tcx>, _: TyContext) {
*ty = self.tcx.normalize_erasing_regions(self.param_env, ty);
// We have to use `try_normalize_erasing_regions` here, since it's
// possible that we visit impossible-to-satisfy where clauses here,
// see #91745
*ty = self.tcx.try_normalize_erasing_regions(self.param_env, *ty).unwrap_or(ty);
}
}
21 changes: 21 additions & 0 deletions src/test/ui/mir/issue-91745.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// check-pass

pub trait Foo {
type Bar;
}

pub trait Broken {
type Assoc;
fn broken(&self) where Self::Assoc: Foo;
}

impl<T> Broken for T {
type Assoc = ();
fn broken(&self) where Self::Assoc: Foo {
let _x: <Self::Assoc as Foo>::Bar;
}
}

fn main() {
let _m: &dyn Broken<Assoc=()> = &();
}

0 comments on commit 1dc4b24

Please sign in to comment.