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

Path in error message is neither public name nor internal name of type #56943

Closed
dtolnay opened this issue Dec 18, 2018 · 0 comments · Fixed by #57802
Closed

Path in error message is neither public name nor internal name of type #56943

dtolnay opened this issue Dec 18, 2018 · 0 comments · Fixed by #57802
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-resolve Area: Name resolution T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@dtolnay
Copy link
Member

dtolnay commented Dec 18, 2018

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.

@dtolnay dtolnay added A-diagnostics Area: Messages for errors, warnings, and lints A-resolve Area: Name resolution T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 18, 2018
@davidtwco davidtwco self-assigned this Jan 21, 2019
@bors bors closed this as completed in a9950f6 Jan 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-resolve Area: Name resolution T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants