diff options
Diffstat (limited to 'crates/hir/src/source_analyzer.rs')
-rw-r--r-- | crates/hir/src/source_analyzer.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/crates/hir/src/source_analyzer.rs b/crates/hir/src/source_analyzer.rs index c013e78d9..ce6f3c008 100644 --- a/crates/hir/src/source_analyzer.rs +++ b/crates/hir/src/source_analyzer.rs | |||
@@ -185,12 +185,16 @@ impl SourceAnalyzer { | |||
185 | 185 | ||
186 | pub(crate) fn resolve_record_pat_field( | 186 | pub(crate) fn resolve_record_pat_field( |
187 | &self, | 187 | &self, |
188 | _db: &dyn HirDatabase, | 188 | db: &dyn HirDatabase, |
189 | field: &ast::RecordPatField, | 189 | field: &ast::RecordPatField, |
190 | ) -> Option<Field> { | 190 | ) -> Option<Field> { |
191 | let pat_id = self.pat_id(&field.pat()?)?; | 191 | let field_name = field.field_name()?.as_name(); |
192 | let struct_field = self.infer.as_ref()?.record_pat_field_resolution(pat_id)?; | 192 | let record_pat = ast::RecordPat::cast(field.syntax().parent().and_then(|p| p.parent())?)?; |
193 | Some(struct_field.into()) | 193 | let pat_id = self.pat_id(&record_pat.into())?; |
194 | let variant = self.infer.as_ref()?.variant_resolution_for_pat(pat_id)?; | ||
195 | let variant_data = variant.variant_data(db.upcast()); | ||
196 | let field = FieldId { parent: variant, local_id: variant_data.field(&field_name)? }; | ||
197 | Some(field.into()) | ||
194 | } | 198 | } |
195 | 199 | ||
196 | pub(crate) fn resolve_macro_call( | 200 | pub(crate) fn resolve_macro_call( |