1
Fork 0

use try_normalize_erasing_regions in RevealAllVisitor

This commit is contained in:
b-naber 2021-12-13 22:24:08 +01:00
parent a0a4c7d1e4
commit f3ecd64c61
2 changed files with 25 additions and 1 deletions

View file

@ -36,6 +36,9 @@ impl<'tcx> MutVisitor<'tcx> for RevealAllVisitor<'tcx> {
#[inline] #[inline]
fn visit_ty(&mut self, ty: &mut Ty<'tcx>, _: TyContext) { 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=()> = &();
}