Don't allow unsafe statics outside of extern blocks
This commit is contained in:
parent
5affbb1715
commit
2f5a84ea16
6 changed files with 35 additions and 2 deletions
|
|
@ -28,5 +28,11 @@ error: function pointers cannot be declared with `safe` safety qualifier
|
|||
LL | type FnPtr = safe fn(i32, i32) -> i32;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
error: static items cannot be declared with `unsafe` safety qualifier outside of `extern` block
|
||||
--> $DIR/safe-outside-extern.rs:28:1
|
||||
|
|
||||
LL | unsafe static LOL: u8 = 0;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -25,4 +25,7 @@ type FnPtr = safe fn(i32, i32) -> i32;
|
|||
//~^ ERROR: function pointers cannot be declared with `safe` safety qualifier
|
||||
//[ungated]~| ERROR: unsafe extern {}` blocks and `safe` keyword are experimental [E0658]
|
||||
|
||||
unsafe static LOL: u8 = 0;
|
||||
//~^ ERROR: static items cannot be declared with `unsafe` safety qualifier outside of `extern` block
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,12 @@ error: function pointers cannot be declared with `safe` safety qualifier
|
|||
LL | type FnPtr = safe fn(i32, i32) -> i32;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: static items cannot be declared with `unsafe` safety qualifier outside of `extern` block
|
||||
--> $DIR/safe-outside-extern.rs:28:1
|
||||
|
|
||||
LL | unsafe static LOL: u8 = 0;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0658]: `unsafe extern {}` blocks and `safe` keyword are experimental
|
||||
--> $DIR/safe-outside-extern.rs:4:1
|
||||
|
|
||||
|
|
@ -78,6 +84,6 @@ LL | type FnPtr = safe fn(i32, i32) -> i32;
|
|||
= help: add `#![feature(unsafe_extern_blocks)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error: aborting due to 10 previous errors
|
||||
error: aborting due to 11 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue