Skip to content

Commit 670d1a1

Browse files
committed
more updates on parser
1 parent 46c8b80 commit 670d1a1

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

compiler/rustc_parse/src/errors.rs

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,28 +1305,29 @@ impl<'a> IntoDiagnostic<'a> for ExpectedSemi {
13051305
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'a> {
13061306
let token_descr = TokenDescription::from_token(&self.token);
13071307

1308-
let mut diag = DiagnosticBuilder::new(
1309-
dcx,
1310-
level,
1311-
match token_descr {
1312-
Some(TokenDescription::ReservedIdentifier) => {
1313-
fluent::parse_expected_semi_found_reserved_identifier_str
1314-
}
1315-
Some(TokenDescription::Keyword) => fluent::parse_expected_semi_found_keyword_str,
1316-
Some(TokenDescription::ReservedKeyword) => {
1317-
fluent::parse_expected_semi_found_reserved_keyword_str
1318-
}
1319-
Some(TokenDescription::DocComment) => {
1320-
fluent::parse_expected_semi_found_doc_comment_str
1321-
}
1322-
None => fluent::parse_expected_semi_found_str,
1323-
},
1324-
);
1308+
let mut diag = handler.struct_diagnostic(match token_descr {
1309+
Some(TokenDescription::ReservedIdentifier) => DiagnosticMessage::Str(Cow::from(
1310+
"expected `;`, found reserved identifier `{$token}`",
1311+
)),
1312+
Some(TokenDescription::Keyword) => {
1313+
DiagnosticMessage::Str(Cow::from("expected `;`, found keyword `{$token}`"))
1314+
}
1315+
Some(TokenDescription::ReservedKeyword) => {
1316+
DiagnosticMessage::Str(Cow::from("expected `;`, found reserved keyword `{$token}`"))
1317+
}
1318+
Some(TokenDescription::DocComment) => {
1319+
DiagnosticMessage::Str(Cow::from("expected `;`, found doc comment `{$token}`"))
1320+
}
1321+
None => DiagnosticMessage::Str(Cow::from("expected `;`, found `{$token}`")),
1322+
});
13251323
diag.set_span(self.span);
13261324
diag.set_arg("token", self.token);
13271325

13281326
if let Some(unexpected_token_label) = self.unexpected_token_label {
1329-
diag.span_label(unexpected_token_label, fluent::parse_label_unexpected_token);
1327+
diag.span_label(
1328+
unexpected_token_label,
1329+
DiagnosticMessage::Str(Cow::from("unexpected token")),
1330+
);
13301331
}
13311332

13321333
self.sugg.add_to_diagnostic(&mut diag);

0 commit comments

Comments
 (0)