make "custom attribute panicked" translatable
This commit is contained in:
parent
23a3d777c8
commit
61509914a3
3 changed files with 25 additions and 5 deletions
|
@ -22,6 +22,10 @@ expand_collapse_debuginfo_illegal =
|
|||
expand_count_repetition_misplaced =
|
||||
`count` can not be placed inside the inner-most repetition
|
||||
|
||||
expand_custom_attribute_panicked =
|
||||
custom attribute panicked
|
||||
.help = message: {$message}
|
||||
|
||||
expand_duplicate_matcher_binding = duplicate matcher binding
|
||||
.label = duplicate binding
|
||||
.label2 = previous binding
|
||||
|
|
|
@ -392,6 +392,21 @@ pub(crate) struct ProcMacroPanickedHelp {
|
|||
pub message: String,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(expand_custom_attribute_panicked)]
|
||||
pub(crate) struct CustomAttributePanicked {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
#[subdiagnostic]
|
||||
pub message: Option<CustomAttributePanickedHelp>,
|
||||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
#[help(expand_help)]
|
||||
pub(crate) struct CustomAttributePanickedHelp {
|
||||
pub message: String,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(expand_proc_macro_derive_tokens)]
|
||||
pub struct ProcMacroDeriveTokens {
|
||||
|
|
|
@ -93,11 +93,12 @@ impl base::AttrProcMacro for AttrProcMacro {
|
|||
let server = proc_macro_server::Rustc::new(ecx);
|
||||
self.client.run(&strategy, server, annotation, annotated, proc_macro_backtrace).map_err(
|
||||
|e| {
|
||||
let mut err = ecx.dcx().struct_span_err(span, "custom attribute panicked");
|
||||
if let Some(s) = e.as_str() {
|
||||
err.help(format!("message: {s}"));
|
||||
}
|
||||
err.emit()
|
||||
ecx.dcx().emit_err(errors::CustomAttributePanicked {
|
||||
span,
|
||||
message: e.as_str().map(|message| errors::CustomAttributePanickedHelp {
|
||||
message: message.into(),
|
||||
}),
|
||||
})
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue