summaryrefslogtreecommitdiffstats
path: root/src/test/ui/not-panic
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /src/test/ui/not-panic
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/not-panic')
-rw-r--r--src/test/ui/not-panic/not-panic-safe-2.rs13
-rw-r--r--src/test/ui/not-panic/not-panic-safe-2.stderr34
-rw-r--r--src/test/ui/not-panic/not-panic-safe-3.rs13
-rw-r--r--src/test/ui/not-panic/not-panic-safe-3.stderr34
-rw-r--r--src/test/ui/not-panic/not-panic-safe-4.rs12
-rw-r--r--src/test/ui/not-panic/not-panic-safe-4.stderr34
-rw-r--r--src/test/ui/not-panic/not-panic-safe-5.rs10
-rw-r--r--src/test/ui/not-panic/not-panic-safe-5.stderr17
-rw-r--r--src/test/ui/not-panic/not-panic-safe-6.rs12
-rw-r--r--src/test/ui/not-panic/not-panic-safe-6.stderr34
-rw-r--r--src/test/ui/not-panic/not-panic-safe.rs10
-rw-r--r--src/test/ui/not-panic/not-panic-safe.stderr20
12 files changed, 243 insertions, 0 deletions
diff --git a/src/test/ui/not-panic/not-panic-safe-2.rs b/src/test/ui/not-panic/not-panic-safe-2.rs
new file mode 100644
index 000000000..f3faa7043
--- /dev/null
+++ b/src/test/ui/not-panic/not-panic-safe-2.rs
@@ -0,0 +1,13 @@
+#![allow(dead_code)]
+
+use std::panic::UnwindSafe;
+use std::rc::Rc;
+use std::cell::RefCell;
+
+fn assert<T: UnwindSafe + ?Sized>() {}
+
+fn main() {
+ assert::<Rc<RefCell<i32>>>();
+ //~^ ERROR the type `UnsafeCell<i32>` may contain interior mutability and a
+ //~| ERROR the type `UnsafeCell<isize>` may contain interior mutability and a
+}
diff --git a/src/test/ui/not-panic/not-panic-safe-2.stderr b/src/test/ui/not-panic/not-panic-safe-2.stderr
new file mode 100644
index 000000000..65594702b
--- /dev/null
+++ b/src/test/ui/not-panic/not-panic-safe-2.stderr
@@ -0,0 +1,34 @@
+error[E0277]: the type `UnsafeCell<i32>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
+ --> $DIR/not-panic-safe-2.rs:10:5
+ |
+LL | assert::<Rc<RefCell<i32>>>();
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `UnsafeCell<i32>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
+ |
+ = help: within `RefCell<i32>`, the trait `RefUnwindSafe` is not implemented for `UnsafeCell<i32>`
+ = note: required because it appears within the type `RefCell<i32>`
+ = note: required because of the requirements on the impl of `UnwindSafe` for `Rc<RefCell<i32>>`
+note: required by a bound in `assert`
+ --> $DIR/not-panic-safe-2.rs:7:14
+ |
+LL | fn assert<T: UnwindSafe + ?Sized>() {}
+ | ^^^^^^^^^^ required by this bound in `assert`
+
+error[E0277]: the type `UnsafeCell<isize>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
+ --> $DIR/not-panic-safe-2.rs:10:5
+ |
+LL | assert::<Rc<RefCell<i32>>>();
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `UnsafeCell<isize>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
+ |
+ = help: within `RefCell<i32>`, the trait `RefUnwindSafe` is not implemented for `UnsafeCell<isize>`
+ = note: required because it appears within the type `Cell<isize>`
+ = note: required because it appears within the type `RefCell<i32>`
+ = note: required because of the requirements on the impl of `UnwindSafe` for `Rc<RefCell<i32>>`
+note: required by a bound in `assert`
+ --> $DIR/not-panic-safe-2.rs:7:14
+ |
+LL | fn assert<T: UnwindSafe + ?Sized>() {}
+ | ^^^^^^^^^^ required by this bound in `assert`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/not-panic/not-panic-safe-3.rs b/src/test/ui/not-panic/not-panic-safe-3.rs
new file mode 100644
index 000000000..21f0c0993
--- /dev/null
+++ b/src/test/ui/not-panic/not-panic-safe-3.rs
@@ -0,0 +1,13 @@
+#![allow(dead_code)]
+
+use std::panic::UnwindSafe;
+use std::sync::Arc;
+use std::cell::RefCell;
+
+fn assert<T: UnwindSafe + ?Sized>() {}
+
+fn main() {
+ assert::<Arc<RefCell<i32>>>();
+ //~^ ERROR the type `UnsafeCell<i32>` may contain interior mutability and a
+ //~| ERROR the type `UnsafeCell<isize>` may contain interior mutability and a
+}
diff --git a/src/test/ui/not-panic/not-panic-safe-3.stderr b/src/test/ui/not-panic/not-panic-safe-3.stderr
new file mode 100644
index 000000000..db3fdb253
--- /dev/null
+++ b/src/test/ui/not-panic/not-panic-safe-3.stderr
@@ -0,0 +1,34 @@
+error[E0277]: the type `UnsafeCell<i32>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
+ --> $DIR/not-panic-safe-3.rs:10:5
+ |
+LL | assert::<Arc<RefCell<i32>>>();
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `UnsafeCell<i32>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
+ |
+ = help: within `RefCell<i32>`, the trait `RefUnwindSafe` is not implemented for `UnsafeCell<i32>`
+ = note: required because it appears within the type `RefCell<i32>`
+ = note: required because of the requirements on the impl of `UnwindSafe` for `Arc<RefCell<i32>>`
+note: required by a bound in `assert`
+ --> $DIR/not-panic-safe-3.rs:7:14
+ |
+LL | fn assert<T: UnwindSafe + ?Sized>() {}
+ | ^^^^^^^^^^ required by this bound in `assert`
+
+error[E0277]: the type `UnsafeCell<isize>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
+ --> $DIR/not-panic-safe-3.rs:10:5
+ |
+LL | assert::<Arc<RefCell<i32>>>();
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `UnsafeCell<isize>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
+ |
+ = help: within `RefCell<i32>`, the trait `RefUnwindSafe` is not implemented for `UnsafeCell<isize>`
+ = note: required because it appears within the type `Cell<isize>`
+ = note: required because it appears within the type `RefCell<i32>`
+ = note: required because of the requirements on the impl of `UnwindSafe` for `Arc<RefCell<i32>>`
+note: required by a bound in `assert`
+ --> $DIR/not-panic-safe-3.rs:7:14
+ |
+LL | fn assert<T: UnwindSafe + ?Sized>() {}
+ | ^^^^^^^^^^ required by this bound in `assert`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/not-panic/not-panic-safe-4.rs b/src/test/ui/not-panic/not-panic-safe-4.rs
new file mode 100644
index 000000000..ba93af5c0
--- /dev/null
+++ b/src/test/ui/not-panic/not-panic-safe-4.rs
@@ -0,0 +1,12 @@
+#![allow(dead_code)]
+
+use std::panic::UnwindSafe;
+use std::cell::RefCell;
+
+fn assert<T: UnwindSafe + ?Sized>() {}
+
+fn main() {
+ assert::<&RefCell<i32>>();
+ //~^ ERROR the type `UnsafeCell<i32>` may contain interior mutability and a
+ //~| ERROR the type `UnsafeCell<isize>` may contain interior mutability and a
+}
diff --git a/src/test/ui/not-panic/not-panic-safe-4.stderr b/src/test/ui/not-panic/not-panic-safe-4.stderr
new file mode 100644
index 000000000..079601b39
--- /dev/null
+++ b/src/test/ui/not-panic/not-panic-safe-4.stderr
@@ -0,0 +1,34 @@
+error[E0277]: the type `UnsafeCell<i32>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
+ --> $DIR/not-panic-safe-4.rs:9:5
+ |
+LL | assert::<&RefCell<i32>>();
+ | ^^^^^^^^^^^^^^^^^^^^^^^ `UnsafeCell<i32>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
+ |
+ = help: within `RefCell<i32>`, the trait `RefUnwindSafe` is not implemented for `UnsafeCell<i32>`
+ = note: required because it appears within the type `RefCell<i32>`
+ = note: required because of the requirements on the impl of `UnwindSafe` for `&RefCell<i32>`
+note: required by a bound in `assert`
+ --> $DIR/not-panic-safe-4.rs:6:14
+ |
+LL | fn assert<T: UnwindSafe + ?Sized>() {}
+ | ^^^^^^^^^^ required by this bound in `assert`
+
+error[E0277]: the type `UnsafeCell<isize>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
+ --> $DIR/not-panic-safe-4.rs:9:5
+ |
+LL | assert::<&RefCell<i32>>();
+ | ^^^^^^^^^^^^^^^^^^^^^^^ `UnsafeCell<isize>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
+ |
+ = help: within `RefCell<i32>`, the trait `RefUnwindSafe` is not implemented for `UnsafeCell<isize>`
+ = note: required because it appears within the type `Cell<isize>`
+ = note: required because it appears within the type `RefCell<i32>`
+ = note: required because of the requirements on the impl of `UnwindSafe` for `&RefCell<i32>`
+note: required by a bound in `assert`
+ --> $DIR/not-panic-safe-4.rs:6:14
+ |
+LL | fn assert<T: UnwindSafe + ?Sized>() {}
+ | ^^^^^^^^^^ required by this bound in `assert`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/not-panic/not-panic-safe-5.rs b/src/test/ui/not-panic/not-panic-safe-5.rs
new file mode 100644
index 000000000..e0d37517d
--- /dev/null
+++ b/src/test/ui/not-panic/not-panic-safe-5.rs
@@ -0,0 +1,10 @@
+#![allow(dead_code)]
+
+use std::panic::UnwindSafe;
+use std::cell::UnsafeCell;
+
+fn assert<T: UnwindSafe + ?Sized>() {}
+
+fn main() {
+ assert::<*const UnsafeCell<i32>>(); //~ ERROR E0277
+}
diff --git a/src/test/ui/not-panic/not-panic-safe-5.stderr b/src/test/ui/not-panic/not-panic-safe-5.stderr
new file mode 100644
index 000000000..edd0f72dd
--- /dev/null
+++ b/src/test/ui/not-panic/not-panic-safe-5.stderr
@@ -0,0 +1,17 @@
+error[E0277]: the type `UnsafeCell<i32>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
+ --> $DIR/not-panic-safe-5.rs:9:5
+ |
+LL | assert::<*const UnsafeCell<i32>>();
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `UnsafeCell<i32>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
+ |
+ = help: the trait `RefUnwindSafe` is not implemented for `UnsafeCell<i32>`
+ = note: required because of the requirements on the impl of `UnwindSafe` for `*const UnsafeCell<i32>`
+note: required by a bound in `assert`
+ --> $DIR/not-panic-safe-5.rs:6:14
+ |
+LL | fn assert<T: UnwindSafe + ?Sized>() {}
+ | ^^^^^^^^^^ required by this bound in `assert`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/not-panic/not-panic-safe-6.rs b/src/test/ui/not-panic/not-panic-safe-6.rs
new file mode 100644
index 000000000..4915096dc
--- /dev/null
+++ b/src/test/ui/not-panic/not-panic-safe-6.rs
@@ -0,0 +1,12 @@
+#![allow(dead_code)]
+
+use std::panic::UnwindSafe;
+use std::cell::RefCell;
+
+fn assert<T: UnwindSafe + ?Sized>() {}
+
+fn main() {
+ assert::<*mut RefCell<i32>>();
+ //~^ ERROR the type `UnsafeCell<i32>` may contain interior mutability and a
+ //~| ERROR the type `UnsafeCell<isize>` may contain interior mutability and a
+}
diff --git a/src/test/ui/not-panic/not-panic-safe-6.stderr b/src/test/ui/not-panic/not-panic-safe-6.stderr
new file mode 100644
index 000000000..f3b784a29
--- /dev/null
+++ b/src/test/ui/not-panic/not-panic-safe-6.stderr
@@ -0,0 +1,34 @@
+error[E0277]: the type `UnsafeCell<i32>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
+ --> $DIR/not-panic-safe-6.rs:9:5
+ |
+LL | assert::<*mut RefCell<i32>>();
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `UnsafeCell<i32>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
+ |
+ = help: within `RefCell<i32>`, the trait `RefUnwindSafe` is not implemented for `UnsafeCell<i32>`
+ = note: required because it appears within the type `RefCell<i32>`
+ = note: required because of the requirements on the impl of `UnwindSafe` for `*mut RefCell<i32>`
+note: required by a bound in `assert`
+ --> $DIR/not-panic-safe-6.rs:6:14
+ |
+LL | fn assert<T: UnwindSafe + ?Sized>() {}
+ | ^^^^^^^^^^ required by this bound in `assert`
+
+error[E0277]: the type `UnsafeCell<isize>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
+ --> $DIR/not-panic-safe-6.rs:9:5
+ |
+LL | assert::<*mut RefCell<i32>>();
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `UnsafeCell<isize>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
+ |
+ = help: within `RefCell<i32>`, the trait `RefUnwindSafe` is not implemented for `UnsafeCell<isize>`
+ = note: required because it appears within the type `Cell<isize>`
+ = note: required because it appears within the type `RefCell<i32>`
+ = note: required because of the requirements on the impl of `UnwindSafe` for `*mut RefCell<i32>`
+note: required by a bound in `assert`
+ --> $DIR/not-panic-safe-6.rs:6:14
+ |
+LL | fn assert<T: UnwindSafe + ?Sized>() {}
+ | ^^^^^^^^^^ required by this bound in `assert`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/not-panic/not-panic-safe.rs b/src/test/ui/not-panic/not-panic-safe.rs
new file mode 100644
index 000000000..4165c5dc1
--- /dev/null
+++ b/src/test/ui/not-panic/not-panic-safe.rs
@@ -0,0 +1,10 @@
+#![allow(dead_code)]
+
+use std::panic::UnwindSafe;
+
+fn assert<T: UnwindSafe + ?Sized>() {}
+
+fn main() {
+ assert::<&mut i32>();
+ //~^ ERROR the type `&mut i32` may not be safely transferred across an unwind boundary
+}
diff --git a/src/test/ui/not-panic/not-panic-safe.stderr b/src/test/ui/not-panic/not-panic-safe.stderr
new file mode 100644
index 000000000..2cd51a439
--- /dev/null
+++ b/src/test/ui/not-panic/not-panic-safe.stderr
@@ -0,0 +1,20 @@
+error[E0277]: the type `&mut i32` may not be safely transferred across an unwind boundary
+ --> $DIR/not-panic-safe.rs:8:14
+ |
+LL | assert::<&mut i32>();
+ | -^^^^^^^
+ | |
+ | `&mut i32` may not be safely transferred across an unwind boundary
+ | help: consider removing the leading `&`-reference
+ |
+ = help: the trait `UnwindSafe` is not implemented for `&mut i32`
+ = note: `UnwindSafe` is implemented for `&i32`, but not for `&mut i32`
+note: required by a bound in `assert`
+ --> $DIR/not-panic-safe.rs:5:14
+ |
+LL | fn assert<T: UnwindSafe + ?Sized>() {}
+ | ^^^^^^^^^^ required by this bound in `assert`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.