Rollup merge of #108436 - tshepang:translatable-proc-macro-panicked, r=estebank
make "proc macro panicked" translatable
This commit is contained in:
commit
9631f4b5c9
@ -129,3 +129,7 @@ expand_module_multiple_candidates =
|
|||||||
.help = delete or rename one of them to remove the ambiguity
|
.help = delete or rename one of them to remove the ambiguity
|
||||||
|
|
||||||
expand_trace_macro = trace_macro
|
expand_trace_macro = trace_macro
|
||||||
|
|
||||||
|
expand_proc_macro_panicked =
|
||||||
|
proc macro panicked
|
||||||
|
.help = message: {$message}
|
||||||
|
@ -375,3 +375,18 @@ pub struct TraceMacro {
|
|||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(expand_proc_macro_panicked)]
|
||||||
|
pub(crate) struct ProcMacroPanicked {
|
||||||
|
#[primary_span]
|
||||||
|
pub span: Span,
|
||||||
|
#[subdiagnostic]
|
||||||
|
pub message: Option<ProcMacroPanickedHelp>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Subdiagnostic)]
|
||||||
|
#[help(expand_help)]
|
||||||
|
pub(crate) struct ProcMacroPanickedHelp {
|
||||||
|
pub message: String,
|
||||||
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
use crate::base::{self, *};
|
use crate::base::{self, *};
|
||||||
|
use crate::errors;
|
||||||
use crate::proc_macro_server;
|
use crate::proc_macro_server;
|
||||||
|
|
||||||
use rustc_ast as ast;
|
use rustc_ast as ast;
|
||||||
@ -60,11 +61,12 @@ fn expand<'cx>(
|
|||||||
let strategy = exec_strategy(ecx);
|
let strategy = exec_strategy(ecx);
|
||||||
let server = proc_macro_server::Rustc::new(ecx);
|
let server = proc_macro_server::Rustc::new(ecx);
|
||||||
self.client.run(&strategy, server, input, proc_macro_backtrace).map_err(|e| {
|
self.client.run(&strategy, server, input, proc_macro_backtrace).map_err(|e| {
|
||||||
let mut err = ecx.struct_span_err(span, "proc macro panicked");
|
ecx.sess.emit_err(errors::ProcMacroPanicked {
|
||||||
if let Some(s) = e.as_str() {
|
span,
|
||||||
err.help(&format!("message: {}", s));
|
message: e
|
||||||
}
|
.as_str()
|
||||||
err.emit()
|
.map(|message| errors::ProcMacroPanickedHelp { message: message.into() }),
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user