Rust-clippy: declare_interior_mutable_const should probably be downgraded

Created on 3 Aug 2020  路  3Comments  路  Source: rust-lang/rust-clippy

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.

L-bug L-documentation good-first-issue hacktoberfest

All 3 comments

I'd like to tackle this one if no one else has.

Is there a way to change the lint's level directly or do I have to change its lint group as well? And if its the lint group that has to change, should it be to style, complexity, or perf? This is to facilitate the change from deny to warn by default.

@longlb you need to change the group of the lint. I agree there is no clear candidate, but I guess style is the closer one.

I think we could have a suspicious (or something similar) category for this cases, but that would be another issue and there are plans to change how lints are categorized.

Was this page helpful?
0 / 5 - 0 ratings