Rollup merge of #91875 - b-naber:mir-transform-norm-erase-reg, r=Aaron1011

Use try_normalize_erasing_regions in RevealAllVisitor

Fixes https://github.com/rust-lang/rust/issues/91745

Thanks to ``@Aaron1011`` for [pointing out the problem](https://github.com/rust-lang/rust/issues/91745#issuecomment-991996008).

r? ``@Aaron1011``
This commit is contained in:
Matthias Krüger 2021-12-14 10:21:05 +01:00 committed by GitHub
commit b50bb65c2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 1 deletions

View File

@ -36,6 +36,9 @@ fn tcx(&self) -> TyCtxt<'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);
}
}

View File

@ -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=()> = &();
}