forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
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
20f23ab
commit 8366c7f
Showing
41 changed files
with
85 additions
and
163 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.
23 changes: 0 additions & 23 deletions
23
tests/ui/feature-gates/feature-gate-unsafe-extern-blocks.stderr
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
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,38 @@ | ||
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: static items cannot be declared with `unsafe` safety qualifier outside of `extern` block | ||
--> $DIR/safe-outside-extern.rs:20:1 | ||
| | ||
LL | unsafe static LOL: u8 = 0; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 6 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
2 changes: 1 addition & 1 deletion
2
...xtern-blocks/safe-impl-trait.gated.stderr → ...safe-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
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 | ||
|
Oops, something went wrong.