Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/rustc_parse/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1656,8 +1656,8 @@ pub(crate) enum ExpectedSemiSugg {
style = "short"
)]
ChangeToSemi(#[primary_span] Span),
#[suggestion("add `;` here", code = ";", applicability = "machine-applicable", style = "short")]
AddSemi(#[primary_span] Span),
#[suggestion("add `;` here", code = ";", style = "short")]
AddSemi(#[primary_span] Span, #[applicability] Applicability),
}

#[derive(Diagnostic)]
Expand Down
10 changes: 6 additions & 4 deletions compiler/rustc_parse/src/parser/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ impl<'a> Parser<'a> {
span,
token: self.token,
unexpected_token_label: Some(self.token.span),
sugg: ExpectedSemiSugg::AddSemi(span),
sugg: ExpectedSemiSugg::AddSemi(span, Applicability::MachineApplicable),
});
return Ok(guar);
}
Expand Down Expand Up @@ -723,7 +723,8 @@ impl<'a> Parser<'a> {
span,
token: self.token,
unexpected_token_label: Some(self.token.span),
sugg: ExpectedSemiSugg::AddSemi(span),
// A semicolon may discard the intended return value of a cfg-gated tail expression.
sugg: ExpectedSemiSugg::AddSemi(span, Applicability::MaybeIncorrect),
});
let attr_span = match &expr.attrs[..] {
[] => unreachable!(),
Expand Down Expand Up @@ -755,7 +756,7 @@ impl<'a> Parser<'a> {
(expr.span.shrink_to_lo(), "{ ".to_string()),
(expr.span.shrink_to_hi(), " }".to_string()),
],
Applicability::MachineApplicable,
Applicability::MaybeIncorrect,
);

// Special handling for `#[cfg(...)]` chains
Expand Down Expand Up @@ -811,7 +812,8 @@ impl<'a> Parser<'a> {
"it seems like you are trying to provide different expressions depending on \
`cfg`, consider using `if cfg!(..)`",
sugg,
Applicability::MachineApplicable,
// Unlike `#[cfg]`, `if cfg!` still checks disabled branches.
Applicability::MaybeIncorrect,
);
}
}
Expand Down
Loading