Skip to content

Commit e0abb31

Browse files
committed
Add test for E0796 error
1 parent a231612 commit e0abb31

4 files changed

+40
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// compile-flags: --edition 2024 -Zunstable-options
2+
3+
fn main() {
4+
static mut X: i32 = 1;
5+
unsafe {
6+
let _y = &X;
7+
//~^ ERROR use of mutable static is discouraged
8+
}
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0796]: use of mutable static is discouraged
2+
--> $DIR/use_of_mutable_static_unsafe_block.rs:6:18
3+
|
4+
LL | let _y = &X;
5+
| ^^ use of mutable static
6+
|
7+
= note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0796`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// compile-flags: --edition 2024 -Zunstable-options
2+
3+
fn main() {}
4+
5+
unsafe fn _foo() {
6+
static mut X: i32 = 1;
7+
let _y = &X;
8+
//~^ ERROR use of mutable static is discouraged
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0796]: use of mutable static is discouraged
2+
--> $DIR/use_of_mutable_static_unsafe_fn.rs:7:14
3+
|
4+
LL | let _y = &X;
5+
| ^^ use of mutable static
6+
|
7+
= note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0796`.

0 commit comments

Comments
 (0)