-
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.
Add hard error and migration lint for unsafe attrs
- Loading branch information
1 parent
8fb1930
commit 643bc06
Showing
21 changed files
with
456 additions
and
44 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
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
8 changes: 8 additions & 0 deletions
8
tests/ui/rust-2024/unsafe-attributes/in_2024_compatibility.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,8 @@ | ||
#![deny(rust_2024_compatibility)] | ||
|
||
#[no_mangle] | ||
//~^ ERROR: unsafe attribute used without unsafe | ||
//~| WARN this is accepted in the current edition | ||
extern "C" fn foo() {} | ||
|
||
fn main() {} |
21 changes: 21 additions & 0 deletions
21
tests/ui/rust-2024/unsafe-attributes/in_2024_compatibility.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,21 @@ | ||
error: unsafe attribute used without unsafe | ||
--> $DIR/in_2024_compatibility.rs:3:3 | ||
| | ||
LL | #[no_mangle] | ||
| ^^^^^^^^^ usage of unsafe attribute | ||
| | ||
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024! | ||
= note: for more information, see issue #123757 <https://github.com/rust-lang/rust/issues/123757> | ||
note: the lint level is defined here | ||
--> $DIR/in_2024_compatibility.rs:1:9 | ||
| | ||
LL | #![deny(rust_2024_compatibility)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ | ||
= note: `#[deny(unsafe_attr_outside_unsafe)]` implied by `#[deny(rust_2024_compatibility)]` | ||
help: wrap the attribute in `unsafe(...)` | ||
| | ||
LL | #[unsafe(no_mangle)] | ||
| +++++++ + | ||
|
||
error: aborting due to 1 previous error | ||
|
12 changes: 12 additions & 0 deletions
12
tests/ui/rust-2024/unsafe-attributes/unsafe-attribute-marked.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,12 @@ | ||
//@ revisions: edition2021 edition2024 | ||
//@[edition2021] edition:2021 | ||
//@[edition2024] edition:2024 | ||
//@[edition2024] compile-flags: -Zunstable-options | ||
//@ check-pass | ||
|
||
#![feature(unsafe_attributes)] | ||
|
||
#[unsafe(no_mangle)] | ||
extern "C" fn foo() {} | ||
|
||
fn main() {} |
Oops, something went wrong.