Auto merge of #121780 - nnethercote:diag-renaming2, r=davidtwco

Diagnostic renaming 2

A sequel to #121489.

r? `@davidtwco`
This commit is contained in:
bors 2024-03-05 02:58:34 +00:00
commit ae710de635
4 changed files with 12 additions and 7 deletions

View File

@ -1,7 +1,7 @@
//! checks for `#[inline]` on trait methods without bodies //! checks for `#[inline]` on trait methods without bodies
use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::diagnostics::span_lint_and_then;
use clippy_utils::sugg::DiagnosticExt; use clippy_utils::sugg::DiagExt;
use rustc_ast::ast::Attribute; use rustc_ast::ast::Attribute;
use rustc_errors::Applicability; use rustc_errors::Applicability;
use rustc_hir::{TraitFn, TraitItem, TraitItemKind}; use rustc_hir::{TraitFn, TraitItem, TraitItemKind};

View File

@ -1,7 +1,7 @@
use clippy_utils::diagnostics::span_lint_hir_and_then; use clippy_utils::diagnostics::span_lint_hir_and_then;
use clippy_utils::return_ty; use clippy_utils::return_ty;
use clippy_utils::source::snippet; use clippy_utils::source::snippet;
use clippy_utils::sugg::DiagnosticExt; use clippy_utils::sugg::DiagExt;
use rustc_errors::Applicability; use rustc_errors::Applicability;
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::HirIdSet; use rustc_hir::HirIdSet;

View File

@ -685,7 +685,7 @@ fn indentation<T: LintContext>(cx: &T, span: Span) -> Option<String> {
} }
/// Convenience extension trait for `Diag`. /// Convenience extension trait for `Diag`.
pub trait DiagnosticExt<T: LintContext> { pub trait DiagExt<T: LintContext> {
/// Suggests to add an attribute to an item. /// Suggests to add an attribute to an item.
/// ///
/// Correctly handles indentation of the attribute and item. /// Correctly handles indentation of the attribute and item.
@ -732,7 +732,7 @@ fn suggest_item_with_attr<D: Display + ?Sized>(
fn suggest_remove_item(&mut self, cx: &T, item: Span, msg: &str, applicability: Applicability); fn suggest_remove_item(&mut self, cx: &T, item: Span, msg: &str, applicability: Applicability);
} }
impl<T: LintContext> DiagnosticExt<T> for rustc_errors::Diag<'_, ()> { impl<T: LintContext> DiagExt<T> for rustc_errors::Diag<'_, ()> {
fn suggest_item_with_attr<D: Display + ?Sized>( fn suggest_item_with_attr<D: Display + ?Sized>(
&mut self, &mut self,
cx: &T, cx: &T,

View File

@ -5,12 +5,17 @@
extern crate rustc_lint; extern crate rustc_lint;
extern crate rustc_middle; extern crate rustc_middle;
use rustc_errors::{DiagnosticMessage, MultiSpan}; use rustc_errors::{DiagMessage, MultiSpan};
use rustc_hir::hir_id::HirId; use rustc_hir::hir_id::HirId;
use rustc_lint::{Lint, LintContext}; 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<DiagMessage>)
{
cx.span_lint(lint, span, msg, |_| {}); cx.span_lint(lint, span, msg, |_| {});
} }
@ -19,7 +24,7 @@ pub fn b(
lint: &'static Lint, lint: &'static Lint,
hir_id: HirId, hir_id: HirId,
span: impl Into<MultiSpan>, span: impl Into<MultiSpan>,
msg: impl Into<DiagnosticMessage>, msg: impl Into<DiagMessage>,
) { ) {
tcx.node_span_lint(lint, hir_id, span, msg, |_| {}); tcx.node_span_lint(lint, hir_id, span, msg, |_| {});
} }