about summary refs log tree commit diff
path: root/src/test/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui')
-rw-r--r--src/test/ui/consts/issue-52432.rs10
-rw-r--r--src/test/ui/consts/issue-52432.stderr28
2 files changed, 38 insertions, 0 deletions
diff --git a/src/test/ui/consts/issue-52432.rs b/src/test/ui/consts/issue-52432.rs
new file mode 100644
index 00000000000..2d4c939f47d
--- /dev/null
+++ b/src/test/ui/consts/issue-52432.rs
@@ -0,0 +1,10 @@
+#![feature(const_raw_ptr_to_usize_cast)]
+
+fn main() {
+    [(); &(static |x| {}) as *const _ as usize];
+    //~^ ERROR: closures cannot be static
+    //~| ERROR: type annotations needed
+    [(); &(static || {}) as *const _ as usize];
+    //~^ ERROR: closures cannot be static
+    //~| ERROR: evaluation of constant value failed
+}
diff --git a/src/test/ui/consts/issue-52432.stderr b/src/test/ui/consts/issue-52432.stderr
new file mode 100644
index 00000000000..e9539d24118
--- /dev/null
+++ b/src/test/ui/consts/issue-52432.stderr
@@ -0,0 +1,28 @@
+error[E0697]: closures cannot be static
+  --> $DIR/issue-52432.rs:4:12
+   |
+LL |     [(); &(static |x| {}) as *const _ as usize];
+   |            ^^^^^^^^^^
+
+error[E0697]: closures cannot be static
+  --> $DIR/issue-52432.rs:7:12
+   |
+LL |     [(); &(static || {}) as *const _ as usize];
+   |            ^^^^^^^^^
+
+error[E0282]: type annotations needed
+  --> $DIR/issue-52432.rs:4:20
+   |
+LL |     [(); &(static |x| {}) as *const _ as usize];
+   |                    ^ consider giving this closure parameter a type
+
+error[E0080]: evaluation of constant value failed
+  --> $DIR/issue-52432.rs:7:10
+   |
+LL |     [(); &(static || {}) as *const _ as usize];
+   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "pointer-to-integer cast" needs an rfc before being allowed inside constants
+
+error: aborting due to 4 previous errors
+
+Some errors have detailed explanations: E0080, E0282, E0697.
+For more information about an error, try `rustc --explain E0080`.