forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#119948 - asquared31415:unsafe_op_in_unsafe_fn_fix, r=TaKO8Ki Make `unsafe_op_in_unsafe_fn` migrated in edition 2024 fixes rust-lang#119823
- Loading branch information
Showing
14 changed files
with
160 additions
and
51 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
File renamed without changes.
20 changes: 20 additions & 0 deletions
20
tests/ui/unsafe/unsafe_op_in_unsafe_fn/edition_2024_default.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,20 @@ | ||
// edition: 2024 | ||
// compile-flags: -Zunstable-options | ||
// check-pass | ||
|
||
// Tests that `unsafe_op_in_unsafe_fn` is warn-by-default in edition 2024 and that the | ||
// `unused_unsafe` lint does not consider the inner unsafe block to be unused. | ||
#![crate_type = "lib"] | ||
#![deny(unused_unsafe)] | ||
|
||
unsafe fn unsf() {} | ||
|
||
unsafe fn foo() { | ||
unsf(); | ||
//~^ WARN | ||
|
||
// no unused_unsafe | ||
unsafe { | ||
unsf(); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
tests/ui/unsafe/unsafe_op_in_unsafe_fn/edition_2024_default.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,17 @@ | ||
warning: call to unsafe function `unsf` is unsafe and requires unsafe block (error E0133) | ||
--> $DIR/edition_2024_default.rs:13:5 | ||
| | ||
LL | unsf(); | ||
| ^^^^^^ call to unsafe function | ||
| | ||
= note: for more information, see issue #71668 <https://github.com/rust-lang/rust/issues/71668> | ||
= note: consult the function's documentation for information on how to avoid undefined behavior | ||
note: an unsafe function restricts its caller, but its body is safe by default | ||
--> $DIR/edition_2024_default.rs:12:1 | ||
| | ||
LL | unsafe fn foo() { | ||
| ^^^^^^^^^^^^^^^ | ||
= note: `#[warn(unsafe_op_in_unsafe_fn)]` on by default | ||
|
||
warning: 1 warning emitted | ||
|
9 changes: 9 additions & 0 deletions
9
tests/ui/unsafe/unsafe_op_in_unsafe_fn/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,9 @@ | ||
#![deny(rust_2024_compatibility)] | ||
#![crate_type = "lib"] | ||
|
||
unsafe fn unsf() {} | ||
|
||
unsafe fn foo() { | ||
unsf(); | ||
//~^ ERROR call to unsafe function `unsf` is unsafe and requires unsafe block | ||
} |
22 changes: 22 additions & 0 deletions
22
tests/ui/unsafe/unsafe_op_in_unsafe_fn/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,22 @@ | ||
error: call to unsafe function `unsf` is unsafe and requires unsafe block (error E0133) | ||
--> $DIR/in_2024_compatibility.rs:7:5 | ||
| | ||
LL | unsf(); | ||
| ^^^^^^ call to unsafe function | ||
| | ||
= note: for more information, see issue #71668 <https://github.com/rust-lang/rust/issues/71668> | ||
= note: consult the function's documentation for information on how to avoid undefined behavior | ||
note: an unsafe function restricts its caller, but its body is safe by default | ||
--> $DIR/in_2024_compatibility.rs:6:1 | ||
| | ||
LL | unsafe fn foo() { | ||
| ^^^^^^^^^^^^^^^ | ||
note: the lint level is defined here | ||
--> $DIR/in_2024_compatibility.rs:1:9 | ||
| | ||
LL | #![deny(rust_2024_compatibility)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ | ||
= note: `#[deny(unsafe_op_in_unsafe_fn)]` implied by `#[deny(rust_2024_compatibility)]` | ||
|
||
error: aborting due to 1 previous error | ||
|
File renamed without changes.
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
Oops, something went wrong.