Skip to content

Commit 7155f81

Browse files
committed
hir_ty: don't call write_field_resolution when field candidate isn't visible
1 parent 96c8868 commit 7155f81

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

crates/hir_ty/src/infer/expr.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -459,9 +459,8 @@ impl<'a> InferenceContext<'a> {
459459
TyKind::Adt(AdtId(hir_def::AdtId::StructId(s)), parameters) => {
460460
let local_id = self.db.struct_data(*s).variant_data.field(name)?;
461461
let field = FieldId { parent: (*s).into(), local_id };
462-
let is_visible_in_ctx = is_visible(&field);
463-
self.write_field_resolution(tgt_expr, field);
464-
if is_visible_in_ctx {
462+
if is_visible(&field) {
463+
self.write_field_resolution(tgt_expr, field);
465464
Some(
466465
self.db.field_types((*s).into())[field.local_id]
467466
.clone()
@@ -474,9 +473,8 @@ impl<'a> InferenceContext<'a> {
474473
TyKind::Adt(AdtId(hir_def::AdtId::UnionId(u)), parameters) => {
475474
let local_id = self.db.union_data(*u).variant_data.field(name)?;
476475
let field = FieldId { parent: (*u).into(), local_id };
477-
let is_visible_in_ctx = is_visible(&field);
478-
self.write_field_resolution(tgt_expr, field);
479-
if is_visible_in_ctx {
476+
if is_visible(&field) {
477+
self.write_field_resolution(tgt_expr, field);
480478
Some(
481479
self.db.field_types((*u).into())[field.local_id]
482480
.clone()

0 commit comments

Comments
 (0)