|
1 | 1 | // ignore-tidy-filelength
|
2 | 2 | use std::borrow::Cow;
|
3 | 3 |
|
| 4 | +use crate::parser::{ForbiddenLetReason, TokenDescription}; |
4 | 5 | use rustc_ast::token::Token;
|
5 | 6 | use rustc_ast::{Path, Visibility};
|
6 |
| -use rustc_errors::DiagnosticMessage; |
| 7 | +use rustc_errors::{fluent_raw, DiagnosticMessage}; |
7 | 8 | use rustc_errors::{AddToDiagnostic, Applicability, ErrorGuaranteed, IntoDiagnostic};
|
8 | 9 | use rustc_macros::{Diagnostic, Subdiagnostic};
|
9 | 10 | use rustc_session::errors::ExprParenthesesNeeded;
|
10 | 11 | use rustc_span::edition::{Edition, LATEST_STABLE_EDITION};
|
11 | 12 | use rustc_span::symbol::Ident;
|
12 | 13 | use rustc_span::{Span, Symbol};
|
13 | 14 |
|
14 |
| -use crate::parser::{ForbiddenLetReason, TokenDescription}; |
15 |
| - |
16 | 15 | #[derive(Diagnostic)]
|
17 | 16 | #[diag("ambiguous `+` in a type")]
|
18 | 17 | pub(crate) struct AmbiguousPlus {
|
@@ -1246,18 +1245,22 @@ impl<'a> IntoDiagnostic<'a> for ExpectedIdentifier {
|
1246 | 1245 |
|
1247 | 1246 | let mut diag = handler.struct_diagnostic(match token_descr {
|
1248 | 1247 | Some(TokenDescription::ReservedIdentifier) => {
|
1249 |
| - "expected identifier, found reserved identifier `{$token}`" |
| 1248 | + fluent_raw!("expected identifier, found reserved identifier `{$token}`") |
1250 | 1249 | }
|
1251 |
| - Some(TokenDescription::Keyword) => "expected identifier, found keyword `{$token}`", |
| 1250 | + Some(TokenDescription::Keyword) => { |
| 1251 | + fluent_raw!("expected identifier, found keyword `{$token}`") |
| 1252 | + } |
| 1253 | + |
1252 | 1254 | Some(TokenDescription::ReservedKeyword) => {
|
1253 |
| - "expected identifier, found reserved keyword `{$token}`" |
| 1255 | + fluent_raw!("expected identifier, found reserved keyword `{$token}`") |
1254 | 1256 | }
|
1255 | 1257 |
|
1256 | 1258 | Some(TokenDescription::DocComment) => {
|
1257 |
| - "expected identifier, found doc comment `{$token}`" |
| 1259 | + fluent_raw!("expected identifier, found doc comment `{$token}`") |
| 1260 | + } |
| 1261 | + None => { |
| 1262 | + fluent_raw!("expected identifier, found `{$token}`") |
1258 | 1263 | }
|
1259 |
| - |
1260 |
| - None => "expected identifier, found `{$token}`", |
1261 | 1264 | });
|
1262 | 1265 | diag.set_span(self.span);
|
1263 | 1266 | diag.set_arg("token", self.token);
|
@@ -1305,14 +1308,18 @@ impl<'a> IntoDiagnostic<'a> for ExpectedSemi {
|
1305 | 1308 |
|
1306 | 1309 | let mut diag = handler.struct_diagnostic(match token_descr {
|
1307 | 1310 | Some(TokenDescription::ReservedIdentifier) => {
|
1308 |
| - "expected `;`, found reserved identifier `{$token}`" |
| 1311 | + fluent_raw!("expected `;`, found reserved identifier `{$token}`") |
| 1312 | + } |
| 1313 | + Some(TokenDescription::Keyword) => { |
| 1314 | + fluent_raw!("expected `;`, found keyword `{$token}`") |
1309 | 1315 | }
|
1310 |
| - Some(TokenDescription::Keyword) => "expected `;`, found keyword `{$token}`", |
1311 | 1316 | Some(TokenDescription::ReservedKeyword) => {
|
1312 |
| - "expected `;`, found reserved keyword `{$token}`" |
| 1317 | + fluent_raw!("expected `;`, found reserved keyword `{$token}`") |
| 1318 | + } |
| 1319 | + Some(TokenDescription::DocComment) => { |
| 1320 | + fluent_raw!("expected `;`, found doc comment `{$token}`") |
1313 | 1321 | }
|
1314 |
| - Some(TokenDescription::DocComment) => "expected `;`, found doc comment `{$token}`", |
1315 |
| - None => "expected `;`, found `{$token}`", |
| 1322 | + None => fluent_raw!("expected `;`, found `{$token}`"), |
1316 | 1323 | });
|
1317 | 1324 | diag.set_span(self.span);
|
1318 | 1325 | diag.set_arg("token", self.token);
|
|
0 commit comments