Rename `TyCtxt::struct_span_lint_hir` as `TyCtxt::node_span_lint`.

This commit is contained in:
Nicholas Nethercote 2024-01-16 16:14:33 +11:00
parent cf355c6e9d
commit 6b359b7e1b
4 changed files with 6 additions and 6 deletions

View File

@ -3,5 +3,5 @@ avoid-breaking-exported-api = false
# use the various `span_lint_*` methods instead, which also add a link to the docs
disallowed-methods = [
"rustc_lint::context::LintContext::span_lint",
"rustc_middle::ty::context::TyCtxt::struct_span_lint_hir"
"rustc_middle::ty::context::TyCtxt::node_span_lint"
]

View File

@ -154,7 +154,7 @@ where
pub fn span_lint_hir(cx: &LateContext<'_>, lint: &'static Lint, hir_id: HirId, sp: Span, msg: &str) {
#[expect(clippy::disallowed_methods)]
cx.tcx.struct_span_lint_hir(lint, hir_id, sp, msg.to_string(), |diag| {
cx.tcx.node_span_lint(lint, hir_id, sp, msg.to_string(), |diag| {
docs_link(diag, lint);
});
}
@ -168,7 +168,7 @@ pub fn span_lint_hir_and_then(
f: impl FnOnce(&mut Diagnostic),
) {
#[expect(clippy::disallowed_methods)]
cx.tcx.struct_span_lint_hir(lint, hir_id, sp, msg.to_string(), |diag| {
cx.tcx.node_span_lint(lint, hir_id, sp, msg.to_string(), |diag| {
f(diag);
docs_link(diag, lint);
});

View File

@ -21,7 +21,7 @@ pub fn b(
span: impl Into<MultiSpan>,
msg: impl Into<DiagnosticMessage>,
) {
tcx.struct_span_lint_hir(lint, hir_id, span, msg, |_| {});
tcx.node_span_lint(lint, hir_id, span, msg, |_| {});
}
fn main() {}

View File

@ -7,10 +7,10 @@ LL | cx.span_lint(lint, span, msg, |_| {});
= note: `-D clippy::disallowed-methods` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::disallowed_methods)]`
error: use of a disallowed method `rustc_middle::ty::context::TyCtxt::struct_span_lint_hir`
error: use of a disallowed method `rustc_middle::ty::context::TyCtxt::node_span_lint`
--> $DIR/disallow_struct_span_lint.rs:24:5
|
LL | tcx.struct_span_lint_hir(lint, hir_id, span, msg, |_| {});
LL | tcx.node_span_lint(lint, hir_id, span, msg, |_| {});
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors