diff options
author | Aleksey Kladov <[email protected]> | 2019-11-24 12:13:56 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-11-24 12:18:12 +0000 |
commit | e0b06cb672b7aae770fea24e4a5efdbec8cbf5c6 (patch) | |
tree | 8623aa0e20f91374ad8d10a6fb1d807274dee5e8 /crates/ra_hir/src/source_binder.rs | |
parent | 982a32aca317deb91ae03346cbc7880bd7d4429b (diff) |
Switch to StaticLoc for statics
Diffstat (limited to 'crates/ra_hir/src/source_binder.rs')
-rw-r--r-- | crates/ra_hir/src/source_binder.rs | 12 |
1 files changed, 4 insertions, 8 deletions
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::{ | |||
11 | expr::{ExprId, PatId}, | 11 | expr::{ExprId, PatId}, |
12 | path::known, | 12 | path::known, |
13 | resolver::{self, resolver_for_scope, HasResolver, Resolver, TypeNs, ValueNs}, | 13 | resolver::{self, resolver_for_scope, HasResolver, Resolver, TypeNs, ValueNs}, |
14 | DefWithBodyId, LocationCtx, | 14 | DefWithBodyId, |
15 | }; | 15 | }; |
16 | use hir_expand::{ | 16 | use hir_expand::{ |
17 | name::AsName, AstId, HirFileId, MacroCallId, MacroCallLoc, MacroFileKind, Source, | 17 | name::AsName, AstId, HirFileId, MacroCallId, MacroCallLoc, MacroFileKind, Source, |
@@ -28,8 +28,8 @@ use crate::{ | |||
28 | expr::{BodySourceMap, ExprScopes, ScopeId}, | 28 | expr::{BodySourceMap, ExprScopes, ScopeId}, |
29 | ty::method_resolution::{self, implements_trait}, | 29 | ty::method_resolution::{self, implements_trait}, |
30 | Adt, AssocItem, Const, DefWithBody, Either, Enum, EnumVariant, FromSource, Function, | 30 | Adt, AssocItem, Const, DefWithBody, Either, Enum, EnumVariant, FromSource, Function, |
31 | GenericParam, HasBody, Local, MacroDef, Module, Name, Path, ScopeDef, Static, Struct, Trait, | 31 | GenericParam, HasBody, Local, MacroDef, Name, Path, ScopeDef, Static, Struct, Trait, Ty, |
32 | Ty, TypeAlias, | 32 | TypeAlias, |
33 | }; | 33 | }; |
34 | 34 | ||
35 | fn try_get_resolver_for_node(db: &impl HirDatabase, node: Source<&SyntaxNode>) -> Option<Resolver> { | 35 | fn try_get_resolver_for_node(db: &impl HirDatabase, node: Source<&SyntaxNode>) -> Option<Resolver> { |
@@ -68,16 +68,12 @@ fn def_with_body_from_child_node( | |||
68 | db: &impl HirDatabase, | 68 | db: &impl HirDatabase, |
69 | child: Source<&SyntaxNode>, | 69 | child: Source<&SyntaxNode>, |
70 | ) -> Option<DefWithBody> { | 70 | ) -> Option<DefWithBody> { |
71 | let module_source = crate::ModuleSource::from_child_node(db, child); | ||
72 | let module = Module::from_definition(db, Source::new(child.file_id, module_source))?; | ||
73 | let ctx = LocationCtx::new(db, module.id, child.file_id); | ||
74 | |||
75 | child.value.ancestors().find_map(|node| { | 71 | child.value.ancestors().find_map(|node| { |
76 | match_ast! { | 72 | match_ast! { |
77 | match node { | 73 | match node { |
78 | ast::FnDef(def) => { return Function::from_source(db, child.with_value(def)).map(DefWithBody::from); }, | 74 | ast::FnDef(def) => { return Function::from_source(db, child.with_value(def)).map(DefWithBody::from); }, |
79 | ast::ConstDef(def) => { return Const::from_source(db, child.with_value(def)).map(DefWithBody::from); }, | 75 | ast::ConstDef(def) => { return Const::from_source(db, child.with_value(def)).map(DefWithBody::from); }, |
80 | ast::StaticDef(def) => { Some(Static { id: ctx.to_def(&def) }.into()) }, | 76 | ast::StaticDef(def) => { return Static::from_source(db, child.with_value(def)).map(DefWithBody::from); }, |
81 | _ => { None }, | 77 | _ => { None }, |
82 | } | 78 | } |
83 | } | 79 | } |