diff options
| author | Caio <c410.f3r@gmail.com> | 2021-11-18 12:09:34 -0300 |
|---|---|---|
| committer | Caio <c410.f3r@gmail.com> | 2021-11-18 12:09:34 -0300 |
| commit | 41d9abd76cd514aca23e3409fe6896a3a7d61d1a (patch) | |
| tree | aff7d6c42e88201c903006083095106fd082f16b /src/test/ui/static | |
| parent | 6414e0b5b308d3ae27da83c6a25098cc8aadc1a9 (diff) | |
| download | rust-41d9abd76cd514aca23e3409fe6896a3a7d61d1a.tar.gz rust-41d9abd76cd514aca23e3409fe6896a3a7d61d1a.zip | |
Move some tests to more reasonable directories
Diffstat (limited to 'src/test/ui/static')
| -rw-r--r-- | src/test/ui/static/auxiliary/extern-statics.rs | 4 | ||||
| -rw-r--r-- | src/test/ui/static/safe-extern-statics-mut.mir.stderr | 35 | ||||
| -rw-r--r-- | src/test/ui/static/safe-extern-statics-mut.rs | 17 | ||||
| -rw-r--r-- | src/test/ui/static/safe-extern-statics-mut.thir.stderr | 35 | ||||
| -rw-r--r-- | src/test/ui/static/safe-extern-statics.mir.stderr | 35 | ||||
| -rw-r--r-- | src/test/ui/static/safe-extern-statics.rs | 17 | ||||
| -rw-r--r-- | src/test/ui/static/safe-extern-statics.thir.stderr | 35 | ||||
| -rw-r--r-- | src/test/ui/static/thread-local-in-ctfe.rs | 23 | ||||
| -rw-r--r-- | src/test/ui/static/thread-local-in-ctfe.stderr | 33 |
9 files changed, 234 insertions, 0 deletions
diff --git a/src/test/ui/static/auxiliary/extern-statics.rs b/src/test/ui/static/auxiliary/extern-statics.rs new file mode 100644 index 00000000000..c090bc79fce --- /dev/null +++ b/src/test/ui/static/auxiliary/extern-statics.rs @@ -0,0 +1,4 @@ +extern "C" { + pub static XA: u8; + pub static mut XB: u8; +} diff --git a/src/test/ui/static/safe-extern-statics-mut.mir.stderr b/src/test/ui/static/safe-extern-statics-mut.mir.stderr new file mode 100644 index 00000000000..cec5f9d9c9f --- /dev/null +++ b/src/test/ui/static/safe-extern-statics-mut.mir.stderr @@ -0,0 +1,35 @@ +error[E0133]: use of mutable static is unsafe and requires unsafe function or block + --> $DIR/safe-extern-statics-mut.rs:13:13 + | +LL | let b = B; + | ^ use of mutable static + | + = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior + +error[E0133]: use of mutable static is unsafe and requires unsafe function or block + --> $DIR/safe-extern-statics-mut.rs:14:14 + | +LL | let rb = &B; + | ^^ use of mutable static + | + = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior + +error[E0133]: use of mutable static is unsafe and requires unsafe function or block + --> $DIR/safe-extern-statics-mut.rs:15:14 + | +LL | let xb = XB; + | ^^ use of mutable static + | + = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior + +error[E0133]: use of mutable static is unsafe and requires unsafe function or block + --> $DIR/safe-extern-statics-mut.rs:16:15 + | +LL | let xrb = &XB; + | ^^^ use of mutable static + | + = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0133`. diff --git a/src/test/ui/static/safe-extern-statics-mut.rs b/src/test/ui/static/safe-extern-statics-mut.rs new file mode 100644 index 00000000000..389a4589a71 --- /dev/null +++ b/src/test/ui/static/safe-extern-statics-mut.rs @@ -0,0 +1,17 @@ +// aux-build:extern-statics.rs +// revisions: mir thir +// [thir]compile-flags: -Z thir-unsafeck + +extern crate extern_statics; +use extern_statics::*; + +extern "C" { + static mut B: u8; +} + +fn main() { + let b = B; //~ ERROR use of mutable static is unsafe + let rb = &B; //~ ERROR use of mutable static is unsafe + let xb = XB; //~ ERROR use of mutable static is unsafe + let xrb = &XB; //~ ERROR use of mutable static is unsafe +} diff --git a/src/test/ui/static/safe-extern-statics-mut.thir.stderr b/src/test/ui/static/safe-extern-statics-mut.thir.stderr new file mode 100644 index 00000000000..8e6d2805a0b --- /dev/null +++ b/src/test/ui/static/safe-extern-statics-mut.thir.stderr @@ -0,0 +1,35 @@ +error[E0133]: use of mutable static is unsafe and requires unsafe function or block + --> $DIR/safe-extern-statics-mut.rs:13:13 + | +LL | let b = B; + | ^ use of mutable static + | + = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior + +error[E0133]: use of mutable static is unsafe and requires unsafe function or block + --> $DIR/safe-extern-statics-mut.rs:14:15 + | +LL | let rb = &B; + | ^ use of mutable static + | + = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior + +error[E0133]: use of mutable static is unsafe and requires unsafe function or block + --> $DIR/safe-extern-statics-mut.rs:15:14 + | +LL | let xb = XB; + | ^^ use of mutable static + | + = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior + +error[E0133]: use of mutable static is unsafe and requires unsafe function or block + --> $DIR/safe-extern-statics-mut.rs:16:16 + | +LL | let xrb = &XB; + | ^^ use of mutable static + | + = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0133`. diff --git a/src/test/ui/static/safe-extern-statics.mir.stderr b/src/test/ui/static/safe-extern-statics.mir.stderr new file mode 100644 index 00000000000..102abd0816f --- /dev/null +++ b/src/test/ui/static/safe-extern-statics.mir.stderr @@ -0,0 +1,35 @@ +error[E0133]: use of extern static is unsafe and requires unsafe function or block + --> $DIR/safe-extern-statics.rs:13:13 + | +LL | let a = A; + | ^ use of extern static + | + = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior + +error[E0133]: use of extern static is unsafe and requires unsafe function or block + --> $DIR/safe-extern-statics.rs:14:14 + | +LL | let ra = &A; + | ^^ use of extern static + | + = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior + +error[E0133]: use of extern static is unsafe and requires unsafe function or block + --> $DIR/safe-extern-statics.rs:15:14 + | +LL | let xa = XA; + | ^^ use of extern static + | + = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior + +error[E0133]: use of extern static is unsafe and requires unsafe function or block + --> $DIR/safe-extern-statics.rs:16:15 + | +LL | let xra = &XA; + | ^^^ use of extern static + | + = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0133`. diff --git a/src/test/ui/static/safe-extern-statics.rs b/src/test/ui/static/safe-extern-statics.rs new file mode 100644 index 00000000000..0aa90c442ea --- /dev/null +++ b/src/test/ui/static/safe-extern-statics.rs @@ -0,0 +1,17 @@ +// aux-build:extern-statics.rs +// revisions: mir thir +// [thir]compile-flags: -Z thir-unsafeck + +extern crate extern_statics; +use extern_statics::*; + +extern "C" { + static A: u8; +} + +fn main() { + let a = A; //~ ERROR use of extern static is unsafe + let ra = &A; //~ ERROR use of extern static is unsafe + let xa = XA; //~ ERROR use of extern static is unsafe + let xra = &XA; //~ ERROR use of extern static is unsafe +} diff --git a/src/test/ui/static/safe-extern-statics.thir.stderr b/src/test/ui/static/safe-extern-statics.thir.stderr new file mode 100644 index 00000000000..7fd2182c4c6 --- /dev/null +++ b/src/test/ui/static/safe-extern-statics.thir.stderr @@ -0,0 +1,35 @@ +error[E0133]: use of extern static is unsafe and requires unsafe function or block + --> $DIR/safe-extern-statics.rs:13:13 + | +LL | let a = A; + | ^ use of extern static + | + = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior + +error[E0133]: use of extern static is unsafe and requires unsafe function or block + --> $DIR/safe-extern-statics.rs:14:15 + | +LL | let ra = &A; + | ^ use of extern static + | + = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior + +error[E0133]: use of extern static is unsafe and requires unsafe function or block + --> $DIR/safe-extern-statics.rs:15:14 + | +LL | let xa = XA; + | ^^ use of extern static + | + = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior + +error[E0133]: use of extern static is unsafe and requires unsafe function or block + --> $DIR/safe-extern-statics.rs:16:16 + | +LL | let xra = &XA; + | ^^ use of extern static + | + = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0133`. diff --git a/src/test/ui/static/thread-local-in-ctfe.rs b/src/test/ui/static/thread-local-in-ctfe.rs new file mode 100644 index 00000000000..547e5445aa1 --- /dev/null +++ b/src/test/ui/static/thread-local-in-ctfe.rs @@ -0,0 +1,23 @@ +#![feature(thread_local)] + +#[thread_local] +static A: u32 = 1; + +static B: u32 = A; +//~^ ERROR thread-local statics cannot be accessed at compile-time + +static C: &u32 = &A; +//~^ ERROR thread-local statics cannot be accessed at compile-time + +const D: u32 = A; +//~^ ERROR thread-local statics cannot be accessed at compile-time + +const E: &u32 = &A; +//~^ ERROR thread-local statics cannot be accessed at compile-time + +const fn f() -> u32 { + A + //~^ ERROR thread-local statics cannot be accessed at compile-time +} + +fn main() {} diff --git a/src/test/ui/static/thread-local-in-ctfe.stderr b/src/test/ui/static/thread-local-in-ctfe.stderr new file mode 100644 index 00000000000..fd967604624 --- /dev/null +++ b/src/test/ui/static/thread-local-in-ctfe.stderr @@ -0,0 +1,33 @@ +error[E0625]: thread-local statics cannot be accessed at compile-time + --> $DIR/thread-local-in-ctfe.rs:6:17 + | +LL | static B: u32 = A; + | ^ + +error[E0625]: thread-local statics cannot be accessed at compile-time + --> $DIR/thread-local-in-ctfe.rs:9:19 + | +LL | static C: &u32 = &A; + | ^ + +error[E0625]: thread-local statics cannot be accessed at compile-time + --> $DIR/thread-local-in-ctfe.rs:12:16 + | +LL | const D: u32 = A; + | ^ + +error[E0625]: thread-local statics cannot be accessed at compile-time + --> $DIR/thread-local-in-ctfe.rs:15:18 + | +LL | const E: &u32 = &A; + | ^ + +error[E0625]: thread-local statics cannot be accessed at compile-time + --> $DIR/thread-local-in-ctfe.rs:19:5 + | +LL | A + | ^ + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0625`. |
