-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #112038 - Nemo157:edition-2024-unsafe_op_in_unsafe_fn, …
…r=RalfJung Change `unsafe_op_in_unsafe_fn` to be `warn`-by-default from edition 2024 This was previously FCPed: #71668 (comment) There were two blocking requirements: * Fix the `unused_unsafe` lint, done in #100081 * Have `cargo fix` able to fix the lint, done in #112017
- Loading branch information
Showing
4 changed files
with
40 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// edition: 2024 | ||
// compile-flags: -Zunstable-options | ||
// check-pass | ||
|
||
#![crate_type = "lib"] | ||
|
||
#![deny(unused_unsafe)] | ||
|
||
unsafe fn unsf() {} | ||
|
||
unsafe fn foo() { | ||
unsf(); | ||
//~^ WARN call to unsafe function is unsafe and requires unsafe block | ||
|
||
// no unused_unsafe | ||
unsafe { unsf(); } | ||
} |
16 changes: 16 additions & 0 deletions
16
tests/ui/unsafe/edition-2024-unsafe_op_in_unsafe_fn.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,16 @@ | ||
warning: call to unsafe function is unsafe and requires unsafe block (error E0133) | ||
--> $DIR/edition-2024-unsafe_op_in_unsafe_fn.rs:12:5 | ||
| | ||
LL | unsf(); | ||
| ^^^^^^ call to unsafe function | ||
| | ||
= 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-unsafe_op_in_unsafe_fn.rs:11:1 | ||
| | ||
LL | unsafe fn foo() { | ||
| ^^^^^^^^^^^^^^^ | ||
= note: `#[warn(unsafe_op_in_unsafe_fn)]` on by default | ||
|
||
warning: 1 warning emitted | ||
|