forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't allow unsafe statics outside of extern blocks
- Loading branch information
1 parent
e710f0d
commit eb66417
Showing
6 changed files
with
46 additions
and
5 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
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
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
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,8 @@ | ||
error: static items cannot be declared with `unsafe` safety qualifier outside of `extern` block | ||
--> $DIR/safe-outside-extern.rs:6:1 | ||
| | ||
LL | unsafe static LOL: u8 = 0; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 1 previous error | ||
|
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 @@ | ||
//@ revisions: gated ungated | ||
|
||
// Very pared down version of the same named test on nightly, since we only want | ||
// to validate that `unsafe static` is not being accidentally accepted by the parser. | ||
|
||
unsafe static LOL: u8 = 0; | ||
//~^ ERROR: static items cannot be declared with `unsafe` safety qualifier outside of `extern` block | ||
|
||
fn main() {} |
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,8 @@ | ||
error: static items cannot be declared with `unsafe` safety qualifier outside of `extern` block | ||
--> $DIR/safe-outside-extern.rs:6:1 | ||
| | ||
LL | unsafe static LOL: u8 = 0; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 1 previous error | ||
|