diff options
Diffstat (limited to 'crates/ra_hir/src/source_binder.rs')
-rw-r--r-- | crates/ra_hir/src/source_binder.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs index d326169b3..85b378483 100644 --- a/crates/ra_hir/src/source_binder.rs +++ b/crates/ra_hir/src/source_binder.rs | |||
@@ -26,6 +26,7 @@ use hir_ty::{ | |||
26 | method_resolution::{self, implements_trait}, | 26 | method_resolution::{self, implements_trait}, |
27 | Canonical, InEnvironment, InferenceResult, TraitEnvironment, Ty, | 27 | Canonical, InEnvironment, InferenceResult, TraitEnvironment, Ty, |
28 | }; | 28 | }; |
29 | use ra_prof::profile; | ||
29 | use ra_syntax::{ | 30 | use ra_syntax::{ |
30 | ast::{self, AstNode}, | 31 | ast::{self, AstNode}, |
31 | match_ast, AstPtr, | 32 | match_ast, AstPtr, |
@@ -83,6 +84,7 @@ fn def_with_body_from_child_node( | |||
83 | db: &impl HirDatabase, | 84 | db: &impl HirDatabase, |
84 | child: InFile<&SyntaxNode>, | 85 | child: InFile<&SyntaxNode>, |
85 | ) -> Option<DefWithBody> { | 86 | ) -> Option<DefWithBody> { |
87 | let _p = profile("def_with_body_from_child_node"); | ||
86 | child.cloned().ancestors_with_macros(db).find_map(|node| { | 88 | child.cloned().ancestors_with_macros(db).find_map(|node| { |
87 | let n = &node.value; | 89 | let n = &node.value; |
88 | match_ast! { | 90 | match_ast! { |
@@ -169,6 +171,7 @@ impl SourceAnalyzer { | |||
169 | node: InFile<&SyntaxNode>, | 171 | node: InFile<&SyntaxNode>, |
170 | offset: Option<TextUnit>, | 172 | offset: Option<TextUnit>, |
171 | ) -> SourceAnalyzer { | 173 | ) -> SourceAnalyzer { |
174 | let _p = profile("SourceAnalyzer::new"); | ||
172 | let def_with_body = def_with_body_from_child_node(db, node); | 175 | let def_with_body = def_with_body_from_child_node(db, node); |
173 | if let Some(def) = def_with_body { | 176 | if let Some(def) = def_with_body { |
174 | let (_body, source_map) = db.body_with_source_map(def.into()); | 177 | let (_body, source_map) = db.body_with_source_map(def.into()); |
@@ -237,7 +240,13 @@ impl SourceAnalyzer { | |||
237 | } | 240 | } |
238 | 241 | ||
239 | pub fn resolve_record_field(&self, field: &ast::RecordField) -> Option<crate::StructField> { | 242 | pub fn resolve_record_field(&self, field: &ast::RecordField) -> Option<crate::StructField> { |
240 | let expr_id = self.expr_id(&field.expr()?)?; | 243 | let expr_id = match field.expr() { |
244 | Some(it) => self.expr_id(&it)?, | ||
245 | None => { | ||
246 | let src = InFile { file_id: self.file_id, value: field }; | ||
247 | self.body_source_map.as_ref()?.field_init_shorthand_expr(src)? | ||
248 | } | ||
249 | }; | ||
241 | self.infer.as_ref()?.record_field_resolution(expr_id).map(|it| it.into()) | 250 | self.infer.as_ref()?.record_field_resolution(expr_id).map(|it| it.into()) |
242 | } | 251 | } |
243 | 252 | ||