]> git.lizzy.rs Git - rust.git/commitdiff
use try_normalize_erasing_regions in RevealAllVisitor
authorb-naber <bn263@gmx.de>
Mon, 13 Dec 2021 21:24:08 +0000 (22:24 +0100)
committerb-naber <bn263@gmx.de>
Mon, 13 Dec 2021 22:13:24 +0000 (23:13 +0100)
compiler/rustc_mir_transform/src/reveal_all.rs
src/test/ui/mir/issue-91745.rs [new file with mode: 0644]

index a717dd3e0cd8a6686de92de311770ff0c179d7ec..ee661793a44aae74cc7f042cd140f94ad32d1db2 100644 (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);
     }
 }
diff --git a/src/test/ui/mir/issue-91745.rs b/src/test/ui/mir/issue-91745.rs
new file mode 100644 (file)
index 0000000..ca3d66b
--- /dev/null
@@ -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=()> = &();
+}