Skip to content

Commit cf355c6

Browse files
committed
Rename LintContext::struct_span_lint as LintContext::span_lint.
1 parent 93955e0 commit cf355c6

File tree

5 files changed

+9
-10
lines changed

5 files changed

+9
-10
lines changed

clippy.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ avoid-breaking-exported-api = false
22

33
# use the various `span_lint_*` methods instead, which also add a link to the docs
44
disallowed-methods = [
5-
"rustc_lint::context::LintContext::struct_span_lint",
5+
"rustc_lint::context::LintContext::span_lint",
66
"rustc_middle::ty::context::TyCtxt::struct_span_lint_hir"
77
]

clippy_lints/src/utils/internal_lints/compiler_lint_functions.rs

-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ impl CompilerLintFunctions {
4141
pub fn new() -> Self {
4242
let mut map = FxHashMap::default();
4343
map.insert("span_lint", "utils::span_lint");
44-
map.insert("struct_span_lint", "utils::span_lint");
4544
map.insert("lint", "utils::span_lint");
4645
map.insert("span_lint_note", "utils::span_lint_and_note");
4746
map.insert("span_lint_help", "utils::span_lint_and_help");

clippy_utils/src/diagnostics.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ fn docs_link(diag: &mut Diagnostic, lint: &'static Lint) {
4747
/// ```
4848
pub fn span_lint<T: LintContext>(cx: &T, lint: &'static Lint, sp: impl Into<MultiSpan>, msg: &str) {
4949
#[expect(clippy::disallowed_methods)]
50-
cx.struct_span_lint(lint, sp, msg.to_string(), |diag| {
50+
cx.span_lint(lint, sp, msg.to_string(), |diag| {
5151
docs_link(diag, lint);
5252
});
5353
}
@@ -81,7 +81,7 @@ pub fn span_lint_and_help<T: LintContext>(
8181
help: &str,
8282
) {
8383
#[expect(clippy::disallowed_methods)]
84-
cx.struct_span_lint(lint, span, msg.to_string(), |diag| {
84+
cx.span_lint(lint, span, msg.to_string(), |diag| {
8585
let help = help.to_string();
8686
if let Some(help_span) = help_span {
8787
diag.span_help(help_span, help.to_string());
@@ -124,7 +124,7 @@ pub fn span_lint_and_note<T: LintContext>(
124124
note: &str,
125125
) {
126126
#[expect(clippy::disallowed_methods)]
127-
cx.struct_span_lint(lint, span, msg.to_string(), |diag| {
127+
cx.span_lint(lint, span, msg.to_string(), |diag| {
128128
let note = note.to_string();
129129
if let Some(note_span) = note_span {
130130
diag.span_note(note_span, note);
@@ -146,7 +146,7 @@ where
146146
F: FnOnce(&mut Diagnostic),
147147
{
148148
#[expect(clippy::disallowed_methods)]
149-
cx.struct_span_lint(lint, sp, msg.to_string(), |diag| {
149+
cx.span_lint(lint, sp, msg.to_string(), |diag| {
150150
f(diag);
151151
docs_link(diag, lint);
152152
});

tests/ui-internal/disallow_struct_span_lint.rs renamed to tests/ui-internal/disallow_span_lint.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_lint::{Lint, LintContext};
1111
use rustc_middle::ty::TyCtxt;
1212

1313
pub fn a(cx: impl LintContext, lint: &'static Lint, span: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage>) {
14-
cx.struct_span_lint(lint, span, msg, |_| {});
14+
cx.span_lint(lint, span, msg, |_| {});
1515
}
1616

1717
pub fn b(

tests/ui-internal/disallow_struct_span_lint.stderr renamed to tests/ui-internal/disallow_span_lint.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error: use of a disallowed method `rustc_lint::context::LintContext::struct_span_lint`
1+
error: use of a disallowed method `rustc_lint::context::LintContext::span_lint`
22
--> $DIR/disallow_struct_span_lint.rs:14:5
33
|
4-
LL | cx.struct_span_lint(lint, span, msg, |_| {});
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4+
LL | cx.span_lint(lint, span, msg, |_| {});
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: `-D clippy::disallowed-methods` implied by `-D warnings`
88
= help: to override `-D warnings` add `#[allow(clippy::disallowed_methods)]`

0 commit comments

Comments
 (0)