From 7b456552b8ea254b060a2182907d3db98494fcbb Mon Sep 17 00:00:00 2001
From: Lukas Wirth <lukastw97@gmail.com>
Date: Wed, 2 Dec 2020 09:52:08 +0100
Subject: [PATCH] Don't discard PathKind::Abs information in
 lower_use::convert_path

---
 .../src/nameres/tests/mod_resolution.rs       | 21 +++++++++++++++++++
 crates/hir_def/src/path/lower/lower_use.rs    |  2 +-
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/crates/hir_def/src/nameres/tests/mod_resolution.rs b/crates/hir_def/src/nameres/tests/mod_resolution.rs
index ba295fd9e04..ef6f85e1532 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 53cecb05fb2..ba0d1f0e7af 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<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);