-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bad replacement for unsafe extern block suggestion
- Loading branch information
1 parent
c3d7fb3
commit b0f876d
Showing
10 changed files
with
75 additions
and
26 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
16 changes: 10 additions & 6 deletions
16
...i/rust-2024/unsafe-extern-blocks/safe-unsafe-on-unadorned-extern-block.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,24 @@ | ||
error: items in unadorned `extern` blocks cannot have safety qualifiers | ||
--> $DIR/safe-unsafe-on-unadorned-extern-block.rs:10:5 | ||
| | ||
LL | extern "C" { | ||
| ---------- help: add unsafe to this `extern` block | ||
LL | | ||
LL | safe static TEST1: i32; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
help: add unsafe to this `extern` block | ||
| | ||
LL | unsafe extern "C" { | ||
| ++++++ | ||
|
||
error: items in unadorned `extern` blocks cannot have safety qualifiers | ||
--> $DIR/safe-unsafe-on-unadorned-extern-block.rs:12:5 | ||
| | ||
LL | extern "C" { | ||
| ---------- help: add unsafe to this `extern` block | ||
... | ||
LL | safe fn test1(i: i32); | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
help: add unsafe to this `extern` block | ||
| | ||
LL | unsafe extern "C" { | ||
| ++++++ | ||
|
||
error: aborting due to 2 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
10 changes: 10 additions & 0 deletions
10
tests/ui/rust-2024/unsafe-extern-blocks/unsafe-on-extern-block-issue-126756.fixed
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,10 @@ | ||
//@ run-rustfix | ||
|
||
#![feature(unsafe_extern_blocks)] | ||
#![allow(dead_code)] | ||
|
||
unsafe extern "C" { | ||
unsafe fn foo(); //~ ERROR items in unadorned `extern` blocks cannot have safety qualifiers | ||
} | ||
|
||
fn main() {} |
10 changes: 10 additions & 0 deletions
10
tests/ui/rust-2024/unsafe-extern-blocks/unsafe-on-extern-block-issue-126756.rs
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,10 @@ | ||
//@ run-rustfix | ||
|
||
#![feature(unsafe_extern_blocks)] | ||
#![allow(dead_code)] | ||
|
||
extern "C" { | ||
unsafe fn foo(); //~ ERROR items in unadorned `extern` blocks cannot have safety qualifiers | ||
} | ||
|
||
fn main() {} |
13 changes: 13 additions & 0 deletions
13
tests/ui/rust-2024/unsafe-extern-blocks/unsafe-on-extern-block-issue-126756.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,13 @@ | ||
error: items in unadorned `extern` blocks cannot have safety qualifiers | ||
--> $DIR/unsafe-on-extern-block-issue-126756.rs:7:5 | ||
| | ||
LL | unsafe fn foo(); | ||
| ^^^^^^^^^^^^^^^^ | ||
| | ||
help: add unsafe to this `extern` block | ||
| | ||
LL | unsafe extern "C" { | ||
| ++++++ | ||
|
||
error: aborting due to 1 previous error | ||
|