Skip to content

ignore-interior-mutability config doesn't apply to declare_interior_mutable_const #10537

Closed
@slinkydeveloper

Description

@slinkydeveloper

Summary

PR #9692 adds the ability to ignore interior mutability lints for mutable_key_type, but not for declare_interior_mutable_const.

Reproducer

I tried this code:

use hyper::http::HeaderValue;

const APPLICATION_PROTO: HeaderValue = HeaderValue::from_static("application/proto");

With this configuration:

ignore-interior-mutability = ["bytes::Bytes", "http::header::HeaderName", "http::header::HeaderValue"]

Fails with:

error: a `const` item should never be interior mutable
  --> lib.rs:17:1
   |
17 | const APPLICATION_PROTO: HeaderValue = HeaderValue::from_static("application/proto");
   | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   | |
   | make this a static item (maybe with lazy_static)
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#declare_interior_mutable_const
   = note: `-D clippy::declare-interior-mutable-const` implied by `-D warnings`

Version

rustc 1.67.1 (d5a82bbd2 2023-02-07)
binary: rustc
commit-hash: d5a82bbd26e1ad8b7401f6a718a9c57c96905483
commit-date: 2023-02-07
host: x86_64-unknown-linux-gnu
release: 1.67.1
LLVM version: 15.0.6

Additional Labels

No response

Metadata

Metadata

Labels

C-bugCategory: Clippy is not doing the correct thing

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions