Skip to content

Error on bad pub(path) depends on module ordering #40066

@withoutboats

Description

@withoutboats

Which error message you get with a non-ancestral pub(path) visibility restriction depends on the ordering of module declarations.

These two struct declarations produce different errors;

mod foo {
    pub(in ::bar) struct Foo;
}

mod bar {
    pub(in ::foo) struct Bar;
}

The second produces the correct error:

error: visibilities can only be restricted to ancestor modules

The first produces this, incorrect error:

error[E0578]: cannot find module `bar` in the crate root

Presumably the pub(path) code is operating on the assumption the path, if real, has already been walked (because any correct path would have been walked), but this is not the case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-resolveArea: Name/path resolution done by `rustc_resolve` specificallyC-bugCategory: This is a bug.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.WG-diagnosticsWorking group: Diagnostics

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions