diff options
| author | syvb <me@iter.ca> | 2023-07-14 22:06:32 -0400 |
|---|---|---|
| committer | syvb <me@iter.ca> | 2023-07-15 11:59:38 -0400 |
| commit | 2cfe8ed37d5949a823ad3f0fe1db5e79f9fc9f90 (patch) | |
| tree | e2b5077ab2c2f4c8e6f577189c0d8d0417d9f21d /tests/ui/unsafe | |
| parent | ad963232d9b987d66a6f8e6ec4141f672b8b9900 (diff) | |
| download | rust-2cfe8ed37d5949a823ad3f0fe1db5e79f9fc9f90.tar.gz rust-2cfe8ed37d5949a823ad3f0fe1db5e79f9fc9f90.zip | |
Implement "items do not inherit unsafety" for THIR unsafeck
Diffstat (limited to 'tests/ui/unsafe')
| -rw-r--r-- | tests/ui/unsafe/unsafe-not-inherited.mirunsafeck.stderr (renamed from tests/ui/unsafe/unsafe-not-inherited.stderr) | 4 | ||||
| -rw-r--r-- | tests/ui/unsafe/unsafe-not-inherited.rs | 2 | ||||
| -rw-r--r-- | tests/ui/unsafe/unsafe-not-inherited.thirunsafeck.stderr | 24 |
3 files changed, 28 insertions, 2 deletions
diff --git a/tests/ui/unsafe/unsafe-not-inherited.stderr b/tests/ui/unsafe/unsafe-not-inherited.mirunsafeck.stderr index 3bc5ca5c9d1..5536efbc6f4 100644 --- a/tests/ui/unsafe/unsafe-not-inherited.stderr +++ b/tests/ui/unsafe/unsafe-not-inherited.mirunsafeck.stderr @@ -1,5 +1,5 @@ error[E0133]: use of mutable static is unsafe and requires unsafe function or block - --> $DIR/unsafe-not-inherited.rs:6:31 + --> $DIR/unsafe-not-inherited.rs:8:31 | LL | unsafe {static BAR: u64 = FOO;} | ------ ^^^ use of mutable static @@ -9,7 +9,7 @@ LL | unsafe {static BAR: u64 = FOO;} = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior error[E0133]: call to unsafe function is unsafe and requires unsafe function or block - --> $DIR/unsafe-not-inherited.rs:18:13 + --> $DIR/unsafe-not-inherited.rs:20:13 | LL | unsafe { | ------ items do not inherit unsafety from separate enclosing items diff --git a/tests/ui/unsafe/unsafe-not-inherited.rs b/tests/ui/unsafe/unsafe-not-inherited.rs index 6d797caa0f9..f9d9a595714 100644 --- a/tests/ui/unsafe/unsafe-not-inherited.rs +++ b/tests/ui/unsafe/unsafe-not-inherited.rs @@ -1,3 +1,5 @@ +// revisions: mirunsafeck thirunsafeck +// [thirunsafeck]compile-flags: -Z thir-unsafeck #![allow(unused, dead_code)] static mut FOO: u64 = 0; diff --git a/tests/ui/unsafe/unsafe-not-inherited.thirunsafeck.stderr b/tests/ui/unsafe/unsafe-not-inherited.thirunsafeck.stderr new file mode 100644 index 00000000000..88ea2e6d1fe --- /dev/null +++ b/tests/ui/unsafe/unsafe-not-inherited.thirunsafeck.stderr @@ -0,0 +1,24 @@ +error[E0133]: use of mutable static is unsafe and requires unsafe function or block + --> $DIR/unsafe-not-inherited.rs:8:31 + | +LL | unsafe {static BAR: u64 = FOO;} + | ------ ^^^ use of mutable static + | | + | items do not inherit unsafety from separate enclosing items + | + = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior + +error[E0133]: call to unsafe function `unsafe_call` is unsafe and requires unsafe function or block + --> $DIR/unsafe-not-inherited.rs:20:13 + | +LL | unsafe { + | ------ items do not inherit unsafety from separate enclosing items +... +LL | unsafe_call(); + | ^^^^^^^^^^^^^ call to unsafe function + | + = note: consult the function's documentation for information on how to avoid undefined behavior + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0133`. |
