Skip to content

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

Closed
@aDotInTheVoid

Description

@aDotInTheVoid

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]

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-resolveArea: Name/path resolution done by `rustc_resolve` specificallyA-visibilityArea: Visibility / privacyC-enhancementCategory: An issue proposing an enhancement or a PR with one.D-confusingDiagnostics: Confusing error or lint that should be reworked.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions