diff options
| author | bors <bors@rust-lang.org> | 2020-08-29 10:07:05 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-08-29 10:07:05 +0000 |
| commit | 65d071eeb52eba78896dd09b95a80c647ef150e9 (patch) | |
| tree | 58f6c0ce1d1a647081b0ab8c2d60c3f068a980c9 | |
| parent | 1dc748fb3d2c54f536e6abd74f1ad34b3624f640 (diff) | |
| parent | b71c8b64b5f1609ca68c4a84fb3b28cb17b6f25c (diff) | |
| download | rust-65d071eeb52eba78896dd09b95a80c647ef150e9.tar.gz rust-65d071eeb52eba78896dd09b95a80c647ef150e9.zip | |
Auto 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
| -rw-r--r-- | src/librustc_typeck/check/expr.rs | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/librustc_typeck/check/expr.rs b/src/librustc_typeck/check/expr.rs index ad4418ddca7..1573fb96791 100644 --- a/src/librustc_typeck/check/expr.rs +++ b/src/librustc_typeck/check/expr.rs @@ -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, + ); + } } } } |
