-
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
Fix ordering of nested modules in non-mod.rs mods #55192
Conversation
Flatten relative offset into directory path before adding inline (mod x { ... }) module names to the current directory path. Fix rust-lang#55094
(rust_highfive has picked a reviewer for you, use r? to override) |
Beta-nominating as this changes the behavior of functionality that would become stable in the current beta. |
@bors p=10 coming up on release week |
Sorry for being pestering, but I feel like I'm not communicating well, since I proposed this exact change. Is it OK that this breaks behavior for |
@ehuss Ah, my apologies! I didn't realize there was already a change open for this. Yeah, it does affect the behavior of |
If you want to, you can grab the fixes for the non-mod-rs tests from my PR. In-tree tests are pretty broken right now. |
I can almost guarantee that all changes done in this area after #37602 were subtly buggy, and you can't fix any bug in directory ownership / non-inline modules without introducing new bugs, unless you have detailed understanding of the whole picture. @cramertj and @ehuss |
Also, precise spec with motivational notes would be greatly helpful for this part of the language and compiler. |
@petrochenkov So, several of the rules laid out in #37602 are no longer true, especially since #47298. I'll try and lay out the current rules, and what we want to change. I'm not going to use the phrase "directory owner" here, since as we've discovered, we might want the semantics for what directory is "owned" by the current module to be different based on whether the ownership is being used to determine what location Some definitions:
The rules as currently implemented (post non-mod.rs mods stabilization):
I see two options to fixing this:
I think the first option is probably the best, but it's the one with the most complication and the least consistency between the behavior of #[path] and TL;DR: Edit: there's also the third option of breaking the current path behavior inside nested modules, which is what this PR currently implements. I think this is probably too big of a breaking change, but it might be worth a crater. |
@bors try |
Fix ordering of nested modules in non-mod.rs mods Flatten relative offset into directory path before adding inline (mod x { ... }) module names to the current directory path. Fix #55094
The "path-owning" vs "mod-owning" separations seems strange to me, unless we have to introduce it to explain the existing implementation. I'll re-read #55192 (comment) again tomorrow because right now I seem to forget previous paragraphs faster than I read the new ones. |
☀️ Test successful - status-travis |
@craterbot run start=master#155510e377ae2a8d8ee0dad1a5f809c9062a5526 end=try#ca35ca839582d74f045a4a1eb9e1a82e29f0e032 mode=check-only |
👌 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
🚧 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
cc @rust-lang/release and @rust-lang/compiler for the backport to beta this close to the stable release |
🎉 Experiment
|
Wut, Crater broke itself again... |
This needs to land by Wednesday morning at the absolute latest if it is to make it for the release in beta; otherwise I think the likely course is to back out stabilization. Part of me says we should just do that, though -- is there some reason we can't destabilize this feature instead? |
🚧 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
I'm retagging this as beta-nominated as since this was destabilized in 1.30.0 this now affects 1.31.0 and if we want to continue to leave this as stable it'll presumably need this fix! |
🎉 Experiment
|
No regressions. |
@bors r+ |
📌 Commit ca35ca8 has been approved by |
Fix ordering of nested modules in non-mod.rs mods Flatten relative offset into directory path before adding inline (mod x { ... }) module names to the current directory path. Fix #55094
☀️ Test successful - status-appveyor, status-travis |
I don't think this should have been merged without more discussion on #55094. cc @rust-lang/lang this changed the behavior of |
[beta]: Prepare the 1.31.0 beta release * Update to Cargo's branched 1.31.0 branch * Update the channel to `beta` Rolled up beta-accepted PRs: * #55362: Remove `cargo new --edition` from release notes. * #55325: Fix link to macros chapter * #55358: Remove redundant clone (2) * #55346: Shrink `Statement`. * #55274: Handle bindings in substructure of patterns with type ascriptions * #55297: Partial implementation of uniform paths 2.0 to land before beta * #55192: Fix ordering of nested modules in non-mod.rs mods * #55185: path suggestions in Rust 2018 should point out the change in semantics * #55423: back out bogus `Ok`-wrapping suggestion on `?` arm type mismatch Note that **this does not update the bootstrap compiler** due to #55404
FWIW, I don't even care about precise rules anymore. |
@petrochenkov If we're willing and able to land this breaking change, then we can probably also land a breaking change that would make |
Quite possible. |
Flatten relative offset into directory path before adding inline
(mod x { ... }) module names to the current directory path.
Fix #55094