-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add suggestion to THIR unsafe_op_in_unsafe_fn lint
- Loading branch information
1 parent
2b2c0f9
commit 2b59992
Showing
13 changed files
with
367 additions
and
40 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
4 changes: 2 additions & 2 deletions
4
...dition-2024-unsafe_op_in_unsafe_fn.stderr → ...on-2024-unsafe_op_in_unsafe_fn.mir.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,21 @@ | ||
// edition: 2024 | ||
// compile-flags: -Zunstable-options | ||
// check-pass | ||
// revisions: mir thir | ||
// [thir]compile-flags: -Zthir-unsafeck | ||
|
||
#![crate_type = "lib"] | ||
|
||
#![deny(unused_unsafe)] | ||
|
||
unsafe fn unsf() {} | ||
|
||
unsafe fn foo() { | ||
unsf(); | ||
//~^ WARN call to unsafe function is unsafe and requires unsafe block | ||
//[mir]~^ WARN call to unsafe function is unsafe and requires unsafe block | ||
//[thir]~^^ WARN call to unsafe function `unsf` is unsafe and requires unsafe block | ||
|
||
// no unused_unsafe | ||
unsafe { unsf(); } | ||
unsafe { | ||
unsf(); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
tests/ui/unsafe/edition-2024-unsafe_op_in_unsafe_fn.thir.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 `unsf` is unsafe and requires unsafe block (error E0133) | ||
--> $DIR/edition-2024-unsafe_op_in_unsafe_fn.rs:13: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:12:1 | ||
| | ||
LL | unsafe fn foo() { | ||
| ^^^^^^^^^^^^^^^ | ||
= note: `#[warn(unsafe_op_in_unsafe_fn)]` on by default | ||
|
||
warning: 1 warning emitted | ||
|
Oops, something went wrong.