Generate lint diagnostic message from BuiltinLintDiag
Translation of the lint message happens when the actual diagnostic is created, not when the lint is buffered. Generating the message from BuiltinLintDiag ensures that all required data to construct the message is preserved in the LintBuffer, eventually allowing the messages to be moved to fluent. Remove the `msg` field from BufferedEarlyLint, it is either generated from the data in the BuiltinLintDiag or stored inside BuiltinLintDiag::Normal.
This commit is contained in:
parent
2482f3c17c
commit
c227f35a9c
26 changed files with 212 additions and 130 deletions
|
@ -539,12 +539,11 @@ pub trait LintContext {
|
|||
&self,
|
||||
lint: &'static Lint,
|
||||
span: Option<impl Into<MultiSpan>>,
|
||||
msg: impl Into<DiagMessage>,
|
||||
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
||||
diagnostic: BuiltinLintDiag,
|
||||
) {
|
||||
// We first generate a blank diagnostic.
|
||||
self.opt_span_lint(lint, span, msg, |db| {
|
||||
self.opt_span_lint(lint, span, diagnostics::builtin_message(&diagnostic), |db| {
|
||||
// Now, set up surrounding context.
|
||||
diagnostics::builtin(self.sess(), diagnostic, db);
|
||||
// Rewrap `db`, and pass control to the user.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue