Skip to content

Commit b50bb65

Browse files
authored
Rollup merge of #91875 - b-naber:mir-transform-norm-erase-reg, r=Aaron1011
Use try_normalize_erasing_regions in RevealAllVisitor Fixes #91745 Thanks to ``@Aaron1011`` for [pointing out the problem](#91745 (comment)). r? ``@Aaron1011``
2 parents 75e8d65 + f3ecd64 commit b50bb65

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

compiler/rustc_mir_transform/src/reveal_all.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ impl<'tcx> MutVisitor<'tcx> for RevealAllVisitor<'tcx> {
3636

3737
#[inline]
3838
fn visit_ty(&mut self, ty: &mut Ty<'tcx>, _: TyContext) {
39-
*ty = self.tcx.normalize_erasing_regions(self.param_env, ty);
39+
// We have to use `try_normalize_erasing_regions` here, since it's
40+
// possible that we visit impossible-to-satisfy where clauses here,
41+
// see #91745
42+
*ty = self.tcx.try_normalize_erasing_regions(self.param_env, *ty).unwrap_or(ty);
4043
}
4144
}

src/test/ui/mir/issue-91745.rs

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// check-pass
2+
3+
pub trait Foo {
4+
type Bar;
5+
}
6+
7+
pub trait Broken {
8+
type Assoc;
9+
fn broken(&self) where Self::Assoc: Foo;
10+
}
11+
12+
impl<T> Broken for T {
13+
type Assoc = ();
14+
fn broken(&self) where Self::Assoc: Foo {
15+
let _x: <Self::Assoc as Foo>::Bar;
16+
}
17+
}
18+
19+
fn main() {
20+
let _m: &dyn Broken<Assoc=()> = &();
21+
}

0 commit comments

Comments
 (0)