summaryrefslogtreecommitdiffstats
path: root/tests/ui/interior-mutability
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
commit64d98f8ee037282c35007b64c2649055c56af1db (patch)
tree5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /tests/ui/interior-mutability
parentAdding debian version 1.67.1+dfsg1-1. (diff)
downloadrustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz
rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/interior-mutability')
-rw-r--r--tests/ui/interior-mutability/interior-mutability.rs7
-rw-r--r--tests/ui/interior-mutability/interior-mutability.stderr22
2 files changed, 29 insertions, 0 deletions
diff --git a/tests/ui/interior-mutability/interior-mutability.rs b/tests/ui/interior-mutability/interior-mutability.rs
new file mode 100644
index 000000000..c704acc22
--- /dev/null
+++ b/tests/ui/interior-mutability/interior-mutability.rs
@@ -0,0 +1,7 @@
+use std::cell::Cell;
+use std::panic::catch_unwind;
+fn main() {
+ let mut x = Cell::new(22);
+ catch_unwind(|| { x.set(23); });
+ //~^ ERROR the type `UnsafeCell<i32>` may contain interior mutability and a
+}
diff --git a/tests/ui/interior-mutability/interior-mutability.stderr b/tests/ui/interior-mutability/interior-mutability.stderr
new file mode 100644
index 000000000..034d22591
--- /dev/null
+++ b/tests/ui/interior-mutability/interior-mutability.stderr
@@ -0,0 +1,22 @@
+error[E0277]: the type `UnsafeCell<i32>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
+ --> $DIR/interior-mutability.rs:5:18
+ |
+LL | catch_unwind(|| { x.set(23); });
+ | ------------ ^^^^^^^^^^^^^^^^^ `UnsafeCell<i32>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
+ | |
+ | required by a bound introduced by this call
+ |
+ = help: within `Cell<i32>`, the trait `RefUnwindSafe` is not implemented for `UnsafeCell<i32>`
+ = note: required because it appears within the type `Cell<i32>`
+ = note: required for `&Cell<i32>` to implement `UnwindSafe`
+note: required because it's used within this closure
+ --> $DIR/interior-mutability.rs:5:18
+ |
+LL | catch_unwind(|| { x.set(23); });
+ | ^^
+note: required by a bound in `catch_unwind`
+ --> $SRC_DIR/std/src/panic.rs:LL:COL
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.