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.
Rollup merge of rust-lang#126758 - spastorino:avoid-safe-outside-unsa…
…fe-blocks, r=compiler-errors Do not allow safe/unsafe on static and fn items Fixes rust-lang#126749 r? `@compiler-errors` Tracking: - rust-lang#123743
- Loading branch information
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 | ||
|