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

Bad diagnostic when attemting to import private item via glob #88472

Closed
aDotInTheVoid opened this issue Aug 30, 2021 · 0 comments · Fixed by #88838
Closed

Bad diagnostic when attemting to import private item via glob #88472

aDotInTheVoid opened this issue Aug 30, 2021 · 0 comments · Fixed by #88838
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-resolve Area: Name resolution A-visibility Area: Visibility / privacy C-enhancement Category: An issue proposing an enhancement or a PR with one. D-confusing Diagnostics: Confusing error or lint that should be reworked. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@aDotInTheVoid
Copy link
Member

Given the following code:

mod a {
    struct Foo;
}

mod b {
    use crate::a::*;
    type Bar = Foo;
}

The current output is:

error[E0412]: cannot find type `Foo` in this scope
 --> src/lib.rs:7:16
  |
7 |     type Bar = Foo;
  |                ^^^ not found in this scope
  |
help: consider importing this struct
  |
6 |     use crate::a::Foo;
  |

warning: unused import: `crate::a::*`
 --> src/lib.rs:6:9
  |
6 |     use crate::a::*;
  |         ^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

Ideally the output should look like:

error[E0412]: cannot find type `Foo` in this scope
 --> src/lib.rs:7:16
  |
7 |     type Bar = Foo;
  |                ^^^ not found in this scope
  |
Note: Foo imported [here], but cannot be imported as it is defined as private [here]
@aDotInTheVoid aDotInTheVoid added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 30, 2021
@camelid camelid added A-resolve Area: Name resolution A-visibility Area: Visibility / privacy D-confusing Diagnostics: Confusing error or lint that should be reworked. C-enhancement Category: An issue proposing an enhancement or a PR with one. labels Sep 1, 2021
@bors bors closed this as completed in 9593e61 Oct 1, 2021
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 A-visibility Area: Visibility / privacy C-enhancement Category: An issue proposing an enhancement or a PR with one. D-confusing Diagnostics: Confusing error or lint that should be reworked. 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