Skip to content

[lint: unsafe_in_unsafe_fn] A lint which triggers on unsafe operations in unsafe fn #69270

Open
@Centril

Description

@Centril

As a follow up to fixing #69173 via #69245, we would like to see a lint, starting as allow-by-default which would trigger on the following situation:

#![warn(unsafe_in_unsafe_fn)]

unsafe fn foo() {} // Stand-in for any unsafe operation.
unsafe fn bar() {
    foo();
    //~^ WARN unsafe operation directly in `unsafe fn`
    //~| HELP move the operation into an `unsafe { ... }` block.
}

Eventually, over time, we would like to consider moving this lint to be warn-by-default, but we would like to give the ecosystem time to adapt before doing so. We have not discussed what the timescale of "eventually" entails.

Context (this has already been tentatively accepted by the language team in meetings, though not FCP):

cc @rust-lang/lang @RalfJung

This issue has been assigned to @LeSeulArtichaut via this comment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions