diff options
author | cynecx <[email protected]> | 2021-03-24 22:03:30 +0000 |
---|---|---|
committer | cynecx <[email protected]> | 2021-03-24 22:03:38 +0000 |
commit | 7155f815b96fbc1de5816e3954c4c03c43e709c9 (patch) | |
tree | a5f97cab5b73ff0c9895d4d957f2a7bfc7026cb7 /crates | |
parent | 96c88680b2d680f42809f838e79213e087d1fa1c (diff) |
hir_ty: don't call write_field_resolution when field candidate isn't visible
Diffstat (limited to 'crates')
-rw-r--r-- | crates/hir_ty/src/infer/expr.rs | 10 |
1 files changed, 4 insertions, 6 deletions
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> { | |||
459 | TyKind::Adt(AdtId(hir_def::AdtId::StructId(s)), parameters) => { | 459 | TyKind::Adt(AdtId(hir_def::AdtId::StructId(s)), parameters) => { |
460 | let local_id = self.db.struct_data(*s).variant_data.field(name)?; | 460 | let local_id = self.db.struct_data(*s).variant_data.field(name)?; |
461 | let field = FieldId { parent: (*s).into(), local_id }; | 461 | let field = FieldId { parent: (*s).into(), local_id }; |
462 | let is_visible_in_ctx = is_visible(&field); | 462 | if is_visible(&field) { |
463 | self.write_field_resolution(tgt_expr, field); | 463 | self.write_field_resolution(tgt_expr, field); |
464 | if is_visible_in_ctx { | ||
465 | Some( | 464 | Some( |
466 | self.db.field_types((*s).into())[field.local_id] | 465 | self.db.field_types((*s).into())[field.local_id] |
467 | .clone() | 466 | .clone() |
@@ -474,9 +473,8 @@ impl<'a> InferenceContext<'a> { | |||
474 | TyKind::Adt(AdtId(hir_def::AdtId::UnionId(u)), parameters) => { | 473 | TyKind::Adt(AdtId(hir_def::AdtId::UnionId(u)), parameters) => { |
475 | let local_id = self.db.union_data(*u).variant_data.field(name)?; | 474 | let local_id = self.db.union_data(*u).variant_data.field(name)?; |
476 | let field = FieldId { parent: (*u).into(), local_id }; | 475 | let field = FieldId { parent: (*u).into(), local_id }; |
477 | let is_visible_in_ctx = is_visible(&field); | 476 | if is_visible(&field) { |
478 | self.write_field_resolution(tgt_expr, field); | 477 | self.write_field_resolution(tgt_expr, field); |
479 | if is_visible_in_ctx { | ||
480 | Some( | 478 | Some( |
481 | self.db.field_types((*u).into())[field.local_id] | 479 | self.db.field_types((*u).into())[field.local_id] |
482 | .clone() | 480 | .clone() |