From de9670fe456d89f97e8044d4e0919d2c16d1087f Mon Sep 17 00:00:00 2001 From: uHOOCCOOHu Date: Sun, 15 Sep 2019 19:48:24 +0800 Subject: Move store TypeRef of type based path in PathKind --- crates/ra_hir/src/path.rs | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'crates/ra_hir/src/path.rs') 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}; #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Path { pub kind: PathKind, - pub type_ref: Option>, pub segments: Vec, } @@ -43,7 +42,7 @@ pub enum GenericArg { // or lifetime... } -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum PathKind { Plain, Self_, @@ -52,7 +51,7 @@ pub enum PathKind { // Absolute path Abs, // Type based path like `::foo` - Type, + Type(Box), } impl Path { @@ -69,7 +68,6 @@ impl Path { pub fn from_simple_segments(kind: PathKind, segments: impl IntoIterator) -> Path { Path { kind, - type_ref: None, segments: segments .into_iter() .map(|name| PathSegment { name, args_and_bindings: None }) @@ -81,7 +79,6 @@ impl Path { pub fn from_ast(mut path: ast::Path) -> Option { let mut kind = PathKind::Plain; let mut segments = Vec::new(); - let mut path_type_ref = None; loop { let segment = path.segment()?; @@ -112,8 +109,7 @@ impl Path { match trait_ref { // ::foo None => { - kind = PathKind::Type; - path_type_ref = Some(Box::new(self_type)); + kind = PathKind::Type(Box::new(self_type)); } // >::Foo desugars to Trait::Foo Some(trait_ref) => { @@ -154,7 +150,7 @@ impl Path { }; } segments.reverse(); - return Some(Path { kind, type_ref: path_type_ref, segments }); + return Some(Path { kind, segments }); fn qualifier(path: &ast::Path) -> Option { if let Some(q) = path.qualifier() { @@ -309,11 +305,8 @@ fn convert_path(prefix: Option, path: ast::Path) -> Option { let res = match segment.kind()? { ast::PathSegmentKind::Name(name) => { // no type args in use - let mut res = prefix.unwrap_or_else(|| Path { - kind: PathKind::Plain, - type_ref: None, - segments: Vec::with_capacity(1), - }); + let mut res = prefix + .unwrap_or_else(|| Path { kind: PathKind::Plain, segments: Vec::with_capacity(1) }); res.segments.push(PathSegment { name: name.as_name(), args_and_bindings: None, // no type args in use -- cgit v1.2.3