-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Description
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
- resolve: Report more visibility-related early resolution ambiguities for imports #149596 - the lint was implemented