Skip to content

declare_interior_mutable_const should probably be downgraded #5863

@ijackson

Description

@ijackson

Hi. I ran into #3962 (interior mutability complaint even if non-interior-mutable enum variants are used). Searching for the name of the lint found me #5050, and also #5812 (which relates to types which have "buried" interior mutability and which therefore don't present the semantic hazard that this lint is aimed at).

In #5812 clippy suggests using lazy_static which is right if the user actually wanted the interior mutability, but is not a good approach if all that's needed is to suppress this lint.

This lint is deny by default. I think it is not sufficiently reliable for that. The issue conversations show people who are concerned that they would be missing a serious problem and are mistakenly reluctant to suppress this lint.

I suggest that the lint should be downgraded to warn-by-default.

Also I think these issues should be discussed in https://rust-lang.github.io/rust-clippy/master/index.html#declare_interior_mutable_const under "Known problems".

I'm not very familiar with clippy but this doesn't sound like it would be a difficult change. So if this seems like a good idea to the clippy team please let me know and I will prepare an MR.

Thanks,
Ian.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-documentationArea: Adding or improving documentationC-bugCategory: Clippy is not doing the correct thinggood first issueThese issues are a good way to get started with Clippy

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions