Skip to content

Commit b55a3e4

Browse files
Rollup merge of rust-lang#153016 - GuillaumeGomez:migrate-diag, r=JonathanBrouwer,Kivooeo
Migration of `LintDiagnostic` - part 2 Follow-up of rust-lang#152933. More `LintDiagnostic` items being migrated to `Diagnostic`. r? @JonathanBrouwer
2 parents 60941db + b8f5241 commit b55a3e4

37 files changed

+190
-171
lines changed

compiler/rustc_borrowck/src/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2698,7 +2698,12 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
26982698

26992699
let mut_span = tcx.sess.source_map().span_until_non_whitespace(span);
27002700

2701-
tcx.emit_node_span_lint(UNUSED_MUT, lint_root, span, VarNeedNotMut { span: mut_span })
2701+
tcx.emit_diag_node_span_lint(
2702+
UNUSED_MUT,
2703+
lint_root,
2704+
span,
2705+
VarNeedNotMut { span: mut_span },
2706+
)
27022707
}
27032708
}
27042709
}

compiler/rustc_borrowck/src/session_diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub(crate) struct GenericDoesNotLiveLongEnough {
4747
pub span: Span,
4848
}
4949

50-
#[derive(LintDiagnostic)]
50+
#[derive(Diagnostic)]
5151
#[diag("variable does not need to be mutable")]
5252
pub(crate) struct VarNeedNotMut {
5353
#[suggestion(

compiler/rustc_codegen_ssa/src/errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_errors::codes::*;
1010
use rustc_errors::{
1111
Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, EmissionGuarantee, IntoDiagArg, Level, msg,
1212
};
13-
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
13+
use rustc_macros::{Diagnostic, Subdiagnostic};
1414
use rustc_middle::ty::layout::LayoutError;
1515
use rustc_middle::ty::{FloatTy, Ty};
1616
use rustc_span::{Span, Symbol};
@@ -1164,7 +1164,7 @@ pub(crate) struct XcrunSdkPathWarning {
11641164
pub stderr: String,
11651165
}
11661166

1167-
#[derive(LintDiagnostic)]
1167+
#[derive(Diagnostic)]
11681168
#[diag("enabling the `neon` target feature on the current target is unsound due to ABI issues")]
11691169
pub(crate) struct Aarch64SoftfloatNeon;
11701170

compiler/rustc_codegen_ssa/src/target_features.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub(crate) fn from_target_feature_attr(
7575
// For "neon" specifically, we emit an FCW instead of a hard error.
7676
// See <https://github.com/rust-lang/rust/issues/134375>.
7777
if tcx.sess.target.arch == Arch::AArch64 && name.as_str() == "neon" {
78-
tcx.emit_node_span_lint(
78+
tcx.emit_diag_node_span_lint(
7979
AARCH64_SOFTFLOAT_NEON,
8080
tcx.local_def_id_to_hir_id(did),
8181
feature_span,

compiler/rustc_const_eval/src/const_eval/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,9 @@ pub(super) fn lint<'tcx, L>(
252252
lint: &'static rustc_session::lint::Lint,
253253
decorator: impl FnOnce(Vec<errors::FrameNote>) -> L,
254254
) where
255-
L: for<'a> rustc_errors::LintDiagnostic<'a, ()>,
255+
L: for<'a> rustc_errors::Diagnostic<'a, ()>,
256256
{
257257
let (span, frames) = get_span_and_frames(tcx, &machine.stack);
258258

259-
tcx.emit_node_span_lint(lint, machine.best_lint_scope(*tcx), span, decorator(frames));
259+
tcx.emit_diag_node_span_lint(lint, machine.best_lint_scope(*tcx), span, decorator(frames));
260260
}

compiler/rustc_const_eval/src/const_eval/machine.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> {
718718
.level
719719
.is_error();
720720
let span = ecx.cur_span();
721-
ecx.tcx.emit_node_span_lint(
721+
ecx.tcx.emit_diag_node_span_lint(
722722
rustc_session::lint::builtin::LONG_RUNNING_CONST_EVAL,
723723
hir_id,
724724
span,

compiler/rustc_const_eval/src/errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_errors::{
99
Subdiagnostic, msg,
1010
};
1111
use rustc_hir::ConstContext;
12-
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
12+
use rustc_macros::{Diagnostic, Subdiagnostic};
1313
use rustc_middle::mir::interpret::{
1414
CtfeProvenance, ExpectedKind, InterpErrorKind, InvalidMetaKind, InvalidProgramInfo,
1515
Misalignment, Pointer, PointerKind, ResourceExhaustionInfo, UndefinedBehaviorInfo,
@@ -318,7 +318,7 @@ pub(crate) struct InteriorMutableBorrowEscaping {
318318
pub kind: ConstContext,
319319
}
320320

321-
#[derive(LintDiagnostic)]
321+
#[derive(Diagnostic)]
322322
#[diag("constant evaluation is taking a long time")]
323323
#[note(
324324
"this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval.

compiler/rustc_hir_analysis/src/check/check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1264,7 +1264,7 @@ fn check_impl_items_against_trait<'tcx>(
12641264
}
12651265

12661266
if self_is_guaranteed_unsize_self && tcx.generics_require_sized_self(ty_trait_item.def_id) {
1267-
tcx.emit_node_span_lint(
1267+
tcx.emit_diag_node_span_lint(
12681268
rustc_lint_defs::builtin::DEAD_CODE,
12691269
tcx.local_def_id_to_hir_id(ty_impl_item.def_id.expect_local()),
12701270
tcx.def_span(ty_impl_item.def_id),

compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ fn report_mismatched_rpitit_signature<'tcx>(
345345
with_no_trimmed_paths!(with_types_for_signature!(format!("{return_ty}")));
346346

347347
let span = unmatched_bound.unwrap_or(span);
348-
tcx.emit_node_span_lint(
348+
tcx.emit_diag_node_span_lint(
349349
if is_internal { REFINING_IMPL_TRAIT_INTERNAL } else { REFINING_IMPL_TRAIT_REACHABLE },
350350
tcx.local_def_id_to_hir_id(impl_m_def_id.expect_local()),
351351
span,
@@ -442,7 +442,7 @@ fn report_mismatched_rpitit_captures<'tcx>(
442442
.sort_by_cached_key(|arg| !matches!(arg.kind(), ty::GenericArgKind::Lifetime(_)));
443443
let suggestion = format!("use<{}>", trait_captured_args.iter().join(", "));
444444

445-
tcx.emit_node_span_lint(
445+
tcx.emit_diag_node_span_lint(
446446
if is_internal { REFINING_IMPL_TRAIT_INTERNAL } else { REFINING_IMPL_TRAIT_REACHABLE },
447447
tcx.local_def_id_to_hir_id(impl_opaque_def_id),
448448
use_bound_span,

compiler/rustc_hir_analysis/src/check/wfcheck.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use rustc_hir::{AmbigArg, ItemKind, find_attr};
1414
use rustc_infer::infer::outlives::env::OutlivesEnvironment;
1515
use rustc_infer::infer::{self, InferCtxt, SubregionOrigin, TyCtxtInferExt};
1616
use rustc_lint_defs::builtin::SHADOWING_SUPERTRAIT_ITEMS;
17-
use rustc_macros::LintDiagnostic;
17+
use rustc_macros::Diagnostic;
1818
use rustc_middle::mir::interpret::ErrorHandled;
1919
use rustc_middle::traits::solve::NoSolution;
2020
use rustc_middle::ty::trait_def::TraitSpecializationKind;
@@ -797,7 +797,7 @@ fn lint_item_shadowing_supertrait_item<'tcx>(tcx: TyCtxt<'tcx>, trait_item_def_i
797797
errors::SupertraitItemShadowee::Several { traits: traits.into(), spans: spans.into() }
798798
};
799799

800-
tcx.emit_node_span_lint(
800+
tcx.emit_diag_node_span_lint(
801801
SHADOWING_SUPERTRAIT_ITEMS,
802802
tcx.local_def_id_to_hir_id(trait_item_def_id),
803803
tcx.def_span(trait_item_def_id),
@@ -2458,7 +2458,7 @@ fn lint_redundant_lifetimes<'tcx>(
24582458
&& outlives_env.free_region_map().sub_free_regions(tcx, victim, candidate)
24592459
{
24602460
shadowed.insert(victim);
2461-
tcx.emit_node_span_lint(
2461+
tcx.emit_diag_node_span_lint(
24622462
rustc_lint_defs::builtin::REDUNDANT_LIFETIMES,
24632463
tcx.local_def_id_to_hir_id(def_id.expect_local()),
24642464
tcx.def_span(def_id),
@@ -2469,7 +2469,7 @@ fn lint_redundant_lifetimes<'tcx>(
24692469
}
24702470
}
24712471

2472-
#[derive(LintDiagnostic)]
2472+
#[derive(Diagnostic)]
24732473
#[diag("unnecessary lifetime parameter `{$victim}`")]
24742474
#[note("you can use the `{$candidate}` lifetime directly, in place of `{$victim}`")]
24752475
struct RedundantLifetimeArgsLint<'tcx> {

0 commit comments

Comments
 (0)