From c53fbcd726fefeb0fa04365f4326c8a9f5d48b48 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 24 Feb 2026 11:30:46 +0100 Subject: [PATCH] Migrate `rustc_pattern_analysis` to use `TyCtxt::emit_diag_node_span_lint` --- compiler/rustc_pattern_analysis/src/errors.rs | 8 ++++---- compiler/rustc_pattern_analysis/src/lints.rs | 2 +- compiler/rustc_pattern_analysis/src/rustc.rs | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_pattern_analysis/src/errors.rs b/compiler/rustc_pattern_analysis/src/errors.rs index e7448613cc14..b27e52f32bf2 100644 --- a/compiler/rustc_pattern_analysis/src/errors.rs +++ b/compiler/rustc_pattern_analysis/src/errors.rs @@ -46,7 +46,7 @@ pub fn new<'p, 'tcx>( } } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("multiple patterns overlap on their endpoints")] #[note("you likely meant to write mutually exclusive ranges")] pub struct OverlappingRangeEndpoints { @@ -64,7 +64,7 @@ pub struct Overlap { pub range: String, // a printed pattern } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("exclusive range missing `{$max}`")] pub struct ExclusiveRangeMissingMax { #[label("this range doesn't match `{$max}` because `..` is an exclusive range")] @@ -80,7 +80,7 @@ pub struct ExclusiveRangeMissingMax { pub max: String, // a printed pattern } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("multiple ranges are one apart")] pub struct ExclusiveRangeMissingGap { #[label("this range doesn't match `{$gap}` because `..` is an exclusive range")] @@ -119,7 +119,7 @@ fn add_to_diag(self, diag: &mut Diag<'_, G>) { } } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("some variants are not matched explicitly")] #[help("ensure that all variants are matched explicitly by adding the suggested match arms")] #[note( diff --git a/compiler/rustc_pattern_analysis/src/lints.rs b/compiler/rustc_pattern_analysis/src/lints.rs index 3da744dc8c02..314d3e60f2a4 100644 --- a/compiler/rustc_pattern_analysis/src/lints.rs +++ b/compiler/rustc_pattern_analysis/src/lints.rs @@ -74,7 +74,7 @@ pub(crate) fn lint_nonexhaustive_missing_variants<'p, 'tcx>( // is not exhaustive enough. // // NB: The partner lint for structs lives in `compiler/rustc_hir_analysis/src/check/pat.rs`. - rcx.tcx.emit_node_span_lint( + rcx.tcx.emit_diag_node_span_lint( NON_EXHAUSTIVE_OMITTED_PATTERNS, rcx.match_lint_level, rcx.scrut_span, diff --git a/compiler/rustc_pattern_analysis/src/rustc.rs b/compiler/rustc_pattern_analysis/src/rustc.rs index dc38f2d8bc70..2804a807b993 100644 --- a/compiler/rustc_pattern_analysis/src/rustc.rs +++ b/compiler/rustc_pattern_analysis/src/rustc.rs @@ -948,7 +948,7 @@ fn lint_overlapping_range_endpoints( .map(|span| errors::Overlap { range: overlap_as_pat.to_string(), span }) .collect(); let pat_span = pat.data().span; - self.tcx.emit_node_span_lint( + self.tcx.emit_diag_node_span_lint( lint::builtin::OVERLAPPING_RANGE_ENDPOINTS, self.match_lint_level, pat_span, @@ -984,7 +984,7 @@ fn lint_non_contiguous_range_endpoints( let gap_as_pat = self.print_pat_range(&gap, *pat.ty()); if gapped_with.is_empty() { // If `gapped_with` is empty, `gap == T::MAX`. - self.tcx.emit_node_span_lint( + self.tcx.emit_diag_node_span_lint( lint::builtin::NON_CONTIGUOUS_RANGE_ENDPOINTS, self.match_lint_level, thir_pat.span, @@ -998,7 +998,7 @@ fn lint_non_contiguous_range_endpoints( }, ); } else { - self.tcx.emit_node_span_lint( + self.tcx.emit_diag_node_span_lint( lint::builtin::NON_CONTIGUOUS_RANGE_ENDPOINTS, self.match_lint_level, thir_pat.span,