diff options
| author | csmoe <csmoe@msn.com> | 2020-08-27 22:01:52 +0800 |
|---|---|---|
| committer | csmoe <csmoe@msn.com> | 2020-08-27 22:01:52 +0800 |
| commit | b71c8b64b5f1609ca68c4a84fb3b28cb17b6f25c (patch) | |
| tree | 0f1216bed289d9c9dccb94dd7ae156a9c2c21ca4 | |
| parent | 7cfcefd1fbbbfefbdc88feb7359e6364d7c0bf8a (diff) | |
| download | rust-b71c8b64b5f1609ca68c4a84fb3b28cb17b6f25c.tar.gz rust-b71c8b64b5f1609ca68c4a84fb3b28cb17b6f25c.zip | |
should not try to apply field accessing on enum
| -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 82ed8fda8b4..582357273d6 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, + ); + } } } } |
