Use DiagnosticMessage for BufferedEarlyLint.msg

This commit is contained in:
finalchild 2022-08-17 23:52:16 +09:00
parent d6fdf14eb7
commit 80451de390
3 changed files with 6 additions and 6 deletions

View File

@ -1176,7 +1176,7 @@ fn create_lints_for_named_arguments_used_positionally(cx: &mut Context<'_, '_>)
cx.ecx.buffered_early_lint.push(BufferedEarlyLint {
span: MultiSpan::from_span(named_arg.positional_named_arg_span),
msg: msg.clone(),
msg: msg.clone().into(),
node_id: ast::CRATE_NODE_ID,
lint_id: LintId::of(&NAMED_ARGUMENTS_USED_POSITIONALLY),
diagnostic: BuiltinLintDiagnostics::NamedArgumentUsedPositionally {

View File

@ -45,7 +45,7 @@ impl<'a, T: EarlyLintPass> EarlyContextAndPass<'a, T> {
lint_id.lint,
Some(span),
|lint| {
lint.build(&msg).emit();
lint.build(msg).emit();
},
diagnostic,
);

View File

@ -9,7 +9,7 @@ pub use self::Level::*;
use rustc_ast::node_id::{NodeId, NodeMap};
use rustc_ast::{AttrId, Attribute};
use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey};
use rustc_error_messages::MultiSpan;
use rustc_error_messages::{MultiSpan, DiagnosticMessage};
use rustc_hir::HashStableContext;
use rustc_hir::HirId;
use rustc_span::edition::Edition;
@ -491,7 +491,7 @@ pub struct BufferedEarlyLint {
pub span: MultiSpan,
/// The lint message.
pub msg: String,
pub msg: DiagnosticMessage,
/// The `NodeId` of the AST node that generated the lint.
pub node_id: NodeId,
@ -520,11 +520,11 @@ impl LintBuffer {
lint: &'static Lint,
node_id: NodeId,
span: MultiSpan,
msg: &str,
msg: impl Into<DiagnosticMessage>,
diagnostic: BuiltinLintDiagnostics,
) {
let lint_id = LintId::of(lint);
let msg = msg.to_string();
let msg = msg.into();
self.add_early_lint(BufferedEarlyLint { lint_id, node_id, span, msg, diagnostic });
}