Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
slinkydeveloper opened this issue Mar 24, 2023 · 3 comments · Fixed by #11678
Closed
Assignees
Labels
C-bug Category: Clippy is not doing the correct thing

Comments

@slinkydeveloper
Copy link
Contributor

slinkydeveloper commented Mar 24, 2023

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

@slinkydeveloper slinkydeveloper added the C-bug Category: Clippy is not doing the correct thing label Mar 24, 2023
@slinkydeveloper
Copy link
Contributor Author

If people is interested in this fix, I can contribute it :)

@slinkydeveloper
Copy link
Contributor Author

@slinkydeveloper
Copy link
Contributor Author

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing
Projects
None yet
1 participant