about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2022-08-10 09:28:24 -0700
committerGitHub <noreply@github.com>2022-08-10 09:28:24 -0700
commit96fc9f177e37f560787e37b8fee4e1dd772b6bfa (patch)
tree3b83176d382bfb3fca5dca109622f8d2074d032d /src/test
parentefa182f3db46b70841dc4481b112cb365b52921a (diff)
parent4bf350dc388792fe859580ad92b422f701573616 (diff)
downloadrust-96fc9f177e37f560787e37b8fee4e1dd772b6bfa.tar.gz
rust-96fc9f177e37f560787e37b8fee4e1dd772b6bfa.zip
Rollup merge of #100359 - b-naber:valtrees-pretty-print-ice, r=lcnr
Special-case references to leafs in valtree pretty-printing

Fixes https://github.com/rust-lang/rust/issues/100313
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/const-generics/issues/issue-100313.rs21
-rw-r--r--src/test/ui/const-generics/issues/issue-100313.stderr15
2 files changed, 36 insertions, 0 deletions
diff --git a/src/test/ui/const-generics/issues/issue-100313.rs b/src/test/ui/const-generics/issues/issue-100313.rs
new file mode 100644
index 00000000000..4e9d3626aa8
--- /dev/null
+++ b/src/test/ui/const-generics/issues/issue-100313.rs
@@ -0,0 +1,21 @@
+#![allow(incomplete_features)]
+#![feature(const_mut_refs)]
+#![feature(adt_const_params)]
+
+struct T<const B: &'static bool>;
+
+impl <const B: &'static bool> T<B> {
+    const fn set_false(&self) {
+        unsafe {
+            *(B as *const bool as *mut bool) = false;
+            //~^ ERROR evaluation of constant value failed [E0080]
+        }
+    }
+}
+
+const _: () = {
+    let x = T::<{&true}>;
+    x.set_false();
+};
+
+fn main() {}
diff --git a/src/test/ui/const-generics/issues/issue-100313.stderr b/src/test/ui/const-generics/issues/issue-100313.stderr
new file mode 100644
index 00000000000..f3ce357c2bb
--- /dev/null
+++ b/src/test/ui/const-generics/issues/issue-100313.stderr
@@ -0,0 +1,15 @@
+error[E0080]: evaluation of constant value failed
+  --> $DIR/issue-100313.rs:10:13
+   |
+LL |             *(B as *const bool as *mut bool) = false;
+   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |             |
+   |             writing to alloc7 which is read-only
+   |             inside `T::<&true>::set_false` at $DIR/issue-100313.rs:10:13
+...
+LL |     x.set_false();
+   |     ------------- inside `_` at $DIR/issue-100313.rs:18:5
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0080`.