mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Migrate rustc_pattern_analysis to use TyCtxt::emit_diag_node_span_lint
This commit is contained in:
@@ -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<G: EmissionGuarantee>(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(
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user