mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 15:11:30 +00:00
Replace &mut DiagnosticBuilder
, in signatures, with &mut Diagnostic
.
This commit is contained in:
parent
e390e6c469
commit
88483bd4b7
7 changed files with 17 additions and 17 deletions
|
@ -6,7 +6,7 @@ use clippy_utils::{
|
|||
};
|
||||
use if_chain::if_chain;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_errors::{Applicability, DiagnosticBuilder};
|
||||
use rustc_errors::{Applicability, Diagnostic};
|
||||
use rustc_hir::intravisit::{self, Visitor};
|
||||
use rustc_hir::{Block, Expr, ExprKind, HirId};
|
||||
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
||||
|
@ -489,7 +489,7 @@ fn emit_branches_sharing_code_lint(
|
|||
add_expr_note = !cx.typeck_results().expr_ty(if_expr).is_unit();
|
||||
}
|
||||
|
||||
let add_optional_msgs = |diag: &mut DiagnosticBuilder<'_>| {
|
||||
let add_optional_msgs = |diag: &mut Diagnostic| {
|
||||
if add_expr_note {
|
||||
diag.note("The end suggestion probably needs some adjustments to use the expression result correctly");
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use std::borrow::Cow;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use rustc_errors::DiagnosticBuilder;
|
||||
use rustc_errors::Diagnostic;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::intravisit::{walk_body, walk_expr, walk_inf, walk_ty, Visitor};
|
||||
use rustc_hir::{Body, Expr, ExprKind, GenericArg, Item, ItemKind, QPath, TyKind};
|
||||
|
@ -68,7 +68,7 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitHasher {
|
|||
|
||||
fn suggestion<'tcx>(
|
||||
cx: &LateContext<'tcx>,
|
||||
diag: &mut DiagnosticBuilder<'_>,
|
||||
diag: &mut Diagnostic,
|
||||
generics_span: Span,
|
||||
generics_suggestion_span: Span,
|
||||
target: &ImplicitHasherType<'_>,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! checks for `#[inline]` on trait methods without bodies
|
||||
|
||||
use clippy_utils::diagnostics::span_lint_and_then;
|
||||
use clippy_utils::sugg::DiagnosticBuilderExt;
|
||||
use clippy_utils::sugg::DiagnosticExt;
|
||||
use rustc_ast::ast::Attribute;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{TraitFn, TraitItem, TraitItemKind};
|
||||
|
|
|
@ -6,7 +6,7 @@ use clippy_utils::{get_trait_def_id, is_self, paths};
|
|||
use if_chain::if_chain;
|
||||
use rustc_ast::ast::Attribute;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_errors::{Applicability, DiagnosticBuilder};
|
||||
use rustc_errors::{Applicability, Diagnostic};
|
||||
use rustc_hir::intravisit::FnKind;
|
||||
use rustc_hir::{BindingAnnotation, Body, FnDecl, GenericArg, HirId, Impl, ItemKind, Node, PatKind, QPath, TyKind};
|
||||
use rustc_hir::{HirIdMap, HirIdSet};
|
||||
|
@ -196,7 +196,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
|
|||
}
|
||||
|
||||
// Dereference suggestion
|
||||
let sugg = |diag: &mut DiagnosticBuilder<'_>| {
|
||||
let sugg = |diag: &mut Diagnostic| {
|
||||
if let ty::Adt(def, ..) = ty.kind() {
|
||||
if let Some(span) = cx.tcx.hir().span_if_local(def.did) {
|
||||
if can_type_implement_copy(cx.tcx, cx.param_env, ty).is_ok() {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use clippy_utils::diagnostics::span_lint_hir_and_then;
|
||||
use clippy_utils::return_ty;
|
||||
use clippy_utils::source::snippet;
|
||||
use clippy_utils::sugg::DiagnosticBuilderExt;
|
||||
use clippy_utils::sugg::DiagnosticExt;
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
|
|
|
@ -8,13 +8,13 @@
|
|||
//! Thank you!
|
||||
//! ~The `INTERNAL_METADATA_COLLECTOR` lint
|
||||
|
||||
use rustc_errors::{Applicability, DiagnosticBuilder};
|
||||
use rustc_errors::{Applicability, Diagnostic};
|
||||
use rustc_hir::HirId;
|
||||
use rustc_lint::{LateContext, Lint, LintContext};
|
||||
use rustc_span::source_map::{MultiSpan, Span};
|
||||
use std::env;
|
||||
|
||||
fn docs_link(diag: &mut DiagnosticBuilder<'_>, lint: &'static Lint) {
|
||||
fn docs_link(diag: &mut Diagnostic, lint: &'static Lint) {
|
||||
if env::var("CLIPPY_DISABLE_DOCS_LINKS").is_err() {
|
||||
if let Some(lint) = lint.name_lower().strip_prefix("clippy::") {
|
||||
diag.help(&format!(
|
||||
|
@ -145,7 +145,7 @@ pub fn span_lint_and_then<C, S, F>(cx: &C, lint: &'static Lint, sp: S, msg: &str
|
|||
where
|
||||
C: LintContext,
|
||||
S: Into<MultiSpan>,
|
||||
F: FnOnce(&mut DiagnosticBuilder<'_>),
|
||||
F: FnOnce(&mut Diagnostic),
|
||||
{
|
||||
cx.struct_span_lint(lint, sp, |diag| {
|
||||
let mut diag = diag.build(msg);
|
||||
|
@ -169,7 +169,7 @@ pub fn span_lint_hir_and_then(
|
|||
hir_id: HirId,
|
||||
sp: impl Into<MultiSpan>,
|
||||
msg: &str,
|
||||
f: impl FnOnce(&mut DiagnosticBuilder<'_>),
|
||||
f: impl FnOnce(&mut Diagnostic),
|
||||
) {
|
||||
cx.tcx.struct_span_lint_hir(lint, hir_id, sp, |diag| {
|
||||
let mut diag = diag.build(msg);
|
||||
|
@ -219,7 +219,7 @@ pub fn span_lint_and_sugg<'a, T: LintContext>(
|
|||
/// appear once per
|
||||
/// replacement. In human-readable format though, it only appears once before
|
||||
/// the whole suggestion.
|
||||
pub fn multispan_sugg<I>(diag: &mut DiagnosticBuilder<'_>, help_msg: &str, sugg: I)
|
||||
pub fn multispan_sugg<I>(diag: &mut Diagnostic, help_msg: &str, sugg: I)
|
||||
where
|
||||
I: IntoIterator<Item = (Span, String)>,
|
||||
{
|
||||
|
@ -232,7 +232,7 @@ where
|
|||
/// multiple spans. This is tracked in issue [rustfix#141](https://github.com/rust-lang/rustfix/issues/141).
|
||||
/// Suggestions with multiple spans will be silently ignored.
|
||||
pub fn multispan_sugg_with_applicability<I>(
|
||||
diag: &mut DiagnosticBuilder<'_>,
|
||||
diag: &mut Diagnostic,
|
||||
help_msg: &str,
|
||||
applicability: Applicability,
|
||||
sugg: I,
|
||||
|
|
|
@ -673,8 +673,8 @@ fn indentation<T: LintContext>(cx: &T, span: Span) -> Option<String> {
|
|||
})
|
||||
}
|
||||
|
||||
/// Convenience extension trait for `DiagnosticBuilder`.
|
||||
pub trait DiagnosticBuilderExt<T: LintContext> {
|
||||
/// Convenience extension trait for `Diagnostic`.
|
||||
pub trait DiagnosticExt<T: LintContext> {
|
||||
/// Suggests to add an attribute to an item.
|
||||
///
|
||||
/// Correctly handles indentation of the attribute and item.
|
||||
|
@ -721,7 +721,7 @@ pub trait DiagnosticBuilderExt<T: LintContext> {
|
|||
fn suggest_remove_item(&mut self, cx: &T, item: Span, msg: &str, applicability: Applicability);
|
||||
}
|
||||
|
||||
impl<T: LintContext> DiagnosticBuilderExt<T> for rustc_errors::DiagnosticBuilder<'_> {
|
||||
impl<T: LintContext> DiagnosticExt<T> for rustc_errors::Diagnostic {
|
||||
fn suggest_item_with_attr<D: Display + ?Sized>(
|
||||
&mut self,
|
||||
cx: &T,
|
||||
|
|
Loading…
Reference in a new issue