From ade0176c20f7e4159a0cb81ae8034acacc915310 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 26 Feb 2020 13:24:46 +0100 Subject: Remove dead code --- crates/ra_hir/src/lib.rs | 2 +- crates/ra_hir/src/source_analyzer.rs | 32 ++++++++------------------------ 2 files changed, 9 insertions(+), 25 deletions(-) (limited to 'crates/ra_hir') diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs index 004a2185f..4a85e7e36 100644 --- a/crates/ra_hir/src/lib.rs +++ b/crates/ra_hir/src/lib.rs @@ -47,7 +47,7 @@ pub use crate::{ }, has_source::HasSource, semantics::{original_range, Semantics, SemanticsScope}, - source_analyzer::{PathResolution, ScopeEntryWithSyntax}, + source_analyzer::PathResolution, }; pub use hir_def::{ diff --git a/crates/ra_hir/src/source_analyzer.rs b/crates/ra_hir/src/source_analyzer.rs index bff1ecd14..b655e2c32 100644 --- a/crates/ra_hir/src/source_analyzer.rs +++ b/crates/ra_hir/src/source_analyzer.rs @@ -25,8 +25,8 @@ use ra_syntax::{ }; use crate::{ - db::HirDatabase, Adt, Const, EnumVariant, Function, Local, MacroDef, Name, Path, Static, - Struct, Trait, Type, TypeAlias, TypeParam, + db::HirDatabase, Adt, Const, EnumVariant, Function, Local, MacroDef, Path, Static, Struct, + Trait, Type, TypeAlias, TypeParam, }; /// `SourceAnalyzer` is a convenience wrapper which exposes HIR API in terms of @@ -53,22 +53,6 @@ pub enum PathResolution { AssocItem(crate::AssocItem), } -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct ScopeEntryWithSyntax { - pub(crate) name: Name, - pub(crate) ptr: Either, AstPtr>, -} - -impl ScopeEntryWithSyntax { - pub fn name(&self) -> &Name { - &self.name - } - - pub fn ptr(&self) -> Either, AstPtr> { - self.ptr - } -} - #[derive(Debug)] pub struct ReferenceDescriptor { pub range: TextRange, @@ -235,16 +219,16 @@ impl SourceAnalyzer { resolve_hir_path(db, &self.resolver, &hir_path) } - fn resolve_local_name(&self, name_ref: &ast::NameRef) -> Option { + fn resolve_local_name( + &self, + name_ref: &ast::NameRef, + ) -> Option, AstPtr>> { let name = name_ref.as_name(); let source_map = self.body_source_map.as_ref()?; let scopes = self.scopes.as_ref()?; let scope = scope_for(scopes, source_map, InFile::new(self.file_id, name_ref.syntax()))?; let entry = scopes.resolve_name_in_scope(scope, &name)?; - Some(ScopeEntryWithSyntax { - name: entry.name().clone(), - ptr: source_map.pat_syntax(entry.pat())?.value, - }) + Some(source_map.pat_syntax(entry.pat())?.value) } // FIXME: we only use this in `inline_local_variable` assist, ideally, we @@ -258,7 +242,7 @@ impl SourceAnalyzer { .filter_map(ast::NameRef::cast) .filter(|name_ref| match self.resolve_local_name(&name_ref) { None => false, - Some(entry) => entry.ptr() == ptr, + Some(d_ptr) => d_ptr == ptr, }) .map(|name_ref| ReferenceDescriptor { name: name_ref.text().to_string(), -- cgit v1.2.3