Don't discard PathKind::Abs information in lower_use::convert_path

This commit is contained in:
Lukas Wirth 2020-12-02 09:52:08 +01:00
parent 13025ae2a1
commit 7b456552b8
2 changed files with 22 additions and 1 deletions

View file

@ -798,3 +798,24 @@ mod foo;
"#,
);
}
#[test]
fn abs_path_ignores_local() {
check(
r#"
//- /main.rs crate:main deps:core
pub use ::core::hash::Hash;
pub mod core {}
//- /lib.rs crate:core
pub mod hash { pub trait Hash {} }
"#,
expect![[r#"
crate
Hash: t
core: t
crate::core
"#]],
);
}

View file

@ -76,7 +76,7 @@ fn convert_path(prefix: Option<ModPath>, path: ast::Path, hygiene: &Hygiene) ->
Either::Left(name) => {
// no type args in use
let mut res = prefix.unwrap_or_else(|| ModPath {
kind: PathKind::Plain,
kind: segment.coloncolon_token().map_or(PathKind::Plain, |_| PathKind::Abs),
segments: Vec::with_capacity(1),
});
res.segments.push(name);