aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r--crates/ra_hir/src/nameres.rs9
-rw-r--r--crates/ra_hir/src/path.rs19
-rw-r--r--crates/ra_hir/src/resolve.rs2
3 files changed, 10 insertions, 20 deletions
diff --git a/crates/ra_hir/src/nameres.rs b/crates/ra_hir/src/nameres.rs
index be1cc76b6..b808a0c36 100644
--- a/crates/ra_hir/src/nameres.rs
+++ b/crates/ra_hir/src/nameres.rs
@@ -382,7 +382,7 @@ impl CrateDefMap {
382 return ResolvePathResult::empty(ReachedFixedPoint::No); // extern crate declarations can add to the extern prelude 382 return ResolvePathResult::empty(ReachedFixedPoint::No); // extern crate declarations can add to the extern prelude
383 } 383 }
384 } 384 }
385 PathKind::Type => { 385 PathKind::Type(_) => {
386 // This is handled in `infer::infer_path_expr` 386 // This is handled in `infer::infer_path_expr`
387 // The result returned here does not matter 387 // The result returned here does not matter
388 return ResolvePathResult::empty(ReachedFixedPoint::Yes); 388 return ResolvePathResult::empty(ReachedFixedPoint::Yes);
@@ -406,11 +406,8 @@ impl CrateDefMap {
406 curr_per_ns = match curr { 406 curr_per_ns = match curr {
407 ModuleDef::Module(module) => { 407 ModuleDef::Module(module) => {
408 if module.krate != self.krate { 408 if module.krate != self.krate {
409 let path = Path { 409 let path =
410 segments: path.segments[i..].to_vec(), 410 Path { segments: path.segments[i..].to_vec(), kind: PathKind::Self_ };
411 kind: PathKind::Self_,
412 type_ref: None,
413 };
414 log::debug!("resolving {:?} in other crate", path); 411 log::debug!("resolving {:?} in other crate", path);
415 let defp_map = db.crate_def_map(module.krate); 412 let defp_map = db.crate_def_map(module.krate);
416 let (def, s) = defp_map.resolve_path(db, module.module_id, &path); 413 let (def, s) = defp_map.resolve_path(db, module.module_id, &path);
diff --git a/crates/ra_hir/src/path.rs b/crates/ra_hir/src/path.rs
index 7c19fda14..9e449f6cc 100644
--- a/crates/ra_hir/src/path.rs
+++ b/crates/ra_hir/src/path.rs
@@ -10,7 +10,6 @@ use crate::{name, type_ref::TypeRef, AsName, Name};
10#[derive(Debug, Clone, PartialEq, Eq, Hash)] 10#[derive(Debug, Clone, PartialEq, Eq, Hash)]
11pub struct Path { 11pub struct Path {
12 pub kind: PathKind, 12 pub kind: PathKind,
13 pub type_ref: Option<Box<TypeRef>>,
14 pub segments: Vec<PathSegment>, 13 pub segments: Vec<PathSegment>,
15} 14}
16 15
@@ -43,7 +42,7 @@ pub enum GenericArg {
43 // or lifetime... 42 // or lifetime...
44} 43}
45 44
46#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 45#[derive(Debug, Clone, PartialEq, Eq, Hash)]
47pub enum PathKind { 46pub enum PathKind {
48 Plain, 47 Plain,
49 Self_, 48 Self_,
@@ -52,7 +51,7 @@ pub enum PathKind {
52 // Absolute path 51 // Absolute path
53 Abs, 52 Abs,
54 // Type based path like `<T>::foo` 53 // Type based path like `<T>::foo`
55 Type, 54 Type(Box<TypeRef>),
56} 55}
57 56
58impl Path { 57impl Path {
@@ -69,7 +68,6 @@ impl Path {
69 pub fn from_simple_segments(kind: PathKind, segments: impl IntoIterator<Item = Name>) -> Path { 68 pub fn from_simple_segments(kind: PathKind, segments: impl IntoIterator<Item = Name>) -> Path {
70 Path { 69 Path {
71 kind, 70 kind,
72 type_ref: None,
73 segments: segments 71 segments: segments
74 .into_iter() 72 .into_iter()
75 .map(|name| PathSegment { name, args_and_bindings: None }) 73 .map(|name| PathSegment { name, args_and_bindings: None })
@@ -81,7 +79,6 @@ impl Path {
81 pub fn from_ast(mut path: ast::Path) -> Option<Path> { 79 pub fn from_ast(mut path: ast::Path) -> Option<Path> {
82 let mut kind = PathKind::Plain; 80 let mut kind = PathKind::Plain;
83 let mut segments = Vec::new(); 81 let mut segments = Vec::new();
84 let mut path_type_ref = None;
85 loop { 82 loop {
86 let segment = path.segment()?; 83 let segment = path.segment()?;
87 84
@@ -112,8 +109,7 @@ impl Path {
112 match trait_ref { 109 match trait_ref {
113 // <T>::foo 110 // <T>::foo
114 None => { 111 None => {
115 kind = PathKind::Type; 112 kind = PathKind::Type(Box::new(self_type));
116 path_type_ref = Some(Box::new(self_type));
117 } 113 }
118 // <T as Trait<A>>::Foo desugars to Trait<Self=T, A>::Foo 114 // <T as Trait<A>>::Foo desugars to Trait<Self=T, A>::Foo
119 Some(trait_ref) => { 115 Some(trait_ref) => {
@@ -154,7 +150,7 @@ impl Path {
154 }; 150 };
155 } 151 }
156 segments.reverse(); 152 segments.reverse();
157 return Some(Path { kind, type_ref: path_type_ref, segments }); 153 return Some(Path { kind, segments });
158 154
159 fn qualifier(path: &ast::Path) -> Option<ast::Path> { 155 fn qualifier(path: &ast::Path) -> Option<ast::Path> {
160 if let Some(q) = path.qualifier() { 156 if let Some(q) = path.qualifier() {
@@ -309,11 +305,8 @@ fn convert_path(prefix: Option<Path>, path: ast::Path) -> Option<Path> {
309 let res = match segment.kind()? { 305 let res = match segment.kind()? {
310 ast::PathSegmentKind::Name(name) => { 306 ast::PathSegmentKind::Name(name) => {
311 // no type args in use 307 // no type args in use
312 let mut res = prefix.unwrap_or_else(|| Path { 308 let mut res = prefix
313 kind: PathKind::Plain, 309 .unwrap_or_else(|| Path { kind: PathKind::Plain, segments: Vec::with_capacity(1) });
314 type_ref: None,
315 segments: Vec::with_capacity(1),
316 });
317 res.segments.push(PathSegment { 310 res.segments.push(PathSegment {
318 name: name.as_name(), 311 name: name.as_name(),
319 args_and_bindings: None, // no type args in use 312 args_and_bindings: None, // no type args in use
diff --git a/crates/ra_hir/src/resolve.rs b/crates/ra_hir/src/resolve.rs
index e357c74e3..bb6915901 100644
--- a/crates/ra_hir/src/resolve.rs
+++ b/crates/ra_hir/src/resolve.rs
@@ -190,7 +190,7 @@ impl Resolver {
190 db: &impl HirDatabase, 190 db: &impl HirDatabase,
191 path: &'p Path, 191 path: &'p Path,
192 ) -> Option<ResolveValueResult<'p>> { 192 ) -> Option<ResolveValueResult<'p>> {
193 if let Some(type_ref) = &path.type_ref { 193 if let PathKind::Type(type_ref) = &path.kind {
194 return Some(ResolveValueResult::TypeRef(type_ref)); 194 return Some(ResolveValueResult::TypeRef(type_ref));
195 } 195 }
196 196