Rename LintContext::struct_span_lint
as LintContext::span_lint
.
This commit is contained in:
parent
d5fd099729
commit
c56d71f418
8 changed files with 12 additions and 13 deletions
|
@ -580,7 +580,7 @@ pub trait LintContext {
|
||||||
///
|
///
|
||||||
/// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature
|
/// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
fn struct_span_lint<S: Into<MultiSpan>>(
|
fn span_lint<S: Into<MultiSpan>>(
|
||||||
&self,
|
&self,
|
||||||
lint: &'static Lint,
|
lint: &'static Lint,
|
||||||
span: S,
|
span: S,
|
||||||
|
|
|
@ -121,7 +121,7 @@ fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tc
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||||
cx.struct_span_lint(NON_FMT_PANICS, arg_span, fluent::lint_non_fmt_panic, |lint| {
|
cx.span_lint(NON_FMT_PANICS, arg_span, fluent::lint_non_fmt_panic, |lint| {
|
||||||
lint.arg("name", symbol);
|
lint.arg("name", symbol);
|
||||||
lint.note(fluent::lint_note);
|
lint.note(fluent::lint_note);
|
||||||
lint.note(fluent::lint_more_info_note);
|
lint.note(fluent::lint_more_info_note);
|
||||||
|
|
|
@ -90,7 +90,7 @@ pub fn session_diagnostic_derive(s: Structure<'_>) -> TokenStream {
|
||||||
/// Then, later, to emit the error:
|
/// Then, later, to emit the error:
|
||||||
///
|
///
|
||||||
/// ```ignore (rust)
|
/// ```ignore (rust)
|
||||||
/// cx.struct_span_lint(INVALID_ATOMIC_ORDERING, fail_order_arg_span, AtomicOrderingInvalidLint {
|
/// cx.span_lint(INVALID_ATOMIC_ORDERING, fail_order_arg_span, AtomicOrderingInvalidLint {
|
||||||
/// method,
|
/// method,
|
||||||
/// success_ordering,
|
/// success_ordering,
|
||||||
/// fail_ordering,
|
/// fail_ordering,
|
||||||
|
|
|
@ -2,6 +2,6 @@ avoid-breaking-exported-api = false
|
||||||
|
|
||||||
# use the various `span_lint_*` methods instead, which also add a link to the docs
|
# use the various `span_lint_*` methods instead, which also add a link to the docs
|
||||||
disallowed-methods = [
|
disallowed-methods = [
|
||||||
"rustc_lint::context::LintContext::struct_span_lint",
|
"rustc_lint::context::LintContext::span_lint",
|
||||||
"rustc_middle::ty::context::TyCtxt::struct_span_lint_hir"
|
"rustc_middle::ty::context::TyCtxt::struct_span_lint_hir"
|
||||||
]
|
]
|
||||||
|
|
|
@ -41,7 +41,6 @@ impl CompilerLintFunctions {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
let mut map = FxHashMap::default();
|
let mut map = FxHashMap::default();
|
||||||
map.insert("span_lint", "utils::span_lint");
|
map.insert("span_lint", "utils::span_lint");
|
||||||
map.insert("struct_span_lint", "utils::span_lint");
|
|
||||||
map.insert("lint", "utils::span_lint");
|
map.insert("lint", "utils::span_lint");
|
||||||
map.insert("span_lint_note", "utils::span_lint_and_note");
|
map.insert("span_lint_note", "utils::span_lint_and_note");
|
||||||
map.insert("span_lint_help", "utils::span_lint_and_help");
|
map.insert("span_lint_help", "utils::span_lint_and_help");
|
||||||
|
|
|
@ -47,7 +47,7 @@ fn docs_link(diag: &mut Diagnostic, lint: &'static Lint) {
|
||||||
/// ```
|
/// ```
|
||||||
pub fn span_lint<T: LintContext>(cx: &T, lint: &'static Lint, sp: impl Into<MultiSpan>, msg: &str) {
|
pub fn span_lint<T: LintContext>(cx: &T, lint: &'static Lint, sp: impl Into<MultiSpan>, msg: &str) {
|
||||||
#[expect(clippy::disallowed_methods)]
|
#[expect(clippy::disallowed_methods)]
|
||||||
cx.struct_span_lint(lint, sp, msg.to_string(), |diag| {
|
cx.span_lint(lint, sp, msg.to_string(), |diag| {
|
||||||
docs_link(diag, lint);
|
docs_link(diag, lint);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ pub fn span_lint_and_help<T: LintContext>(
|
||||||
help: &str,
|
help: &str,
|
||||||
) {
|
) {
|
||||||
#[expect(clippy::disallowed_methods)]
|
#[expect(clippy::disallowed_methods)]
|
||||||
cx.struct_span_lint(lint, span, msg.to_string(), |diag| {
|
cx.span_lint(lint, span, msg.to_string(), |diag| {
|
||||||
let help = help.to_string();
|
let help = help.to_string();
|
||||||
if let Some(help_span) = help_span {
|
if let Some(help_span) = help_span {
|
||||||
diag.span_help(help_span, help.to_string());
|
diag.span_help(help_span, help.to_string());
|
||||||
|
@ -124,7 +124,7 @@ pub fn span_lint_and_note<T: LintContext>(
|
||||||
note: &str,
|
note: &str,
|
||||||
) {
|
) {
|
||||||
#[expect(clippy::disallowed_methods)]
|
#[expect(clippy::disallowed_methods)]
|
||||||
cx.struct_span_lint(lint, span, msg.to_string(), |diag| {
|
cx.span_lint(lint, span, msg.to_string(), |diag| {
|
||||||
let note = note.to_string();
|
let note = note.to_string();
|
||||||
if let Some(note_span) = note_span {
|
if let Some(note_span) = note_span {
|
||||||
diag.span_note(note_span, note);
|
diag.span_note(note_span, note);
|
||||||
|
@ -146,7 +146,7 @@ where
|
||||||
F: FnOnce(&mut Diagnostic),
|
F: FnOnce(&mut Diagnostic),
|
||||||
{
|
{
|
||||||
#[expect(clippy::disallowed_methods)]
|
#[expect(clippy::disallowed_methods)]
|
||||||
cx.struct_span_lint(lint, sp, msg.to_string(), |diag| {
|
cx.span_lint(lint, sp, msg.to_string(), |diag| {
|
||||||
f(diag);
|
f(diag);
|
||||||
docs_link(diag, lint);
|
docs_link(diag, lint);
|
||||||
});
|
});
|
||||||
|
|
|
@ -11,7 +11,7 @@ use rustc_lint::{Lint, LintContext};
|
||||||
use rustc_middle::ty::TyCtxt;
|
use rustc_middle::ty::TyCtxt;
|
||||||
|
|
||||||
pub fn a(cx: impl LintContext, lint: &'static Lint, span: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage>) {
|
pub fn a(cx: impl LintContext, lint: &'static Lint, span: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage>) {
|
||||||
cx.struct_span_lint(lint, span, msg, |_| {});
|
cx.span_lint(lint, span, msg, |_| {});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn b(
|
pub fn b(
|
|
@ -1,8 +1,8 @@
|
||||||
error: use of a disallowed method `rustc_lint::context::LintContext::struct_span_lint`
|
error: use of a disallowed method `rustc_lint::context::LintContext::span_lint`
|
||||||
--> $DIR/disallow_struct_span_lint.rs:14:5
|
--> $DIR/disallow_struct_span_lint.rs:14:5
|
||||||
|
|
|
|
||||||
LL | cx.struct_span_lint(lint, span, msg, |_| {});
|
LL | cx.span_lint(lint, span, msg, |_| {});
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: `-D clippy::disallowed-methods` implied by `-D warnings`
|
= note: `-D clippy::disallowed-methods` implied by `-D warnings`
|
||||||
= help: to override `-D warnings` add `#[allow(clippy::disallowed_methods)]`
|
= help: to override `-D warnings` add `#[allow(clippy::disallowed_methods)]`
|
Loading…
Add table
Add a link
Reference in a new issue