Skip to content

Commit c56d71f

Browse files
committed
Rename LintContext::struct_span_lint as LintContext::span_lint.
1 parent d5fd099 commit c56d71f

File tree

8 files changed

+12
-13
lines changed

8 files changed

+12
-13
lines changed

compiler/rustc_lint/src/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ pub trait LintContext {
580580
///
581581
/// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature
582582
#[rustc_lint_diagnostics]
583-
fn struct_span_lint<S: Into<MultiSpan>>(
583+
fn span_lint<S: Into<MultiSpan>>(
584584
&self,
585585
lint: &'static Lint,
586586
span: S,

compiler/rustc_lint/src/non_fmt_panic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tc
121121
}
122122

123123
#[allow(rustc::diagnostic_outside_of_impl)]
124-
cx.struct_span_lint(NON_FMT_PANICS, arg_span, fluent::lint_non_fmt_panic, |lint| {
124+
cx.span_lint(NON_FMT_PANICS, arg_span, fluent::lint_non_fmt_panic, |lint| {
125125
lint.arg("name", symbol);
126126
lint.note(fluent::lint_note);
127127
lint.note(fluent::lint_more_info_note);

compiler/rustc_macros/src/diagnostics/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ pub fn session_diagnostic_derive(s: Structure<'_>) -> TokenStream {
9090
/// Then, later, to emit the error:
9191
///
9292
/// ```ignore (rust)
93-
/// cx.struct_span_lint(INVALID_ATOMIC_ORDERING, fail_order_arg_span, AtomicOrderingInvalidLint {
93+
/// cx.span_lint(INVALID_ATOMIC_ORDERING, fail_order_arg_span, AtomicOrderingInvalidLint {
9494
/// method,
9595
/// success_ordering,
9696
/// fail_ordering,

src/tools/clippy/clippy.toml

Lines changed: 1 addition & 1 deletion
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
]

src/tools/clippy/clippy_lints/src/utils/internal_lints/compiler_lint_functions.rs

Lines changed: 0 additions & 1 deletion
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");

src/tools/clippy/clippy_utils/src/diagnostics.rs

Lines changed: 4 additions & 4 deletions
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
});

src/tools/clippy/tests/ui-internal/disallow_struct_span_lint.rs renamed to src/tools/clippy/tests/ui-internal/disallow_span_lint.rs

Lines changed: 1 addition & 1 deletion
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(

src/tools/clippy/tests/ui-internal/disallow_struct_span_lint.stderr renamed to src/tools/clippy/tests/ui-internal/disallow_span_lint.stderr

Lines changed: 3 additions & 3 deletions
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)