mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Remove usage of TyCtxt::node_span_lint in clippy
This commit is contained in:
@@ -13,5 +13,5 @@ path = "rustc_lint::context::LintContext::span_lint"
|
||||
reason = "this function does not add a link to our documentation; please use the `clippy_utils::diagnostics::span_lint*` functions instead"
|
||||
|
||||
[[disallowed-methods]]
|
||||
path = "rustc_middle::ty::context::TyCtxt::node_span_lint"
|
||||
path = "rustc_middle::ty::context::TyCtxt::emit_node_span_lint"
|
||||
reason = "this function does not add a link to our documentation; please use the `clippy_utils::diagnostics::span_lint_hir*` functions instead"
|
||||
|
||||
@@ -326,14 +326,14 @@ pub fn span_lint_hir_and_then(
|
||||
f: impl FnOnce(&mut Diag<'_, ()>),
|
||||
) {
|
||||
#[expect(clippy::disallowed_methods)]
|
||||
cx.tcx.node_span_lint(lint, hir_id, sp, |diag| {
|
||||
cx.tcx.emit_node_span_lint(lint, hir_id, sp, rustc_errors::DiagDecorator(|diag| {
|
||||
diag.primary_message(msg);
|
||||
f(diag);
|
||||
docs_link(diag, lint);
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
validate_diag(diag);
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
/// Add a span lint with a suggestion on how to fix it.
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
extern crate rustc_lint;
|
||||
extern crate rustc_middle;
|
||||
|
||||
use rustc_errors::{DiagMessage, MultiSpan};
|
||||
use rustc_errors::{DiagDecorator, DiagMessage, MultiSpan};
|
||||
use rustc_hir::hir_id::HirId;
|
||||
use rustc_lint::{Lint, LintContext};
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
@@ -19,10 +19,10 @@ pub fn a(cx: impl LintContext, lint: &'static Lint, span: impl Into<MultiSpan>,
|
||||
}
|
||||
|
||||
pub fn b(tcx: TyCtxt<'_>, lint: &'static Lint, hir_id: HirId, span: impl Into<MultiSpan>, msg: impl Into<DiagMessage>) {
|
||||
tcx.node_span_lint(lint, hir_id, span, |lint| {
|
||||
tcx.emit_node_span_lint(lint, hir_id, span, DiagDecorator(|lint| {
|
||||
//~^ disallowed_methods
|
||||
lint.primary_message(msg);
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
||||
Reference in New Issue
Block a user