From 7155f815b96fbc1de5816e3954c4c03c43e709c9 Mon Sep 17 00:00:00 2001 From: cynecx Date: Wed, 24 Mar 2021 23:03:30 +0100 Subject: hir_ty: don't call write_field_resolution when field candidate isn't visible --- crates/hir_ty/src/infer/expr.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'crates') diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs index b08880cdf..46d713a7b 100644 --- a/crates/hir_ty/src/infer/expr.rs +++ b/crates/hir_ty/src/infer/expr.rs @@ -459,9 +459,8 @@ impl<'a> InferenceContext<'a> { TyKind::Adt(AdtId(hir_def::AdtId::StructId(s)), parameters) => { let local_id = self.db.struct_data(*s).variant_data.field(name)?; let field = FieldId { parent: (*s).into(), local_id }; - let is_visible_in_ctx = is_visible(&field); - self.write_field_resolution(tgt_expr, field); - if is_visible_in_ctx { + if is_visible(&field) { + self.write_field_resolution(tgt_expr, field); Some( self.db.field_types((*s).into())[field.local_id] .clone() @@ -474,9 +473,8 @@ impl<'a> InferenceContext<'a> { TyKind::Adt(AdtId(hir_def::AdtId::UnionId(u)), parameters) => { let local_id = self.db.union_data(*u).variant_data.field(name)?; let field = FieldId { parent: (*u).into(), local_id }; - let is_visible_in_ctx = is_visible(&field); - self.write_field_resolution(tgt_expr, field); - if is_visible_in_ctx { + if is_visible(&field) { + self.write_field_resolution(tgt_expr, field); Some( self.db.field_types((*u).into())[field.local_id] .clone() -- cgit v1.2.3