Skip to content
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

mutable_key_type doesn't mention the type which makes it confusing #10619

Closed
Noratrieb opened this issue Apr 9, 2023 · 2 comments · Fixed by #13496
Closed

mutable_key_type doesn't mention the type which makes it confusing #10619

Noratrieb opened this issue Apr 9, 2023 · 2 comments · Fixed by #13496
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@Noratrieb
Copy link
Member

Noratrieb commented Apr 9, 2023

Summary

I'm not sure whether this is a false positive, there are lots of maps involved here and clippy doesn't tell me what it's complaining about. At least I have no clues where it could be coming from.

warning: mutable key type
   --> compiler/rustc_codegen_ssa/src/back/symbol_export.rs:406:13
    |
406 |             let substs_map = instances.entry(def_id).or_default();
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#mutable_key_type
    = note: `-D clippy::mutable-key-type` implied by `-D clippy::suspicious`

instances is of type UnordMap<DefId, HashMap<&List<GenericArg>, CrateNum, BuildHasherDefault<FxHasher>>>

where

pub struct UnordMap<K: Eq + Hash, V> {
    inner: FxHashMap<K, V>, /* FxHashMap is just a type alias for Hashmap */
}

pub struct DefId {
    /* contains two newtyped integers */
}

pub struct List<T> {
    len: usize,
    data: [T; 0],
    opaque: OpaqueListContents,
}

extern "C" {
    type OpaqueListContents;
}

pub struct GenericArg<'tcx> {
    ptr: NonZeroUsize,
    marker: PhantomData<(Ty<'tcx>, ty::Region<'tcx>, ty::Const<'tcx>)>,
}

/* Ty, Region and Const are references to more nested things, see the rustc docs */

Lint Name

mutable_key_type

Reproducer

I sadly don't have a simple reproducer, but I ran clippy in rust-lang/rust 1c39afb

Version

rustc 1.70.0-nightly (af06dce64 2023-04-08)
binary: rustc
commit-hash: af06dce64bf87ea9206bdf6cff61c144b9ce8458
commit-date: 2023-04-08
host: x86_64-unknown-linux-gnu
release: 1.70.0-nightly
LLVM version: 16.0.2

Additional Labels

No response

@Noratrieb Noratrieb added C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have labels Apr 9, 2023
@jyn514
Copy link
Member

jyn514 commented Apr 9, 2023

I sadly don't have a simple reproducer, but I can clippy in rust-lang/rust 1c39afb

x clippy compiler -A clippy::all -D clippy::perf

@kpreid
Copy link
Contributor

kpreid commented Jun 18, 2024

I just hit this issue when testing with nightly clippy, presumably due to #12691 expanding the set of things that are counted as interior mutable. In my own case, I was able to configure ignore-interior-mutability based on my knowledge of the types in my project, but it could have been very difficult to track down what type clippy was actually objecting to (or more precisely, what type is the most appropriate to allow).

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 I-false-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants