Auto merge of #53988 - eddyb:issue-53770, r=petrochenkov
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
This commit is contained in:
commit
3d2fc456a9
2 changed files with 49 additions and 43 deletions
|
|
@ -23,8 +23,7 @@ mod m {
|
|||
pub(in crate::m) struct S;
|
||||
}
|
||||
|
||||
mod n
|
||||
{
|
||||
mod n {
|
||||
use crate::m::f;
|
||||
use crate as root;
|
||||
pub fn check() {
|
||||
|
|
@ -34,9 +33,20 @@ mod n
|
|||
}
|
||||
}
|
||||
|
||||
mod p {
|
||||
use {super::f, crate::m::g, self::root::m::h};
|
||||
use crate as root;
|
||||
pub fn check() {
|
||||
assert_eq!(f(), 1);
|
||||
assert_eq!(g(), 2);
|
||||
assert_eq!(h(), 3);
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
assert_eq!(f(), 1);
|
||||
assert_eq!(crate::m::g(), 2);
|
||||
assert_eq!(root::m::h(), 3);
|
||||
n::check();
|
||||
p::check();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue