-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stabilize unsafe extern blocks (RFC 3484)
- Loading branch information
1 parent
b01a977
commit 8e21e78
Showing
40 changed files
with
86 additions
and
139 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
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
13 changes: 0 additions & 13 deletions
13
tests/ui/feature-gates/feature-gate-unsafe-extern-blocks.rs
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
#![feature(unsafe_extern_blocks)] | ||
#![deny(unsafe_code)] | ||
|
||
#[allow(unsafe_code)] | ||
|
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 |
---|---|---|
@@ -1,8 +1,6 @@ | ||
extern "C" unsafe { | ||
//~^ ERROR expected `{`, found keyword `unsafe` | ||
//~| ERROR extern block cannot be declared unsafe | ||
unsafe fn foo(); | ||
//~^ ERROR items in unadorned `extern` blocks cannot have safety qualifiers | ||
} | ||
|
||
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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
unsafe extern "C" { | ||
//~^ ERROR extern block cannot be declared unsafe | ||
} | ||
//@ check-pass | ||
|
||
unsafe extern "C" {} | ||
|
||
fn main() {} |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,28 +1,20 @@ | ||
//@ 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,32 @@ | ||
error: items outside of `unsafe extern { }` cannot be declared with `safe` safety qualifier | ||
--> $DIR/safe-outside-extern.rs:1:1 | ||
| | ||
LL | safe fn foo() {} | ||
| ^^^^^^^^^^^^^^^^ | ||
|
||
error: items outside of `unsafe extern { }` cannot be declared with `safe` safety qualifier | ||
--> $DIR/safe-outside-extern.rs:4: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:8:5 | ||
| | ||
LL | safe fn foo(); | ||
| ^^^^^^^^^^^^^^ | ||
|
||
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: function pointers cannot be declared with `safe` safety qualifier | ||
--> $DIR/safe-outside-extern.rs:17:14 | ||
| | ||
LL | type FnPtr = safe fn(i32, i32) -> i32; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 5 previous errors | ||
|
4 changes: 2 additions & 2 deletions
4
tests/ui/rust-2024/unsafe-extern-blocks/extern-items-unsafe.edition2021.stderr
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
4 changes: 2 additions & 2 deletions
4
tests/ui/rust-2024/unsafe-extern-blocks/extern-items-unsafe.edition2024.stderr
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
2 changes: 1 addition & 1 deletion
2
tests/ui/rust-2024/unsafe-extern-blocks/extern-items.edition2024.stderr
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
8 changes: 8 additions & 0 deletions
8
tests/ui/rust-2024/unsafe-extern-blocks/safe-impl-trait.stderr
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: expected one of `!` or `::`, found keyword `impl` | ||
--> $DIR/safe-impl-trait.rs:2:6 | ||
| | ||
LL | safe impl Bar for () { } | ||
| ^^^^ expected one of `!` or `::` | ||
|
||
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
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: expected one of `!` or `::`, found keyword `trait` | ||
--> $DIR/safe-trait.rs:1:6 | ||
| | ||
LL | safe trait Foo {} | ||
| ^^^^^ expected one of `!` or `::` | ||
|
||
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
Oops, something went wrong.