|
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, EmissionGuarantee, 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 { |
@@ -1205,18 +1204,22 @@ impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for ExpectedIdentifier { |
1205 | 1204 |
|
1206 | 1205 | let mut diag = handler.struct_diagnostic(match token_descr { |
1207 | 1206 | Some(TokenDescription::ReservedIdentifier) => { |
1208 | | - "expected identifier, found reserved identifier `{$token}`" |
| 1207 | + fluent_raw!("expected identifier, found reserved identifier `{$token}`") |
1209 | 1208 | } |
1210 | | - Some(TokenDescription::Keyword) => "expected identifier, found keyword `{$token}`", |
| 1209 | + Some(TokenDescription::Keyword) => { |
| 1210 | + fluent_raw!("expected identifier, found keyword `{$token}`") |
| 1211 | + } |
| 1212 | + |
1211 | 1213 | Some(TokenDescription::ReservedKeyword) => { |
1212 | | - "expected identifier, found reserved keyword `{$token}`" |
| 1214 | + fluent_raw!("expected identifier, found reserved keyword `{$token}`") |
1213 | 1215 | } |
1214 | 1216 |
|
1215 | 1217 | Some(TokenDescription::DocComment) => { |
1216 | | - "expected identifier, found doc comment `{$token}`" |
| 1218 | + fluent_raw!("expected identifier, found doc comment `{$token}`") |
| 1219 | + } |
| 1220 | + None => { |
| 1221 | + fluent_raw!("expected identifier, found `{$token}`") |
1217 | 1222 | } |
1218 | | - |
1219 | | - None => "expected identifier, found `{$token}`", |
1220 | 1223 | }); |
1221 | 1224 | diag.set_span(self.span); |
1222 | 1225 | diag.set_arg("token", self.token); |
@@ -1264,14 +1267,18 @@ impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for ExpectedSemi { |
1264 | 1267 |
|
1265 | 1268 | let mut diag = handler.struct_diagnostic(match token_descr { |
1266 | 1269 | Some(TokenDescription::ReservedIdentifier) => { |
1267 | | - "expected `;`, found reserved identifier `{$token}`" |
| 1270 | + fluent_raw!("expected `;`, found reserved identifier `{$token}`") |
| 1271 | + } |
| 1272 | + Some(TokenDescription::Keyword) => { |
| 1273 | + fluent_raw!("expected `;`, found keyword `{$token}`") |
1268 | 1274 | } |
1269 | | - Some(TokenDescription::Keyword) => "expected `;`, found keyword `{$token}`", |
1270 | 1275 | Some(TokenDescription::ReservedKeyword) => { |
1271 | | - "expected `;`, found reserved keyword `{$token}`" |
| 1276 | + fluent_raw!("expected `;`, found reserved keyword `{$token}`") |
| 1277 | + } |
| 1278 | + Some(TokenDescription::DocComment) => { |
| 1279 | + fluent_raw!("expected `;`, found doc comment `{$token}`") |
1272 | 1280 | } |
1273 | | - Some(TokenDescription::DocComment) => "expected `;`, found doc comment `{$token}`", |
1274 | | - None => "expected `;`, found `{$token}`", |
| 1281 | + None => fluent_raw!("expected `;`, found `{$token}`"), |
1275 | 1282 | }); |
1276 | 1283 | diag.set_span(self.span); |
1277 | 1284 | diag.set_arg("token", self.token); |
|
0 commit comments