-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
d40f30e
commit 22831ed
Showing
8 changed files
with
216 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:8: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:13:5 | ||
| | ||
LL | safe fn foo(); | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error: items outside of `unsafe extern { }` cannot be declared with `safe` safety qualifier | ||
--> $DIR/safe-outside-extern.rs:19:5 | ||
| | ||
LL | safe fn foo() {} | ||
| ^^^^^^^^^^^^^^^^ | ||
|
||
error: function pointers cannot be declared with `safe` safety qualifier | ||
--> $DIR/safe-outside-extern.rs:24: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,28 @@ | ||
//@ 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 | ||
//[ungated]~| ERROR: unsafe extern {}` blocks and `safe` keyword are experimental [E0658] | ||
|
||
safe static FOO: i32 = 1; | ||
//~^ ERROR: items outside of `unsafe extern { }` cannot be declared with `safe` safety qualifier | ||
//[ungated]~| ERROR: unsafe extern {}` blocks and `safe` keyword are experimental [E0658] | ||
|
||
trait Foo { | ||
safe fn foo(); | ||
//~^ ERROR: items outside of `unsafe extern { }` cannot be declared with `safe` safety qualifier | ||
//[ungated]~| ERROR: unsafe extern {}` blocks and `safe` keyword are experimental [E0658] | ||
} | ||
|
||
impl Foo for () { | ||
safe fn foo() {} | ||
//~^ ERROR: items outside of `unsafe extern { }` cannot be declared with `safe` safety qualifier | ||
//[ungated]~| ERROR: unsafe extern {}` blocks and `safe` keyword are experimental [E0658] | ||
} | ||
|
||
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] | ||
|
||
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,83 @@ | ||
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:8: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:13:5 | ||
| | ||
LL | safe fn foo(); | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error: items outside of `unsafe extern { }` cannot be declared with `safe` safety qualifier | ||
--> $DIR/safe-outside-extern.rs:19:5 | ||
| | ||
LL | safe fn foo() {} | ||
| ^^^^^^^^^^^^^^^^ | ||
|
||
error: function pointers cannot be declared with `safe` safety qualifier | ||
--> $DIR/safe-outside-extern.rs:24:14 | ||
| | ||
LL | type FnPtr = safe fn(i32, i32) -> i32; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error[E0658]: `unsafe extern {}` blocks and `safe` keyword are experimental | ||
--> $DIR/safe-outside-extern.rs:4:1 | ||
| | ||
LL | safe fn foo() {} | ||
| ^^^^ | ||
| | ||
= note: see issue #123743 <https://github.com/rust-lang/rust/issues/123743> for more information | ||
= 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[E0658]: `unsafe extern {}` blocks and `safe` keyword are experimental | ||
--> $DIR/safe-outside-extern.rs:8:1 | ||
| | ||
LL | safe static FOO: i32 = 1; | ||
| ^^^^ | ||
| | ||
= note: see issue #123743 <https://github.com/rust-lang/rust/issues/123743> for more information | ||
= 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[E0658]: `unsafe extern {}` blocks and `safe` keyword are experimental | ||
--> $DIR/safe-outside-extern.rs:13:5 | ||
| | ||
LL | safe fn foo(); | ||
| ^^^^ | ||
| | ||
= note: see issue #123743 <https://github.com/rust-lang/rust/issues/123743> for more information | ||
= 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[E0658]: `unsafe extern {}` blocks and `safe` keyword are experimental | ||
--> $DIR/safe-outside-extern.rs:19:5 | ||
| | ||
LL | safe fn foo() {} | ||
| ^^^^ | ||
| | ||
= note: see issue #123743 <https://github.com/rust-lang/rust/issues/123743> for more information | ||
= 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[E0658]: `unsafe extern {}` blocks and `safe` keyword are experimental | ||
--> $DIR/safe-outside-extern.rs:24:14 | ||
| | ||
LL | type FnPtr = safe fn(i32, i32) -> i32; | ||
| ^^^^ | ||
| | ||
= note: see issue #123743 <https://github.com/rust-lang/rust/issues/123743> for more information | ||
= 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 | ||
|
||
For more information about this error, try `rustc --explain E0658`. |