forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not allow safe usafe on static and fn items
- Loading branch information
1 parent
cb8a7ea
commit 3d6d9e2
Showing
8 changed files
with
160 additions
and
31 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
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,32 @@ | ||
error: items outside of `unsafe extern { }` cannot be declared with `safe` safety qualifier | ||
--> $DIR/safe-outside-extern.rs:4:1 | ||
| | ||
LL | safe fn foo() {} | ||
| ^^^^^^^^^^^^^^^^ | ||
|
||
error: items outside of `unsafe extern { }` cannot be declared with `safe` safety qualifier | ||
--> $DIR/safe-outside-extern.rs:7:1 | ||
| | ||
LL | safe static FOO: i32 = 1; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: items outside of `unsafe extern { }` cannot be declared with `safe` safety qualifier | ||
--> $DIR/safe-outside-extern.rs:11:5 | ||
| | ||
LL | safe fn foo(); | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error: items outside of `unsafe extern { }` cannot be declared with `safe` safety qualifier | ||
--> $DIR/safe-outside-extern.rs:16:5 | ||
| | ||
LL | safe fn foo() {} | ||
| ^^^^^^^^^^^^^^^^ | ||
|
||
error: function pointers cannot be declared with `safe` safety qualifier | ||
--> $DIR/safe-outside-extern.rs:20:14 | ||
| | ||
LL | type FnPtr = safe fn(i32, i32) -> i32; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 5 previous errors | ||
|
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,23 @@ | ||
//@ revisions: gated ungated | ||
#![cfg_attr(gated, feature(unsafe_extern_blocks))] | ||
|
||
safe fn foo() {} | ||
//~^ ERROR: items outside of `unsafe extern { }` cannot be declared with `safe` safety qualifier | ||
|
||
safe static FOO: i32 = 1; | ||
//~^ ERROR: items outside of `unsafe extern { }` cannot be declared with `safe` safety qualifier | ||
|
||
trait Foo { | ||
safe fn foo(); | ||
//~^ ERROR: items outside of `unsafe extern { }` cannot be declared with `safe` safety qualifier | ||
} | ||
|
||
impl Foo for () { | ||
safe fn foo() {} | ||
//~^ ERROR: items outside of `unsafe extern { }` cannot be declared with `safe` safety qualifier | ||
} | ||
|
||
type FnPtr = safe fn(i32, i32) -> i32; | ||
//~^ ERROR: function pointers cannot be declared with `safe` safety qualifier | ||
|
||
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,32 @@ | ||
error: items outside of `unsafe extern { }` cannot be declared with `safe` safety qualifier | ||
--> $DIR/safe-outside-extern.rs:4:1 | ||
| | ||
LL | safe fn foo() {} | ||
| ^^^^^^^^^^^^^^^^ | ||
|
||
error: items outside of `unsafe extern { }` cannot be declared with `safe` safety qualifier | ||
--> $DIR/safe-outside-extern.rs:7:1 | ||
| | ||
LL | safe static FOO: i32 = 1; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: items outside of `unsafe extern { }` cannot be declared with `safe` safety qualifier | ||
--> $DIR/safe-outside-extern.rs:11:5 | ||
| | ||
LL | safe fn foo(); | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error: items outside of `unsafe extern { }` cannot be declared with `safe` safety qualifier | ||
--> $DIR/safe-outside-extern.rs:16:5 | ||
| | ||
LL | safe fn foo() {} | ||
| ^^^^^^^^^^^^^^^^ | ||
|
||
error: function pointers cannot be declared with `safe` safety qualifier | ||
--> $DIR/safe-outside-extern.rs:20:14 | ||
| | ||
LL | type FnPtr = safe fn(i32, i32) -> i32; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 5 previous errors | ||
|