Skip to content

Tracking Issue for future-incompatibility lint ambiguous_import_visibilities #153961

@petrochenkov

Description

@petrochenkov

This is the tracking issue for the ambiguous_import_visibilities future-compatibility warning and other related errors. The goal of this page is to describe why this change was made and how you can fix code that is affected by it. It also provides a place to ask questions or register a complaint if you feel the change should not be made. For more information on the policy around future-compatibility warnings, see our breaking change policy guidelines.

What is the warning for?

The ambiguous_import_visibilities lint detects imports that should report ambiguity errors due to ambiguous import visibilities, but previously didn't do that due to rustc bugs.

Why was this change made?

Explain why this change was made. If there is additional context, like an MCP, link it here.

Example

mod reexport {
    mod m {
        pub struct S {}
    }

    macro_rules! mac {
        () => { use m::S; }
    }

    pub use m::*;
    mac!();

    pub use S as Z; // ambiguous visibility
}

Previous versions of rustc compiled it successfully because they fetched the glob import's visibility for pub use S as Z import, and ignored the private use m::S import that appeared later.

Recommendations

Try disambiguating with explicit (non-glob) imports.

When will this warning become a hard error?

If known, describe the future plans. For example, how long you anticipate this being a warning, or if there are other factors that will influence the anticipated closure.

Steps

  • Implement the lint
  • Raise lint level to deny
  • Change the lint to report in dependencies
  • Switch to a hard error

Implementation history

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-visibilityArea: Visibility / privacyC-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCL-ambiguous_import_visibilitiesLint: ambiguous_import_visibilitiesT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    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