-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Tracking issue for changes to name resolution (RFC 1560) #35120
Comments
Implement RFC 1560 behind `#![feature(item_like_imports)]` This implements rust-lang/rfcs#1560 (cc #35120) behind the `item_like_imports` feature gate. The [RFC text](https://github.com/rust-lang/rfcs/blob/master/text/1560-name-resolution.md#changes-to-name-resolution-rules) describes the changes to name resolution enabled by `#![feature(item_like_imports)` in detail. To summarize, - Items and named imports shadow glob imports. - Multiple globs can import the same name if the name is unused or the imports are shadowed. - Multiple globs can import the same name if the imports are of the same item (following re-exports). - The visibility of such a name is the maximum visibility of the imports. - Equivalently, adding a glob import will never reduce the visibility of a name, nor will removing one increase it. - Non-prelude private imports can be used wherever we currently allow private items to be used. - Prelude-imported names are unaffected, i.e. they continue to be usable only in lexical scopes. - Globs import all visible names, not just public names. - Equivalently, glob importing from an ancestor module imports all of the ancestor's names, and glob importing from other modules is unchanged. r? @nrc
Nominating for stabilisation in the next cycle |
There are potential breaking changes around importing more names in globs, e.g., in |
More specifically, without
If the name is not used to resolve other imports, then it is simple to emit a warning instead of a hard ambiguity error. I believe this is likely to avoid a large fraction of any breakage in practice. To avoid the remaining breakage, we would probably need to try re-resolving the crate without |
Can we get started on crater runs now? If we can't do a warning cycle, we should be aggressive about submitting PRs to affected crates to repair problems. (Also, we should investigate whether we can give good errors that link users to an issue explaining what changed and how to fix, even if they are still getting an error.) |
Sure, I was thinking it was pretty early in the cycle and more breakage could appear later, but I guess there is no harm in doing multiple crate runs. @jseyfried would you be able to make a PR to un-feature-gate for a Crater run please? |
A partial warning cycle is fairly simple and a full warning cycle is possible (see #35120 (comment)).
The errors we give today already include a suggestion for a fix, e.g. this gist. I could make the suggestion more detailed/concrete or improve the error in other ways -- let me know if you have ideas. |
Team member @aturon has proposed to merge this. The next step is review by the rest of the tagged teams: No concerns currently listed. Once these reviewers reach consensus, this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
🔔 This is now entering its final comment period, as per the review above. 🔔 psst @aturon, I wasn't able to add the |
The final comment period is now complete. |
I see that the FCP is complete, but this issue is still open. What's the status? Are we keeping this open pending a deprecation period? |
RFC 1560 was stabilized in #37127 (currently in beta). |
This code currently fails in stable, but compiles in beta and nightly. I do not think it should: struct Outer;
mod foo {
use super::Outer;
mod test {
use super::*;
struct Dummy(Outer);
}
}
fn main() {} Since I've skimmed through the changes to name resolution rules section, but don't see what this would match up with. Anyone care to point me in the right direction? |
https://github.com/rust-lang/rfcs/blob/master/text/1560-name-resolution.md#non-public-imports + https://github.com/rust-lang/rfcs/blob/master/text/1560-name-resolution.md#glob-imports-of-accessible-but-not-public-names |
@petrochenkov Thank you. "non-public imports" appears to be the piece I was missing; I was aware of the glob change. I guess I missed it when skimming because it uses a sibling module, not the nested module that my brain was primed for. |
Tracking issue for rust-lang/rfcs#1560.
The text was updated successfully, but these errors were encountered: