1
Fork 0

Rollup merge of #122773 - tshepang:make-expand-translatable, r=fee1-dead

make "expected paren or brace" error translatable
This commit is contained in:
Matthias Krüger 2024-03-21 12:05:07 +01:00 committed by GitHub
commit 8106b54290
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 16 additions and 3 deletions

View file

@ -448,3 +448,11 @@ pub struct InvalidFragmentSpecifier {
pub fragment: Ident,
pub help: String,
}
#[derive(Diagnostic)]
#[diag(expand_expected_paren_or_brace)]
pub struct ExpectedParenOrBrace<'a> {
#[primary_span]
pub span: Span,
pub token: Cow<'a, str>,
}

View file

@ -194,9 +194,11 @@ fn parse_tree<'a>(
}
Delimiter::Parenthesis => {}
_ => {
let tok = pprust::token_kind_to_string(&token::OpenDelim(delim));
let msg = format!("expected `(` or `{{`, found `{tok}`");
sess.dcx().span_err(delim_span.entire(), msg);
let token = pprust::token_kind_to_string(&token::OpenDelim(delim));
sess.dcx().emit_err(errors::ExpectedParenOrBrace {
span: delim_span.entire(),
token,
});
}
}
}