-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// compile-flags: --edition 2024 -Zunstable-options | ||
|
||
fn main() { | ||
static mut X: i32 = 1; | ||
unsafe { | ||
let _y = &X; | ||
//~^ ERROR use of mutable static is discouraged | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
error[E0796]: use of mutable static is discouraged | ||
--> $DIR/use_of_mutable_static_unsafe_block.rs:6:18 | ||
| | ||
LL | let _y = &X; | ||
| ^^ 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 previous error | ||
|
||
For more information about this error, try `rustc --explain E0796`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// compile-flags: --edition 2024 -Zunstable-options | ||
|
||
fn main() {} | ||
|
||
unsafe fn _foo() { | ||
static mut X: i32 = 1; | ||
let _y = &X; | ||
//~^ ERROR use of mutable static is discouraged | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
error[E0796]: use of mutable static is discouraged | ||
--> $DIR/use_of_mutable_static_unsafe_fn.rs:7:14 | ||
| | ||
LL | let _y = &X; | ||
| ^^ 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 previous error | ||
|
||
For more information about this error, try `rustc --explain E0796`. |