From e0b06cb672b7aae770fea24e4a5efdbec8cbf5c6 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 24 Nov 2019 15:13:56 +0300 Subject: Switch to StaticLoc for statics --- crates/ra_hir/src/source_binder.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'crates/ra_hir/src/source_binder.rs') diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs index 0a836c913..cfc4bd326 100644 --- a/crates/ra_hir/src/source_binder.rs +++ b/crates/ra_hir/src/source_binder.rs @@ -11,7 +11,7 @@ use hir_def::{ expr::{ExprId, PatId}, path::known, resolver::{self, resolver_for_scope, HasResolver, Resolver, TypeNs, ValueNs}, - DefWithBodyId, LocationCtx, + DefWithBodyId, }; use hir_expand::{ name::AsName, AstId, HirFileId, MacroCallId, MacroCallLoc, MacroFileKind, Source, @@ -28,8 +28,8 @@ use crate::{ expr::{BodySourceMap, ExprScopes, ScopeId}, ty::method_resolution::{self, implements_trait}, Adt, AssocItem, Const, DefWithBody, Either, Enum, EnumVariant, FromSource, Function, - GenericParam, HasBody, Local, MacroDef, Module, Name, Path, ScopeDef, Static, Struct, Trait, - Ty, TypeAlias, + GenericParam, HasBody, Local, MacroDef, Name, Path, ScopeDef, Static, Struct, Trait, Ty, + TypeAlias, }; fn try_get_resolver_for_node(db: &impl HirDatabase, node: Source<&SyntaxNode>) -> Option { @@ -68,16 +68,12 @@ fn def_with_body_from_child_node( db: &impl HirDatabase, child: Source<&SyntaxNode>, ) -> Option { - let module_source = crate::ModuleSource::from_child_node(db, child); - let module = Module::from_definition(db, Source::new(child.file_id, module_source))?; - let ctx = LocationCtx::new(db, module.id, child.file_id); - child.value.ancestors().find_map(|node| { match_ast! { match node { ast::FnDef(def) => { return Function::from_source(db, child.with_value(def)).map(DefWithBody::from); }, ast::ConstDef(def) => { return Const::from_source(db, child.with_value(def)).map(DefWithBody::from); }, - ast::StaticDef(def) => { Some(Static { id: ctx.to_def(&def) }.into()) }, + ast::StaticDef(def) => { return Static::from_source(db, child.with_value(def)).map(DefWithBody::from); }, _ => { None }, } } -- cgit v1.2.3