about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-03-24 10:49:16 +0100
committerMatthias Krüger <matthias.krueger@famsik.de>2024-03-24 10:51:23 +0100
commite800b99347b88dc90bb105a0551011ac01ead624 (patch)
tree30e904c2104577961f8c9f0027f7c86ebe79eefd
parent56ea366763b5fbac9ded4e0bdab7bd0fe1cb75b2 (diff)
add tests for ICE in mir building with captured value of unresolved type, None in compiler/rustc_mir_build/src/build/expr/as_place.rs #110453
Fixes #110453
-rw-r--r--tests/ui/mir/mir-build-2021-closure-capture-ice-110453-1.rs18
-rw-r--r--tests/ui/mir/mir-build-2021-closure-capture-ice-110453-1.stderr14
-rw-r--r--tests/ui/mir/mir-build-2021-closure-capture-ice-110453-2.rs11
-rw-r--r--tests/ui/mir/mir-build-2021-closure-capture-ice-110453-2.stderr9
4 files changed, 52 insertions, 0 deletions
diff --git a/tests/ui/mir/mir-build-2021-closure-capture-ice-110453-1.rs b/tests/ui/mir/mir-build-2021-closure-capture-ice-110453-1.rs
new file mode 100644
index 00000000000..0b2e63bfcf7
--- /dev/null
+++ b/tests/ui/mir/mir-build-2021-closure-capture-ice-110453-1.rs
@@ -0,0 +1,18 @@
+// ICE in mir building with captured value of unresolved type
+// None in compiler/rustc_mir_build/src/build/expr/as_place.rs
+// issue: rust-lang/rust#110453
+//@ edition:2021
+
+#![crate_type="lib"]
+
+pub struct B;
+pub fn a() -> B { B }
+
+mod handlers {
+    pub struct C(B);
+    //~^ ERROR cannot find type `B` in this scope
+    pub fn c() -> impl Fn() -> C {
+        let a1 = ();
+        || C((crate::a(), a1).into())
+    }
+}
diff --git a/tests/ui/mir/mir-build-2021-closure-capture-ice-110453-1.stderr b/tests/ui/mir/mir-build-2021-closure-capture-ice-110453-1.stderr
new file mode 100644
index 00000000000..468da0227d3
--- /dev/null
+++ b/tests/ui/mir/mir-build-2021-closure-capture-ice-110453-1.stderr
@@ -0,0 +1,14 @@
+error[E0412]: cannot find type `B` in this scope
+  --> $DIR/mir-build-2021-closure-capture-ice-110453-1.rs:12:18
+   |
+LL |     pub struct C(B);
+   |                  ^ not found in this scope
+   |
+help: consider importing this struct
+   |
+LL +     use crate::B;
+   |
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0412`.
diff --git a/tests/ui/mir/mir-build-2021-closure-capture-ice-110453-2.rs b/tests/ui/mir/mir-build-2021-closure-capture-ice-110453-2.rs
new file mode 100644
index 00000000000..d63ccc6651c
--- /dev/null
+++ b/tests/ui/mir/mir-build-2021-closure-capture-ice-110453-2.rs
@@ -0,0 +1,11 @@
+// ICE in mir building with captured value of unresolved type
+// None in compiler/rustc_mir_build/src/build/expr/as_place.rs
+// issue: rust-lang/rust#110453
+//@ edition:2021
+
+#![crate_type="lib"]
+
+pub fn dup(f: impl Fn(i32) -> i32) -> impl Fn(as_str) -> i32 {
+//~^ ERROR cannot find type `as_str` in this scope
+    move |a| f(a * 2)
+}
diff --git a/tests/ui/mir/mir-build-2021-closure-capture-ice-110453-2.stderr b/tests/ui/mir/mir-build-2021-closure-capture-ice-110453-2.stderr
new file mode 100644
index 00000000000..8fe4981eb3f
--- /dev/null
+++ b/tests/ui/mir/mir-build-2021-closure-capture-ice-110453-2.stderr
@@ -0,0 +1,9 @@
+error[E0412]: cannot find type `as_str` in this scope
+  --> $DIR/mir-build-2021-closure-capture-ice-110453-2.rs:8:47
+   |
+LL | pub fn dup(f: impl Fn(i32) -> i32) -> impl Fn(as_str) -> i32 {
+   |                                               ^^^^^^ not found in this scope
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0412`.