Skip to content

Better error messages for unresolved imports due to privateness when using use foo::* #6477

Closed
@kud1ing

Description

@kud1ing

In #6443 @cmr made rustc for the following code

mod foo {
   struct Foo;
}

mod bar {
   use foo::Foo;
   struct Bar {
     x : Foo
   }
}

explain error: unresolved import: found "Foo" in "foo" but it is private.

When the module members however are imported using * this way:

mod foo {
   struct Foo;
}

mod bar {
   use foo::*;
   struct Bar {
     x : Foo
   }
}

rustc only says error: use of undeclared type name "Foo".

I think the most prominent use case could be use super::* in unit-test modules.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-resolveArea: Name/path resolution done by `rustc_resolve` specificallyC-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions