Minor improvement on else-no-if diagnostic

This commit is contained in:
Michael Goulet 2022-05-24 14:14:41 -07:00
parent fa70b89d19
commit d61d30d9a2
2 changed files with 3 additions and 18 deletions

View file

@ -2291,16 +2291,9 @@ impl<'a> Parser<'a> {
.span_label(else_span, "expected an `if` or a block after this `else`")
.span_suggestion(
cond.span.shrink_to_lo(),
"add an `if` if this is the condition to an chained `if` statement after the `else`",
"add an `if` if this is the condition of a chained `else if` statement",
"if ".to_string(),
Applicability::MaybeIncorrect,
).multipart_suggestion(
"... otherwise, place this expression inside of a block if it is not an `if` condition",
vec![
(cond.span.shrink_to_lo(), "{ ".to_string()),
(cond.span.shrink_to_hi(), " }".to_string()),
],
Applicability::MaybeIncorrect,
)
.emit();
self.parse_if_after_cond(AttrVec::new(), cond.span.shrink_to_lo(), cond)?