-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Add MVP suggestion for unsafe_op_in_unsafe_fn
#99827
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// run-rustfix | ||
|
||
#![deny(unsafe_op_in_unsafe_fn)] | ||
|
||
unsafe fn unsf() {} | ||
|
||
pub unsafe fn foo() { unsafe { | ||
unsf(); //~ ERROR call to unsafe function is unsafe | ||
unsf(); //~ ERROR call to unsafe function is unsafe | ||
}} | ||
|
||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// run-rustfix | ||
|
||
#![deny(unsafe_op_in_unsafe_fn)] | ||
|
||
unsafe fn unsf() {} | ||
|
||
pub unsafe fn foo() { | ||
unsf(); //~ ERROR call to unsafe function is unsafe | ||
unsf(); //~ ERROR call to unsafe function is unsafe | ||
} | ||
|
||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
error: call to unsafe function is unsafe and requires unsafe block (error E0133) | ||
--> $DIR/wrapping-unsafe-block-sugg.rs:8:5 | ||
| | ||
LL | unsf(); | ||
| ^^^^^^ call to unsafe function | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/wrapping-unsafe-block-sugg.rs:3:9 | ||
| | ||
LL | #![deny(unsafe_op_in_unsafe_fn)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
= note: consult the function's documentation for information on how to avoid undefined behavior | ||
help: consider wrapping the function in an unsafe block | ||
|
||
| | ||
LL ~ pub unsafe fn foo() { unsafe { | ||
LL | unsf(); | ||
LL | unsf(); | ||
LL ~ }} | ||
| | ||
|
||
error: call to unsafe function is unsafe and requires unsafe block (error E0133) | ||
--> $DIR/wrapping-unsafe-block-sugg.rs:9:5 | ||
| | ||
LL | unsf(); | ||
| ^^^^^^ call to unsafe function | ||
| | ||
= note: consult the function's documentation for information on how to avoid undefined behavior | ||
|
||
error: aborting due to 2 previous errors | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps HasPlaceholders?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docs for
Applicability
stateBut I think the goal is to be able to apply a "quick fix" to make the code compile. Can
HasPlaceholders
suggestion still be applied "auto-manually"? I have never used rustfix (:sweat_smile:) and I'm not sure how the differentApplicability
settings behave for the end user.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe not, good point.