Skip to content

Commit e23290f

Browse files
authored
Rollup merge of #75985 - csmoe:issue-61076-1, r=estebank
Should not apply field accessing on enum Closes #75977 But I'm surprised that `x.py test --stage 1` and CI didn't catch this with existing testcase. r? @estebank
2 parents 72c8fb4 + b71c8b6 commit e23290f

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/librustc_typeck/check/expr.rs

+11-7
Original file line numberDiff line numberDiff line change
@@ -1545,13 +1545,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
15451545
normalized_ty.kind,
15461546
);
15471547
if let ty::Adt(def, _) = normalized_ty.kind {
1548-
if def.non_enum_variant().fields.iter().any(|field| field.ident == field_ident) {
1549-
err.span_suggestion_verbose(
1550-
base.span.shrink_to_hi(),
1551-
"consider awaiting before field access",
1552-
".await".to_string(),
1553-
Applicability::MaybeIncorrect,
1554-
);
1548+
// no field access on enum type
1549+
if !def.is_enum() {
1550+
if def.non_enum_variant().fields.iter().any(|field| field.ident == field_ident)
1551+
{
1552+
err.span_suggestion_verbose(
1553+
base.span.shrink_to_hi(),
1554+
"consider awaiting before field access",
1555+
".await".to_string(),
1556+
Applicability::MaybeIncorrect,
1557+
);
1558+
}
15551559
}
15561560
}
15571561
}

0 commit comments

Comments
 (0)