forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#127944 - compiler-errors:beta-no-unsafe, r=Ma…
…rk-Simulacrum Don't allow unsafe statics outside of extern blocks (beta version) This PR fixes a regression where we allowed `unsafe static` items in top-level modules (i.e. outside of `unsafe extern` blocks). rust-lang#127943 does not rebase cleanly, so I've prepared an extremely pared down version of this PR for beta purposes.
- Loading branch information
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 | ||
|