-
Notifications
You must be signed in to change notification settings - Fork 13.4k
rustc_resolve: only prepend CrateRoot to a non-keyword segment. #53988
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
FWIW, the RFC explicitly specified that the It also means you can always prepends a single |
Without looking at code, how |
I see, root segments can indeed be injected at arbitrary different levels inside braces. |
I have mixed feelings and not ready to approve this single-handedly. In non- Should this implicit use {a, {self::b}, {c, {super::d}}};
=>
use ::{a, {self::b}, {c, {super::d}}}; // `::self::b` and `::super::d` are errors or "adaptively", multiple times inside braces when appropriate (this PR) use {a, {b}, {c, {d}}};
=>
use {::a, {self::b}, {::c, {super::d}}}; // OK ? |
I would expect the following to hold: (1) use {$p_0};
=>
use $p_0; (2) use {$p_0, $p_1, $p_2};
=>
use $p_0;
use $p_1;
use $p_2; (3) use {$p_0, {$p_1, {$p_2}}};
=>
use $p_0;
use $p_1;
use $p_2; This applies however arbitrarily deep you nest it. I think that prefixing |
☔ The latest upstream changes (presumably #54005) made this pull request unmergeable. Please resolve the merge conflicts. |
So with |
@petrochenkov You mean |
@eddyb |
☔ The latest upstream changes (presumably #54021) made this pull request unmergeable. Please resolve the merge conflicts. |
I definitely agree with @Centril's intuition as well -- a nested |
@aturon @Centril Do we need some sort of process here (FCP merge, I'd guess?), or are you saying that @petrochenkov can already go ahead and |
Since we're under a bit of a time pressure, let's instead do: @rfcbot poll lang Can we go ahead and r+ this PR? |
Team member @Centril has asked teams: T-lang, for consensus on:
|
Ok, @bors r+ |
📌 Commit e0e7cf3 has been approved by |
rustc_resolve: only prepend CrateRoot to a non-keyword segment. Fixes rust-lang#53770 by treating `use` paths as absolute in a finer-grained manner, specifically: ```rust use {a, crate::b, self::c, super::d}; ``` Used to be interpreted as if it were (when `uniform_paths` is not enabled): ```rust use ::{a, crate::b, self::c, super::d}; ``` With this PR, the `CrateRoot` pseudo-keyword indicating an absolute path is only inserted when the first path segment is found (if it's not a keyword), i.e. the example behaves like: ```rust use {::a, crate::b, self::c, super::d}; ``` This should (finally) make `use {path};` fully equivalent to `use path;`. r? @petrochenkov cc @cramertj @joshtriplett @nikomatsakis
…rochenkov rustc_resolve: inject `uniform_paths` canary always on Rust 2018. **NOTE**: this PR is based on rust-lang#53988, only the second commit is new. This PR is an attempt at future-proofing "anchored paths" by emitting the same ambiguity errors that `#![feature(uniform_paths)]` would, with slightly changed phrasing (see added UI tests). r? @petrochenkov cc @aturon @Centril @joshtriplett
rustc_resolve: only prepend CrateRoot to a non-keyword segment. Fixes #53770 by treating `use` paths as absolute in a finer-grained manner, specifically: ```rust use {a, crate::b, self::c, super::d}; ``` Used to be interpreted as if it were (when `uniform_paths` is not enabled): ```rust use ::{a, crate::b, self::c, super::d}; ``` With this PR, the `CrateRoot` pseudo-keyword indicating an absolute path is only inserted when the first path segment is found (if it's not a keyword), i.e. the example behaves like: ```rust use {::a, crate::b, self::c, super::d}; ``` This should (finally) make `use {path};` fully equivalent to `use path;`. r? @petrochenkov cc @cramertj @joshtriplett @nikomatsakis
☀️ Test successful - status-appveyor, status-travis |
Fixes #53770 by treating
use
paths as absolute in a finer-grained manner, specifically:Used to be interpreted as if it were (when
uniform_paths
is not enabled):With this PR, the
CrateRoot
pseudo-keyword indicating an absolute path is only inserted when the first path segment is found (if it's not a keyword), i.e. the example behaves like:This should (finally) make
use {path};
fully equivalent touse path;
.r? @petrochenkov cc @cramertj @joshtriplett @nikomatsakis