Skip to content

Commit

Permalink
Rollup merge of rust-lang#75985 - csmoe:issue-61076-1, r=estebank
Browse files Browse the repository at this point in the history
Should not apply field accessing on enum

Closes rust-lang#75977
But I'm surprised that `x.py test --stage 1` and CI didn't catch this with existing testcase.
r? @estebank
  • Loading branch information
Dylan-DPC committed Aug 29, 2020
2 parents 5ee0755 + b71c8b6 commit d62a324
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/librustc_typeck/check/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1545,13 +1545,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
normalized_ty.kind,
);
if let ty::Adt(def, _) = normalized_ty.kind {
if def.non_enum_variant().fields.iter().any(|field| field.ident == field_ident) {
err.span_suggestion_verbose(
base.span.shrink_to_hi(),
"consider awaiting before field access",
".await".to_string(),
Applicability::MaybeIncorrect,
);
// no field access on enum type
if !def.is_enum() {
if def.non_enum_variant().fields.iter().any(|field| field.ident == field_ident)
{
err.span_suggestion_verbose(
base.span.shrink_to_hi(),
"consider awaiting before field access",
".await".to_string(),
Applicability::MaybeIncorrect,
);
}
}
}
}
Expand Down

0 comments on commit d62a324

Please sign in to comment.