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

conflict between use and pub use in crate re-exports #11858

Closed
digama0 opened this issue Mar 31, 2022 · 0 comments · Fixed by #17715
Closed

conflict between use and pub use in crate re-exports #11858

digama0 opened this issue Mar 31, 2022 · 0 comments · Fixed by #17715
Labels
A-nameres name, path and module resolution C-bug Category: bug

Comments

@digama0
Copy link
Contributor

digama0 commented Mar 31, 2022

crate mylib:

mod bar {
  pub struct Foo;
}
use bar::*;
pub use bar::*;

main.rs:

use mylib::Foo;

pub fn f(_: &Foo) {}
fn main() {
  let foo = mylib::Foo;
  f(&foo); // type mismatch: expected &{unknown}, found &Foo
}

Other observations about this example: hovering over the reference to Foo in f shows that it is not recognized, which is why &{unknown} is expected in the type mismatch. rustc compiles this without issue. If both glob imports are replaced by imports of bar::Foo, then it fails to compile because two Foo names are introduced in the scope of mylib; if only the private one is replaced by Foo then rustc will treat Foo as private even though there is a public glob use. (It is not clear whether this behavior is intentional / desirable in rustc: zulip, rust-lang/rust#95420.)

rust-analyzer version: 63c4d6b20 2022-03-30 nightly

rustc version: rustc 1.61.0-nightly (52b34550a 2022-03-15)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-nameres name, path and module resolution C-bug Category: bug
Projects
None yet
3 participants