Repository navigation
Description
This issue is to track the discussion of the following proposal:
I propose we stabilize the
uniform_pathsfeature in Rust 2018, eliminating theanchored_pathsvariant. I further propose we backport this stabilization to version 1.31 beta, so that all stable versions of Rust 2018 have this feature.
We've taken informal polls about this question in a paper document. Most of the lang team has favored uniform_paths, I and @cramertj were the only two members who initially favored anchored_paths. Yesterday, we discussed this in the lang team video meeting; in the meeting we sort of crystallized the various pros and cons of the two variants, but didn't reach a consensus.
In the time since the meeting, I've come around to thinking that stabilizing on uniform_paths is probably the best choice. I imagine @cramertj has not changed his mind, and though he said in the meeting he wouldn't block a decision, I hope we can use this FCP period to see if there's any agreeable changes that would make uniform_paths more palatable to him.
I've also written a blog post summarizing the meeting discussion and how my position has evolved, which provides more context on this decision.
I also want to make sure we continue to get community feedback as we reach this final decision! Please contribute new thoughts you have to the discussion. However, we will hopefully make this decision within the next few weeks, and certain proposals are out of scope. Any third proposal which is not completely backwards compatible with the current behavior of paths in Rust 2018 is impossible to ship in Rust 2018 at this point. Variations on anchored or uniform paths that are backwards compatible may be considered, but that also seems unlikely.
Activity
withoutboats commentedon Nov 2, 2018
@rfcbot fcp merge
rfcbot commentedon Nov 2, 2018
Team member @withoutboats has proposed to merge this. The next step is review by the rest of the tagged teams:
Concerns:
file-centric-behaviorresolved by Stabilize uniform paths on Rust 2018 #55618 (comment)idiomatic_useresolved by Stabilize uniform paths on Rust 2018 #55618 (comment)implementationresolved by Stabilize uniform paths on Rust 2018 #55618 (comment)stabilization-report-and-testsresolved by Stabilize uniform paths on Rust 2018 #55618 (comment)Once a majority of reviewers approve (and none object), 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.
joshtriplett commentedon Nov 2, 2018
@withoutboats Thank you for your detailed writeup, as well as your careful and considered evaluation.
Having been the sole opposition of more than one language proposal in the past, I would like to explicitly extend the following invitation to @cramertj: If you feel you need more time to write up some thoughts on how
uniform_pathscould adapt to better meet the needs of Rust users in your group and elsewhere at Google, as well as any concerns aboutuniform_pathsthat didn't make it into yesterday's discussion as captured by @withoutboats' writeup, please feel free to either register a concern or simply state that you'd like more time. This is not a vote, and despite rfcbot's default behavior for what it takes to move forward with an FCP, I'd like us to reach a full consensus if possible.nikomatsakis commentedon Nov 2, 2018
It's good to say it explicitly, of course, but -- to be clear -- I feel this is always true for any FCP =)
Centril commentedon Nov 2, 2018
Excellent writeup @withoutboats. ❤️
Report & Tests
@rfcbot concern stabilization-report-and-tests
Before we stabilize
uniform_paths, I think we need a stabilization report that documents what behavior is being stabilized (and what is not), and tests for that behavior. Since @petrochenkov and @eddyb have been at the forefront of implementing the behavior, maybe they could write up the report?File-centric behavior
@rfcbot concern file-centric-behavior
As for what we're going to stabilize here, @nikomatsakis noted in the paper document that a more file-centric adaptation of
uniform_pathsis favourable such that you may write:Benefits
The file-centric approach is beneficial mainly because it is quite common for languages to take such an approach and Rust is the odd fish in the bunch; By adopting an approach where the above snippet is legal, the speed-bump when learning Rust can be reduced. For example, in Java, inner classes can see the imports at the top of the file.
Another benefit of the file-centric approach is that you no longer have to write the
use super::*;boilerplate, which is arguably a misfeature, anymore. This makes writing unit tests more ergonomic:Drawbacks
I see two principal drawbacks with the file-centric behavior:
It encourages writing large files and thus may diminish the maintainability of large projects.
Inline modules are no longer units that can be so easily refactored. For example, if you want to move an inline
mod foo { ... }into a dedicated file, then you may need to scroll up to the beginning of the file and copy theusestatements. This can be mitigated with IDEs -- but not everyone have those.One mitigating factor here is that it is unlikely to have inline modules which nest; the most common use of inline modules are for unit tests or for small modules that contain platform specific behavior -- in the language team meeting, everyone agreed that this was the case and that nested inline modules were not commonly used.
Conclusion
All in all, while I was initially somewhat skeptical about the file-centric behavior, I think it is in line with one of the core goals of
uniform_paths-- to make the module system intuitive and easy to learn. Therefore, I'd like to propose that we incorporate the file-centric behavior into the stabilization (EDIT: or at least make it possible after stabilization...).Why does it have to happen now? Consider the following (playground):
lucozadeez commentedon Nov 2, 2018
Apologies if this has already been considered but would
extern::foowork to disambiguate uniform paths?So the logic would always be
crate::foo::for modules in the crateextern::foo::for external modulesfoo::for submodules if there is a matching submodule or external if notIt has the advantage of using an existing keyword. I couldn't see any reason for there to be a parsing ambiguity but I could be wrong there.
Centril commentedon Nov 2, 2018
@lucozadeez
To disambiguate, you can write
::fooinstead; this will have the same effect.We could also permit
extern::foobut that would be sort of redundant (more than one ways to do it without clear benefits...).I don't think there would be any ambiguity.
joshtriplett commentedon Nov 2, 2018
nikomatsakis commentedon Nov 2, 2018
@Centril
😍 Yes please! 😍
petrochenkov commentedon Nov 2, 2018
Implementation is in progress, so the behavior will change slightly.
I landed some preliminary refactorings last weekend and hope to finish the work this weekend.
I want to do it in such way that uniform paths are always enabled on 2018, but gated if actually used, so we get feature gate errors instead of "unresolved name" errors.
This is possible because "anchored paths with future-proofing" is a strict subset of uniform paths.
I'd prefer to test the new implementation for one more cycle and not backport stabilization to 1.31.
nikomatsakis commentedon Nov 2, 2018
nikomatsakis commentedon Nov 2, 2018
92 remaining items
Centril commentedon Dec 29, 2018
@rfcbot resolve stabilization-report-and-tests
Done in #56759.
aturon commentedon Jan 9, 2019
@rfcbot resolve implementation
rfcbot commentedon Jan 9, 2019
🔔 This is now entering its final comment period, as per the review above. 🔔
Auto merge of #56759 - petrochenkov:prestabuni, r=nikomatsakis
Auto merge of #56759 - petrochenkov:prestabuni, r=nikomatsakis
ErichDonGubler commentedon Jan 12, 2019
I'm confused. Shouldn't this issue remain open until the FCP completes?
Centril commentedon Jan 12, 2019
@ErichDonGubler well, due to time constraints it will already be in 1.32 and FCP in #56759 (comment) will complete in 1 day.
@rfcbot cancel
INSP: drop RsAnchoredPathsInspection
Merge #3767
INSP: drop RsAnchoredPathsInspection