about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFelix S. Klock II <pnkfelix@pnkfx.org>2024-03-08 11:46:17 -0500
committerFelix S. Klock II <pnkfelix@pnkfx.org>2024-03-13 10:32:41 -0400
commitf86b46a9cc0dadaee69ca4e4a911ce122db17b24 (patch)
tree5d5f1000d6294e5e7b31ba61570db9e6c55165bf
parenta8549b4152566d8fbd34c097236df1db3d9afd3c (diff)
downloadrust-f86b46a9cc0dadaee69ca4e4a911ce122db17b24.tar.gz
rust-f86b46a9cc0dadaee69ca4e4a911ce122db17b24.zip
regression test from 121610.
-rw-r--r--tests/ui/consts/future-incompat-mutable-in-final-value-issue-121610.rs18
-rw-r--r--tests/ui/consts/future-incompat-mutable-in-final-value-issue-121610.stderr23
2 files changed, 41 insertions, 0 deletions
diff --git a/tests/ui/consts/future-incompat-mutable-in-final-value-issue-121610.rs b/tests/ui/consts/future-incompat-mutable-in-final-value-issue-121610.rs
new file mode 100644
index 00000000000..ca119f831b1
--- /dev/null
+++ b/tests/ui/consts/future-incompat-mutable-in-final-value-issue-121610.rs
@@ -0,0 +1,18 @@
+//@ check-pass
+use std::cell::Cell;
+
+pub enum JsValue {
+    Undefined,
+    Object(Cell<bool>),
+}
+
+impl ::std::ops::Drop for JsValue {
+    fn drop(&mut self) {}
+}
+
+const UNDEFINED: &JsValue = &JsValue::Undefined;
+    //~^ WARN encountered mutable pointer in final value of constant
+    //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+
+fn main() {
+}
diff --git a/tests/ui/consts/future-incompat-mutable-in-final-value-issue-121610.stderr b/tests/ui/consts/future-incompat-mutable-in-final-value-issue-121610.stderr
new file mode 100644
index 00000000000..85de4e7ff32
--- /dev/null
+++ b/tests/ui/consts/future-incompat-mutable-in-final-value-issue-121610.stderr
@@ -0,0 +1,23 @@
+warning: encountered mutable pointer in final value of constant
+  --> $DIR/future-incompat-mutable-in-final-value-issue-121610.rs:13:1
+   |
+LL | const UNDEFINED: &JsValue = &JsValue::Undefined;
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+   = note: `#[warn(const_eval_mutable_ptr_in_final_value)]` on by default
+
+warning: 1 warning emitted
+
+Future incompatibility report: Future breakage diagnostic:
+warning: encountered mutable pointer in final value of constant
+  --> $DIR/future-incompat-mutable-in-final-value-issue-121610.rs:13:1
+   |
+LL | const UNDEFINED: &JsValue = &JsValue::Undefined;
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+   = note: `#[warn(const_eval_mutable_ptr_in_final_value)]` on by default
+