unsafe_op_in_unsafe_fn causes unnecessary unsafe warnings #132856
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-edition-2024
Area: The 2024 edition
A-lint
Area: Lints (warnings about flaws in source code) such as unused_mut.
A-suggestion-diagnostics
Area: Suggestions generated by the compiler applied by `cargo fix`
D-edition
Diagnostics: An error or lint that should account for edition differences.
D-papercut
Diagnostics: An error or lint that needs small tweaks.
L-false-positive
Lint: False positive (should not have fired).
L-unsafe_op_in_unsafe_fn
Lint: unsafe_op_in_unsafe_fn
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
I tried this code:
This causes a diagnostic suggestion to rewrite it to:
However, this in turn causes more warnings which cannot be auto-fixed:
I don't know if it would be possible to change
unused_unsafe
to have a machine-applicable suggestion to remove theunsafe
keyword. Or maybeunsafe_op_in_unsafe_fn
could incorporate those suggestions. I think it probably should not remove the brackets, since that would have a semantic change, and I think would be difficult to get right (though could actually help with some of the problems of the tail-drop-order changes).Priority-wise, this is just an annoyance since the warnings do not inhibit migration. They just need to be cleaned up manually which for a large codebase could be a lot of work.
Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: