Open
Description
This is a tracking issue for the RFC "unsafe blocks in unsafe fn" (rust-lang/rfcs#2585).
The lint unsafe_block_in_unsafe_fn
is stable, but the RFC proposes some further things we might want to do.
About tracking issues
Tracking issues are used to record the overall progress of implementation.
They are also uses as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Steps
- Introduce an opt-in lint that, when enabled, causes unsafe blocks in unsafe functions to be considered required, and warns if they are absent when an unsafe operation is performed.
- Stabilization PR in Rust 1.52.0 (Stabilize
unsafe_op_in_unsafe_fn
lint #79208) - Include a suggestion with the lint that can insert required unsafe blocks. This could be as simple as adding a block across the entire function, though more granular insertion is probably better. (Add MVP suggestion for
unsafe_op_in_unsafe_fn
#112017) - Adjust documentation to describe the (somewhat unusual) effect of the lint, and to describe the possibility that the lint will be enabled default (see instructions on rustc-dev-guide)
- Write a blog post describing the change, perhaps?
Unresolved Questions
- What is the timeline for adding the lint, and cranking up its default level?
- Should the default level depend on the edition?
- Should we ever make this deny-by-default or even a hard error, in a future edition?
- Should we require
cargo fix
to be able to do something about this warning before making it even warn-by-default? And how precise should it be?
Implementation history
- Implemented in Implement RFC 2585: unsafe blocks in unsafe fn #71862
- Stabilized in Stabilize
unsafe_op_in_unsafe_fn
lint #79208 - Fixable suggestion added in Add MVP suggestion for
unsafe_op_in_unsafe_fn
#112017 - Made warn-by-default for 2024 edition in Change
unsafe_op_in_unsafe_fn
to bewarn
-by-default from edition 2024 #112038
Metadata
Assignees
Labels
Blocker: Approved by a merged RFC but not yet implemented.Category: An issue tracking the progress of sth. like the implementation of an RFCRFC #2585Status: The implementation is incomplete.Relevant to the language team, which will review and decide on the PR/issue.This issue / PR is in PFCP or FCP with a disposition to merge it.The final comment period is finished for this PR / Issue.
Type
Projects
Status
Needs help: Impl