-
Notifications
You must be signed in to change notification settings - Fork 13k
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
59 additions
and
2 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
12 changes: 12 additions & 0 deletions
12
tests/ui/borrowck/borrowck-unsafe-static-mutable-borrows.stderr
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,12 @@ | ||
warning: use of mutable static is discouraged | ||
--> $DIR/borrowck-unsafe-static-mutable-borrows.rs:19:30 | ||
| | ||
LL | let sfoo: *mut Foo = &mut SFOO; | ||
| ^^^^^^^^^ use of mutable static | ||
| | ||
= note: use of mutable static is a hard error from 2024 edition | ||
= note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior | ||
= note: `#[warn(static_mut_ref)]` on by default | ||
|
||
warning: 1 warning emitted | ||
|
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,15 @@ | ||
#![deny(static_mut_ref)] | ||
|
||
fn main() { | ||
static mut X: i32 = 1; | ||
unsafe { | ||
let _y = &X; | ||
//~^ ERROR use of mutable static is discouraged [static_mut_ref] | ||
} | ||
} | ||
|
||
unsafe fn _foo() { | ||
static mut X: i32 = 1; | ||
let _y = &X; | ||
//~^ ERROR use of mutable static is discouraged [static_mut_ref] | ||
} |
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,25 @@ | ||
error: use of mutable static is discouraged | ||
--> $DIR/lint_static_mut_ref.rs:6:18 | ||
| | ||
LL | let _y = &X; | ||
| ^^ use of mutable static | ||
| | ||
= note: use of mutable static is a hard error from 2024 edition | ||
= note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior | ||
note: the lint level is defined here | ||
--> $DIR/lint_static_mut_ref.rs:1:9 | ||
| | ||
LL | #![deny(static_mut_ref)] | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error: use of mutable static is discouraged | ||
--> $DIR/lint_static_mut_ref.rs:13:14 | ||
| | ||
LL | let _y = &X; | ||
| ^^ use of mutable static | ||
| | ||
= note: use of mutable static is a hard error from 2024 edition | ||
= note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior | ||
|
||
error: aborting due to 2 previous errors | ||
|