From d4ed25d86fdec0ce47199c262af62213b62e4863 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 23 Jan 2019 18:26:02 +0300 Subject: introduced better typed AstPtr --- crates/ra_hir/src/nameres/lower.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'crates/ra_hir/src/nameres/lower.rs') diff --git a/crates/ra_hir/src/nameres/lower.rs b/crates/ra_hir/src/nameres/lower.rs index ab6f3a9bc..921ba3c98 100644 --- a/crates/ra_hir/src/nameres/lower.rs +++ b/crates/ra_hir/src/nameres/lower.rs @@ -1,10 +1,10 @@ use std::sync::Arc; use ra_syntax::{ - SyntaxKind, AstNode, SourceFile, TreeArc, SyntaxNodePtr, + SyntaxKind, AstNode, SourceFile, TreeArc, AstPtr, ast::{self, ModuleItemOwner}, }; -use ra_db::{SourceRootId}; +use ra_db::SourceRootId; use ra_arena::{Arena, RawId, impl_arena_id, map::ArenaMap}; use crate::{ @@ -72,13 +72,12 @@ pub struct LoweredModule { #[derive(Debug, Default, PartialEq, Eq)] pub struct ImportSourceMap { - map: ArenaMap, + map: ArenaMap>, } impl ImportSourceMap { fn insert(&mut self, import: ImportId, segment: &ast::PathSegment) { - self.map - .insert(import, SyntaxNodePtr::new(segment.syntax())) + self.map.insert(import, AstPtr::new(segment)) } pub fn get(&self, source: &ModuleSource, import: ImportId) -> TreeArc { @@ -87,9 +86,7 @@ impl ImportSourceMap { ModuleSource::Module(m) => m.syntax().ancestors().find_map(SourceFile::cast).unwrap(), }; - ast::PathSegment::cast(self.map[import].to_node(file)) - .unwrap() - .to_owned() + self.map[import].to_node(file).to_owned() } } -- cgit v1.2.3