make "proc-macro derive panicked" translatable
This commit is contained in:
parent
61509914a3
commit
f68682fd48
3 changed files with 27 additions and 5 deletions
|
@ -114,6 +114,10 @@ expand_only_one_argument =
|
||||||
expand_only_one_word =
|
expand_only_one_word =
|
||||||
must only be one word
|
must only be one word
|
||||||
|
|
||||||
|
expand_proc_macro_derive_panicked =
|
||||||
|
proc-macro derive panicked
|
||||||
|
.help = message: {$message}
|
||||||
|
|
||||||
expand_proc_macro_derive_tokens =
|
expand_proc_macro_derive_tokens =
|
||||||
proc-macro derive produced unparsable tokens
|
proc-macro derive produced unparsable tokens
|
||||||
|
|
||||||
|
|
|
@ -392,6 +392,21 @@ pub(crate) struct ProcMacroPanickedHelp {
|
||||||
pub message: String,
|
pub message: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(expand_proc_macro_derive_panicked)]
|
||||||
|
pub(crate) struct ProcMacroDerivePanicked {
|
||||||
|
#[primary_span]
|
||||||
|
pub span: Span,
|
||||||
|
#[subdiagnostic]
|
||||||
|
pub message: Option<ProcMacroDerivePanickedHelp>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Subdiagnostic)]
|
||||||
|
#[help(expand_help)]
|
||||||
|
pub(crate) struct ProcMacroDerivePanickedHelp {
|
||||||
|
pub message: String,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(expand_custom_attribute_panicked)]
|
#[diag(expand_custom_attribute_panicked)]
|
||||||
pub(crate) struct CustomAttributePanicked {
|
pub(crate) struct CustomAttributePanicked {
|
||||||
|
|
|
@ -147,11 +147,14 @@ impl MultiItemModifier for DeriveProcMacro {
|
||||||
match self.client.run(&strategy, server, input, proc_macro_backtrace) {
|
match self.client.run(&strategy, server, input, proc_macro_backtrace) {
|
||||||
Ok(stream) => stream,
|
Ok(stream) => stream,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
let mut err = ecx.dcx().struct_span_err(span, "proc-macro derive panicked");
|
ecx.dcx().emit_err({
|
||||||
if let Some(s) = e.as_str() {
|
errors::ProcMacroDerivePanicked {
|
||||||
err.help(format!("message: {s}"));
|
span,
|
||||||
}
|
message: e.as_str().map(|message| {
|
||||||
err.emit();
|
errors::ProcMacroDerivePanickedHelp { message: message.into() }
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
});
|
||||||
return ExpandResult::Ready(vec![]);
|
return ExpandResult::Ready(vec![]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue