From 230c763648ad87e07d843a52c134b12d1b7397f4 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Tue, 6 Apr 2021 19:44:28 +0200 Subject: infer: remove `record_pat_field_resolutions` field Same as https://github.com/rust-analyzer/rust-analyzer/pull/8376, this can be computed from other data --- crates/hir/src/source_analyzer.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'crates/hir/src') 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 { pub(crate) fn resolve_record_pat_field( &self, - _db: &dyn HirDatabase, + db: &dyn HirDatabase, field: &ast::RecordPatField, ) -> Option { - let pat_id = self.pat_id(&field.pat()?)?; - let struct_field = self.infer.as_ref()?.record_pat_field_resolution(pat_id)?; - Some(struct_field.into()) + let field_name = field.field_name()?.as_name(); + let record_pat = ast::RecordPat::cast(field.syntax().parent().and_then(|p| p.parent())?)?; + let pat_id = self.pat_id(&record_pat.into())?; + let variant = self.infer.as_ref()?.variant_resolution_for_pat(pat_id)?; + let variant_data = variant.variant_data(db.upcast()); + let field = FieldId { parent: variant, local_id: variant_data.field(&field_name)? }; + Some(field.into()) } pub(crate) fn resolve_macro_call( -- cgit v1.2.3