-
Notifications
You must be signed in to change notification settings - Fork 13.3k
resolve: fix bug in visibility of shadowed use declarations #30294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…e in one namespace (e.g. the value namespace) is overridden by a later use declaration defining the same name in the other namespace (e.g. the type namespace).
(rust_highfive has picked a reviewer for you, use r? to override) |
cc #30159. |
r? @nrc |
This also fixes #30159. |
match import_resolution.target_for_namespace(ns) { | ||
Some(target) => { | ||
if !import_resolution[ns].is_public { | ||
continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be a labelled continue? It looks like you should continue to the next import_resolution, not to the next namespace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, if the import resolution is not public in one namespace it still could be public in the other namespace. For example, consider
mod foo {}
pub fn f() {}
use foo as bar;
pub use f as bar;
Here, there is a single import_resolution
corresponding to bar
that is private in the type namespace (i.e. !import_resolution[TypeNS].is_public
) but public in the value namespace (i.e. import_resolution[ValueNS].is_public
). If we skipped to the next import_resolution after seeing that the type namespace is private, we would not export bar
in the value namespace.
LGTM, modulo the two comments |
@nrc Thanks for the feedback. I addressed both comments. |
Sounds good, thanks! @bors: r+ |
📌 Commit ada87fa has been approved by |
This fixes a bug in which the visibility of a use declaration defining a name in one namespace (e.g. the value namespace) is overridden by a later use declaration defining the same name in the other namespace (e.g. the type namespace). For example,
As the example demonstrates, this is a [breaking-change], but it looks unlikely to cause breakage in practice, and any breakage can be fixed by correcting visibility modifiers.