should not try to apply field accessing on enum

This commit is contained in:
csmoe 2020-08-27 22:01:52 +08:00
parent 7cfcefd1fb
commit b71c8b64b5

View File

@ -1545,13 +1545,17 @@ fn suggest_await_on_field_access(
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,
);
}
}
}
}