hir_ty: don't call write_field_resolution when field candidate isn't visible
This commit is contained in:
parent
96c88680b2
commit
7155f815b9
@ -459,9 +459,8 @@ fn infer_expr_inner(&mut self, tgt_expr: ExprId, expected: &Expectation) -> Ty {
|
||||
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 @@ fn infer_expr_inner(&mut self, tgt_expr: ExprId, expected: &Expectation) -> Ty {
|
||||
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()
|
||||
|
Loading…
Reference in New Issue
Block a user