aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_def')
-rw-r--r--crates/ra_hir_def/src/nameres/collector.rs2
-rw-r--r--crates/ra_hir_def/src/nameres/path_resolution.rs15
-rw-r--r--crates/ra_hir_def/src/path.rs5
-rw-r--r--crates/ra_hir_def/src/path/lower.rs4
-rw-r--r--crates/ra_hir_def/src/path/lower/lower_use.rs4
5 files changed, 15 insertions, 15 deletions
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs
index 912a073ea..8bbf7ffa2 100644
--- a/crates/ra_hir_def/src/nameres/collector.rs
+++ b/crates/ra_hir_def/src/nameres/collector.rs
@@ -890,7 +890,7 @@ where
890 // We rewrite simple path `macro_name` to `self::macro_name` to force resolve in module scope only. 890 // We rewrite simple path `macro_name` to `self::macro_name` to force resolve in module scope only.
891 let mut path = mac.path.clone(); 891 let mut path = mac.path.clone();
892 if path.is_ident() { 892 if path.is_ident() {
893 path.kind = PathKind::Self_; 893 path.kind = PathKind::Super(0);
894 } 894 }
895 895
896 self.def_collector.unexpanded_macros.push(MacroDirective { 896 self.def_collector.unexpanded_macros.push(MacroDirective {
diff --git a/crates/ra_hir_def/src/nameres/path_resolution.rs b/crates/ra_hir_def/src/nameres/path_resolution.rs
index 4a249e7e7..1dbc4f371 100644
--- a/crates/ra_hir_def/src/nameres/path_resolution.rs
+++ b/crates/ra_hir_def/src/nameres/path_resolution.rs
@@ -10,6 +10,8 @@
10//! 10//!
11//! `ReachedFixedPoint` signals about this. 11//! `ReachedFixedPoint` signals about this.
12 12
13use std::iter::successors;
14
13use hir_expand::name::Name; 15use hir_expand::name::Name;
14use ra_db::Edition; 16use ra_db::Edition;
15use test_utils::tested_by; 17use test_utils::tested_by;
@@ -97,9 +99,6 @@ impl CrateDefMap {
97 PathKind::Crate => { 99 PathKind::Crate => {
98 PerNs::types(ModuleId { krate: self.krate, local_id: self.root }.into()) 100 PerNs::types(ModuleId { krate: self.krate, local_id: self.root }.into())
99 } 101 }
100 PathKind::Self_ => {
101 PerNs::types(ModuleId { krate: self.krate, local_id: original_module }.into())
102 }
103 // plain import or absolute path in 2015: crate-relative with 102 // plain import or absolute path in 2015: crate-relative with
104 // fallback to extern prelude (with the simplification in 103 // fallback to extern prelude (with the simplification in
105 // rust-lang/rust#57745) 104 // rust-lang/rust#57745)
@@ -123,9 +122,11 @@ impl CrateDefMap {
123 log::debug!("resolving {:?} in module", segment); 122 log::debug!("resolving {:?} in module", segment);
124 self.resolve_name_in_module(db, original_module, &segment, prefer_module(idx)) 123 self.resolve_name_in_module(db, original_module, &segment, prefer_module(idx))
125 } 124 }
126 PathKind::Super => { 125 PathKind::Super(lvl) => {
127 if let Some(p) = self.modules[original_module].parent { 126 let m = successors(Some(original_module), |m| self.modules[*m].parent)
128 PerNs::types(ModuleId { krate: self.krate, local_id: p }.into()) 127 .nth(lvl as usize);
128 if let Some(local_id) = m {
129 PerNs::types(ModuleId { krate: self.krate, local_id }.into())
129 } else { 130 } else {
130 log::debug!("super path in root module"); 131 log::debug!("super path in root module");
131 return ResolvePathResult::empty(ReachedFixedPoint::Yes); 132 return ResolvePathResult::empty(ReachedFixedPoint::Yes);
@@ -170,7 +171,7 @@ impl CrateDefMap {
170 if module.krate != self.krate { 171 if module.krate != self.krate {
171 let path = ModPath { 172 let path = ModPath {
172 segments: path.segments[i..].to_vec(), 173 segments: path.segments[i..].to_vec(),
173 kind: PathKind::Self_, 174 kind: PathKind::Super(0),
174 }; 175 };
175 log::debug!("resolving {:?} in other crate", path); 176 log::debug!("resolving {:?} in other crate", path);
176 let defp_map = db.crate_def_map(module.krate); 177 let defp_map = db.crate_def_map(module.krate);
diff --git a/crates/ra_hir_def/src/path.rs b/crates/ra_hir_def/src/path.rs
index 20d6d98ea..3b26e8337 100644
--- a/crates/ra_hir_def/src/path.rs
+++ b/crates/ra_hir_def/src/path.rs
@@ -56,7 +56,7 @@ impl ModPath {
56 } 56 }
57 57
58 pub fn is_self(&self) -> bool { 58 pub fn is_self(&self) -> bool {
59 self.kind == PathKind::Self_ && self.segments.is_empty() 59 self.kind == PathKind::Super(0) && self.segments.is_empty()
60 } 60 }
61 61
62 /// If this path is a single identifier, like `foo`, return its name. 62 /// If this path is a single identifier, like `foo`, return its name.
@@ -100,8 +100,7 @@ pub enum GenericArg {
100#[derive(Debug, Clone, PartialEq, Eq, Hash)] 100#[derive(Debug, Clone, PartialEq, Eq, Hash)]
101pub enum PathKind { 101pub enum PathKind {
102 Plain, 102 Plain,
103 Self_, 103 Super(u8),
104 Super,
105 Crate, 104 Crate,
106 // Absolute path 105 // Absolute path
107 Abs, 106 Abs,
diff --git a/crates/ra_hir_def/src/path/lower.rs b/crates/ra_hir_def/src/path/lower.rs
index a2e995198..c71b52d89 100644
--- a/crates/ra_hir_def/src/path/lower.rs
+++ b/crates/ra_hir_def/src/path/lower.rs
@@ -95,11 +95,11 @@ pub(super) fn lower_path(mut path: ast::Path, hygiene: &Hygiene) -> Option<Path>
95 break; 95 break;
96 } 96 }
97 ast::PathSegmentKind::SelfKw => { 97 ast::PathSegmentKind::SelfKw => {
98 kind = PathKind::Self_; 98 kind = PathKind::Super(0);
99 break; 99 break;
100 } 100 }
101 ast::PathSegmentKind::SuperKw => { 101 ast::PathSegmentKind::SuperKw => {
102 kind = PathKind::Super; 102 kind = PathKind::Super(1);
103 break; 103 break;
104 } 104 }
105 } 105 }
diff --git a/crates/ra_hir_def/src/path/lower/lower_use.rs b/crates/ra_hir_def/src/path/lower/lower_use.rs
index ea3fdb56c..062c02063 100644
--- a/crates/ra_hir_def/src/path/lower/lower_use.rs
+++ b/crates/ra_hir_def/src/path/lower/lower_use.rs
@@ -95,13 +95,13 @@ fn convert_path(prefix: Option<ModPath>, path: ast::Path, hygiene: &Hygiene) ->
95 if prefix.is_some() { 95 if prefix.is_some() {
96 return None; 96 return None;
97 } 97 }
98 ModPath::from_simple_segments(PathKind::Self_, iter::empty()) 98 ModPath::from_simple_segments(PathKind::Super(0), iter::empty())
99 } 99 }
100 ast::PathSegmentKind::SuperKw => { 100 ast::PathSegmentKind::SuperKw => {
101 if prefix.is_some() { 101 if prefix.is_some() {
102 return None; 102 return None;
103 } 103 }
104 ModPath::from_simple_segments(PathKind::Super, iter::empty()) 104 ModPath::from_simple_segments(PathKind::Super(1), iter::empty())
105 } 105 }
106 ast::PathSegmentKind::Type { .. } => { 106 ast::PathSegmentKind::Type { .. } => {
107 // not allowed in imports 107 // not allowed in imports