Open
Description
Code
// inner/Cargo.toml
[package]
name = "inner"
edition = "2021"
[dependencies]
hashbrown = "0.12.3"
// inner/src/lib.rs
pub fn foo(_: hashbrown::HashMap<u32, u32>) {}
// outer/src/main.rs
#![feature(rustc_private)]
extern crate hashbrown;
fn main() {
let map = hashbrown::HashMap::default();
inner::foo(map);
}
Current output
error[E0308]: mismatched types
--> src/main.rs:6:16
|
6 | inner::foo(map);
| ---------- ^^^ expected `HashMap<u32, u32>`, found `HashMap<_, _, _, _>`
| |
| arguments to this function are incorrect
|
= note: `HashMap<_, _, _, _>` and `HashMap<u32, u32>` have similar names, but are actually distinct types
note: `HashMap<_, _, _, _>` is defined in crate `hashbrown`
--> /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/hashbrown-0.12.3/src/map.rs:188:1
note: `HashMap<u32, u32>` is defined in crate `hashbrown`
--> /Users/jyn/.local/lib/cargo/registry/src/index.crates.io-6f17d22bba15001f/hashbrown-0.12.3/src/map.rs:188:1
|
188 | pub struct HashMap<K, V, S = DefaultHashBuilder, A: Allocator + Clone = Global> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: perhaps two different versions of crate `hashbrown` are being used?
note: function defined here
--> /Users/jyn/src/example/inner/src/lib.rs:1:8
|
1 | pub fn foo(_: hashbrown::HashMap<u32, u32>) {}
| ^^^
Desired output
note: `HashMap<_, _, _, _>` is defined in crate `hashbrown`
--> /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/hashbrown-0.12.3/src/map.rs:188:1
= note: loaded from /Users/jyn/.local/lib/rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libhashbrown-016a8bf1dc67c69f.rlib
= note: which is in the compiler's "sysroot": https://rustc-dev-guide.rust-lang.org/building/bootstrapping.html#what-is-a-sysroot
note: `HashMap<u32, u32>` is defined in crate `hashbrown` (loaded from `/Users/jyn/.local/lib/cargo/target/debug/deps/`)
--> /Users/jyn/.local/lib/cargo/registry/src/index.crates.io-6f17d22bba15001f/hashbrown-0.12.3/src/map.rs:188:1
|
188 | pub struct HashMap<K, V, S = DefaultHashBuilder, A: Allocator + Clone = Global> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: loaded from /Users/jyn/.local/lib/cargo/target/debug/deps/libhashbrown-408ce4dce55d643d.rmeta
= note: perhaps two different versions of crate `hashbrown` are being used?
Rationale and extra context
It's not clear that "/Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/hashbrown-0.12.3/src/map.rs:188:1" is referring to a crate loaded from the sysroot; that path doesn't correspond to anything on disk. It would be nice to explain what's going on; when dealing with sysroots the exact paths of the artifacts often really are important.
Other cases
No response
Anything else?
This is minimized from a real error @aDotInTheVoid saw in rustdoc:
Compiling rustdoc v0.0.0 (/home/alona/dev/rust/rust/src/librustdoc)
error[E0308]: mismatched types
--> src/librustdoc/json/mod.rs:235:13
|
235 | index,
| ^^^^^ expected `rustc_hash::FxHasher`, found `FxHasher`
|
= note: `FxHasher` and `rustc_hash::FxHasher` have similar names, but are actually distinct types
note: `FxHasher` is defined in crate `rustc_hash`
--> /cargo/registry/src/index.crates.io-6f17d22bba15001f/rustc-hash-1.1.0/src/lib.rs:60:1
note: `rustc_hash::FxHasher` is defined in crate `rustc_hash`
--> /home/alona/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rustc-hash-1.1.0/src/lib.rs:60:1
|
60 | pub struct FxHasher {
| ^^^^^^^^^^^^^^^^^^^
= note: perhaps two different versions of crate `rustc_hash` are being used?
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: Crate metadataDiagnostics: Errors or lints caused be the use of two different crate versions.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.Relevant to the compiler team, which will review and decide on the PR/issue.