From 7b456552b8ea254b060a2182907d3db98494fcbb Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Wed, 2 Dec 2020 09:52:08 +0100 Subject: Don't discard PathKind::Abs information in lower_use::convert_path --- crates/hir_def/src/nameres/tests/mod_resolution.rs | 21 +++++++++++++++++++++ crates/hir_def/src/path/lower/lower_use.rs | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'crates/hir_def') diff --git a/crates/hir_def/src/nameres/tests/mod_resolution.rs b/crates/hir_def/src/nameres/tests/mod_resolution.rs index ba295fd9e..ef6f85e15 100644 --- a/crates/hir_def/src/nameres/tests/mod_resolution.rs +++ b/crates/hir_def/src/nameres/tests/mod_resolution.rs @@ -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 + "#]], + ); +} diff --git a/crates/hir_def/src/path/lower/lower_use.rs b/crates/hir_def/src/path/lower/lower_use.rs index 53cecb05f..ba0d1f0e7 100644 --- a/crates/hir_def/src/path/lower/lower_use.rs +++ b/crates/hir_def/src/path/lower/lower_use.rs @@ -76,7 +76,7 @@ fn convert_path(prefix: Option, 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); -- cgit v1.2.3