Skip to content

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

Closed
@Noratrieb

Description

@Noratrieb

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't have

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions