Closed
Description
dep/src/lib.rs
pub struct S;
mod m { pub struct S; }
pub use crate::m::S as S2;
repro/src/lib.rs
extern crate dep;
fn f() {
let _: dep::S = dep::S2;
}
The error message refers to both types as dep::S
even though one is dep::S2
. I am reporting this as distinct from #21934 because dep::S
isn't even the internal name of the other struct. That would be dep::m::S
. Printing dep::S2
would be ideal (as tracked in #21934) but printing dep::m::S
would still be a big improvement.
error[E0308]: mismatched types
--> src/lib.rs:4:21
|
4 | let _: dep::S = dep::S2;
| ^^^^^^^ expected struct `dep::S`, found a different struct `dep::S`
|
= note: expected type `dep::S` (struct `dep::S`)
found type `dep::S` (struct `dep::S`)
Same thing in script form:
#!/bin/bash
cargo new --lib dep
cargo new --lib repro
echo >dep/src/lib.rs '
pub struct S;
mod m { pub struct S; }
pub use crate::m::S as S2;
'
echo >repro/src/lib.rs '
extern crate dep;
fn f() {
let _: dep::S = dep::S2;
}
'
echo >>repro/Cargo.toml 'dep = { path = "../dep" }'
# rustc 1.33.0-nightly (adbfec229 2018-12-17)
cargo +nightly check --manifest-path repro/Cargo.toml
Mentioning @dgreid who hit this today. The real case involves multiple Error
types across different modules, each re-exported from lib.rs under a unique name.