Auto merge of #6914 - camsteffen:source-utils, r=Manishearth

Move some utils to `clippy_utils::source`

changelog: none

Continues #6907
This commit is contained in:
bors 2021-03-16 00:08:01 +00:00
commit d7a23112e3
152 changed files with 753 additions and 649 deletions

View file

@ -1,5 +1,6 @@
use crate::consts::{constant, Constant};
use crate::utils::{is_direct_expn_of, is_expn_of, match_panic_call, snippet_opt, span_lint_and_help};
use crate::utils::{is_direct_expn_of, is_expn_of, match_panic_call, span_lint_and_help};
use clippy_utils::source::snippet_opt;
use if_chain::if_chain;
use rustc_hir::{Expr, ExprKind, UnOp};
use rustc_lint::{LateContext, LateLintPass};

View file

@ -1,5 +1,6 @@
use crate::utils::{eq_expr_value, get_trait_def_id, snippet_opt, span_lint_and_then, trait_ref_of_method};
use crate::utils::{eq_expr_value, get_trait_def_id, span_lint_and_then, trait_ref_of_method};
use crate::utils::{higher, sugg};
use clippy_utils::source::snippet_opt;
use clippy_utils::ty::implements_trait;
use if_chain::if_chain;
use rustc_errors::Applicability;

View file

@ -1,4 +1,5 @@
use crate::utils::{snippet, span_lint_and_then};
use crate::utils::span_lint_and_then;
use clippy_utils::source::snippet;
use clippy_utils::ty::implements_trait;
use rustc_errors::Applicability;
use rustc_hir::{AsyncGeneratorKind, Body, BodyId, ExprKind, GeneratorKind, QPath};

View file

@ -1,9 +1,7 @@
//! checks for attributes
use crate::utils::{
first_line_of_span, is_present_in_source, match_panic_def_id, snippet_opt, span_lint, span_lint_and_help,
span_lint_and_sugg, span_lint_and_then, without_block_comments,
};
use crate::utils::{match_panic_def_id, span_lint, span_lint_and_help, span_lint_and_sugg, span_lint_and_then};
use clippy_utils::source::{first_line_of_span, is_present_in_source, snippet_opt, without_block_comments};
use if_chain::if_chain;
use rustc_ast::{AttrKind, AttrStyle, Attribute, Lit, LitKind, MetaItemKind, NestedMetaItem};
use rustc_errors::Applicability;

View file

@ -1,6 +1,5 @@
use crate::utils::{
differing_macro_contexts, get_parent_expr, snippet_block_with_applicability, span_lint, span_lint_and_sugg,
};
use crate::utils::{differing_macro_contexts, get_parent_expr, span_lint, span_lint_and_sugg};
use clippy_utils::source::snippet_block_with_applicability;
use clippy_utils::ty::implements_trait;
use if_chain::if_chain;
use rustc_errors::Applicability;

View file

@ -1,6 +1,5 @@
use crate::utils::{
eq_expr_value, get_trait_def_id, in_macro, paths, snippet_opt, span_lint_and_sugg, span_lint_and_then,
};
use crate::utils::{eq_expr_value, get_trait_def_id, in_macro, paths, span_lint_and_sugg, span_lint_and_then};
use clippy_utils::source::snippet_opt;
use clippy_utils::ty::{implements_trait, is_type_diagnostic_item};
use if_chain::if_chain;
use rustc_ast::ast::LitKind;

View file

@ -1,6 +1,5 @@
use crate::utils::{
contains_name, get_pat_name, paths, single_segment_path, snippet_with_applicability, span_lint_and_sugg,
};
use crate::utils::{contains_name, get_pat_name, paths, single_segment_path, span_lint_and_sugg};
use clippy_utils::source::snippet_with_applicability;
use clippy_utils::ty::match_type;
use if_chain::if_chain;
use rustc_errors::Applicability;

View file

@ -1,10 +1,11 @@
use clippy_utils::source::snippet_opt;
use clippy_utils::ty::is_isize_or_usize;
use rustc_errors::Applicability;
use rustc_hir::{Expr, ExprKind};
use rustc_lint::LateContext;
use rustc_middle::ty::{self, FloatTy, Ty};
use crate::utils::{in_constant, snippet_opt, span_lint_and_sugg};
use crate::utils::{in_constant, span_lint_and_sugg};
use super::{utils, CAST_LOSSLESS};

View file

@ -1,12 +1,12 @@
use clippy_utils::source::snippet_with_applicability;
use if_chain::if_chain;
use rustc_ast::LitKind;
use rustc_errors::Applicability;
use rustc_hir::{Expr, ExprKind};
use rustc_lint::LateContext;
use rustc_middle::ty::{self, UintTy};
use if_chain::if_chain;
use crate::utils::{snippet_with_applicability, span_lint_and_then};
use crate::utils::span_lint_and_then;
use super::CHAR_LIT_AS_U8;

View file

@ -1,10 +1,10 @@
use crate::utils::span_lint_and_sugg;
use clippy_utils::source::snippet_with_applicability;
use rustc_errors::Applicability;
use rustc_hir::Expr;
use rustc_lint::LateContext;
use rustc_middle::ty::{self, Ty, UintTy};
use crate::utils::{snippet_with_applicability, span_lint_and_sugg};
use super::{utils, FN_TO_NUMERIC_CAST};
pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>, cast_from: Ty<'_>, cast_to: Ty<'_>) {

View file

@ -1,10 +1,10 @@
use crate::utils::span_lint_and_sugg;
use clippy_utils::source::snippet_with_applicability;
use rustc_errors::Applicability;
use rustc_hir::Expr;
use rustc_lint::LateContext;
use rustc_middle::ty::{self, Ty};
use crate::utils::{snippet_with_applicability, span_lint_and_sugg};
use super::{utils, FN_TO_NUMERIC_CAST_WITH_TRUNCATION};
pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>, cast_from: Ty<'_>, cast_to: Ty<'_>) {

View file

@ -1,3 +1,5 @@
use clippy_utils::source::snippet_opt;
use if_chain::if_chain;
use rustc_ast::{LitFloatType, LitIntType, LitKind};
use rustc_errors::Applicability;
use rustc_hir::{Expr, ExprKind, Lit, UnOp};
@ -5,9 +7,7 @@ use rustc_lint::{LateContext, LintContext};
use rustc_middle::lint::in_external_macro;
use rustc_middle::ty::{self, FloatTy, InferTy, Ty};
use if_chain::if_chain;
use crate::utils::{numeric_literal::NumericLiteral, snippet_opt, span_lint_and_sugg};
use crate::utils::{numeric_literal::NumericLiteral, span_lint_and_sugg};
use super::UNNECESSARY_CAST;

View file

@ -1,5 +1,6 @@
//! lint on manually implemented checked conversions that could be transformed into `try_from`
use clippy_utils::source::snippet_with_applicability;
use if_chain::if_chain;
use rustc_ast::ast::LitKind;
use rustc_errors::Applicability;
@ -9,7 +10,7 @@ use rustc_middle::lint::in_external_macro;
use rustc_semver::RustcVersion;
use rustc_session::{declare_tool_lint, impl_lint_pass};
use crate::utils::{meets_msrv, snippet_with_applicability, span_lint_and_sugg, SpanlessEq};
use crate::utils::{meets_msrv, span_lint_and_sugg, SpanlessEq};
const CHECKED_CONVERSIONS_MSRV: RustcVersion = RustcVersion::new(1, 34, 0);

View file

@ -1,5 +1,6 @@
//! calculate cognitive complexity and warn about overly complex functions
use clippy_utils::source::snippet_opt;
use clippy_utils::ty::is_type_diagnostic_item;
use rustc_ast::ast::Attribute;
use rustc_hir::intravisit::{walk_expr, FnKind, NestedVisitorMap, Visitor};
@ -10,7 +11,7 @@ use rustc_session::{declare_tool_lint, impl_lint_pass};
use rustc_span::source_map::Span;
use rustc_span::{sym, BytePos};
use crate::utils::{snippet_opt, span_lint_and_help, LimitStack};
use crate::utils::{span_lint_and_help, LimitStack};
declare_clippy_lint! {
/// **What it does:** Checks for methods with high cognitive complexity.

View file

@ -12,14 +12,15 @@
//!
//! This lint is **warn** by default
use clippy_utils::source::{snippet_block, snippet_block_with_applicability};
use if_chain::if_chain;
use rustc_ast::ast;
use rustc_errors::Applicability;
use rustc_lint::{EarlyContext, EarlyLintPass};
use rustc_session::{declare_lint_pass, declare_tool_lint};
use crate::utils::sugg::Sugg;
use crate::utils::{snippet_block, snippet_block_with_applicability, span_lint_and_sugg, span_lint_and_then};
use rustc_errors::Applicability;
use crate::utils::{span_lint_and_sugg, span_lint_and_then};
declare_clippy_lint! {
/// **What it does:** Checks for nested `if` statements which can be collapsed

View file

@ -1,4 +1,5 @@
use crate::utils::{match_def_path, paths, snippet, span_lint_and_sugg};
use crate::utils::{match_def_path, paths, span_lint_and_sugg};
use clippy_utils::source::snippet;
use if_chain::if_chain;
use rustc_errors::Applicability;
use rustc_hir::{Expr, ExprKind};

View file

@ -1,4 +1,5 @@
use crate::utils::{snippet_opt, span_lint_and_help, span_lint_and_sugg};
use crate::utils::{span_lint_and_help, span_lint_and_sugg};
use clippy_utils::source::snippet_opt;
use rustc_ast::ast;
use rustc_ast::tokenstream::TokenStream;
use rustc_errors::Applicability;

View file

@ -1,7 +1,6 @@
use crate::utils::{
any_parent_is_automatically_derived, contains_name, match_def_path, paths, snippet_with_macro_callsite,
};
use crate::utils::{any_parent_is_automatically_derived, contains_name, match_def_path, paths};
use crate::utils::{span_lint_and_note, span_lint_and_sugg};
use clippy_utils::source::snippet_with_macro_callsite;
use if_chain::if_chain;
use rustc_data_structures::fx::FxHashSet;
use rustc_errors::Applicability;

View file

@ -1,3 +1,5 @@
use clippy_utils::source::snippet;
use if_chain::if_chain;
use rustc_ast::ast::{LitFloatType, LitIntType, LitKind};
use rustc_errors::Applicability;
use rustc_hir::{
@ -11,9 +13,7 @@ use rustc_middle::{
};
use rustc_session::{declare_lint_pass, declare_tool_lint};
use if_chain::if_chain;
use crate::utils::{snippet, span_lint_and_sugg};
use crate::utils::span_lint_and_sugg;
declare_clippy_lint! {
/// **What it does:** Checks for usage of unconstrained numeric literals which may cause default numeric fallback in type

View file

@ -1,4 +1,5 @@
use crate::utils::{get_parent_node, in_macro, is_allowed, snippet_with_context, span_lint_and_sugg};
use crate::utils::{get_parent_node, in_macro, is_allowed, span_lint_and_sugg};
use clippy_utils::source::snippet_with_context;
use clippy_utils::ty::peel_mid_ty_refs;
use rustc_ast::util::parser::PREC_PREFIX;
use rustc_errors::Applicability;

View file

@ -1,12 +1,13 @@
//! Lint on unnecessary double comparisons. Some examples:
use clippy_utils::source::snippet_with_applicability;
use rustc_errors::Applicability;
use rustc_hir::{BinOpKind, Expr, ExprKind};
use rustc_lint::{LateContext, LateLintPass};
use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_span::source_map::Span;
use crate::utils::{eq_expr_value, snippet_with_applicability, span_lint_and_sugg};
use crate::utils::{eq_expr_value, span_lint_and_sugg};
declare_clippy_lint! {
/// **What it does:** Checks for double comparisons that could be simplified to a single expression.

View file

@ -1,3 +1,4 @@
use clippy_utils::source::snippet_with_applicability;
use clippy_utils::ty::match_type;
use if_chain::if_chain;
use rustc_errors::Applicability;
@ -8,7 +9,7 @@ use rustc_span::source_map::Spanned;
use crate::consts::{constant, Constant};
use crate::utils::paths;
use crate::utils::{snippet_with_applicability, span_lint_and_sugg};
use crate::utils::span_lint_and_sugg;
declare_clippy_lint! {
/// **What it does:** Checks for calculation of subsecond microseconds or milliseconds

View file

@ -1,6 +1,7 @@
use crate::utils::span_lint_and_then;
use crate::utils::SpanlessEq;
use crate::utils::{get_item_name, paths, snippet, snippet_opt};
use crate::utils::{snippet_with_applicability, span_lint_and_then};
use crate::utils::{get_item_name, paths};
use clippy_utils::source::{snippet, snippet_opt, snippet_with_applicability};
use clippy_utils::ty::{is_type_diagnostic_item, match_type};
use if_chain::if_chain;
use rustc_errors::Applicability;

View file

@ -1,7 +1,8 @@
//! lint on enum variants that are prefixed or suffixed by the same characters
use crate::utils::{camel_case, is_present_in_source};
use crate::utils::camel_case;
use crate::utils::{span_lint, span_lint_and_help};
use clippy_utils::source::is_present_in_source;
use rustc_ast::ast::{EnumDef, Item, ItemKind, VisibilityKind};
use rustc_lint::{EarlyContext, EarlyLintPass, Lint};
use rustc_session::{declare_tool_lint, impl_lint_pass};

View file

@ -1,7 +1,8 @@
use crate::utils::{
ast_utils::is_useless_with_eq_exprs, eq_expr_value, higher, in_macro, is_expn_of, multispan_sugg, snippet,
span_lint, span_lint_and_then,
ast_utils::is_useless_with_eq_exprs, eq_expr_value, higher, in_macro, is_expn_of, multispan_sugg, span_lint,
span_lint_and_then,
};
use clippy_utils::source::snippet;
use clippy_utils::ty::{implements_trait, is_copy};
use if_chain::if_chain;
use rustc_errors::Applicability;

View file

@ -1,5 +1,6 @@
use clippy_utils::higher;
use clippy_utils::higher::VecArgs;
use clippy_utils::source::snippet_opt;
use clippy_utils::ty::{implements_trait, type_is_unsafe_function};
use if_chain::if_chain;
use rustc_errors::Applicability;
@ -9,7 +10,7 @@ use rustc_middle::lint::in_external_macro;
use rustc_middle::ty::{self, Ty};
use rustc_session::{declare_lint_pass, declare_tool_lint};
use crate::utils::{is_adjusted, iter_input_pats, snippet_opt, span_lint_and_sugg, span_lint_and_then};
use crate::utils::{is_adjusted, iter_input_pats, span_lint_and_sugg, span_lint_and_then};
declare_clippy_lint! {
/// **What it does:** Checks for closures which just call another function where

View file

@ -1,11 +1,14 @@
use crate::utils::{indent_of, span_lint_and_then};
use clippy_utils::source::indent_of;
use if_chain::if_chain;
use rustc_errors::Applicability;
use rustc_hir::{Item, ItemKind};
use rustc_lint::{LateContext, LateLintPass};
use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_span::sym;
use crate::utils::span_lint_and_then;
declare_clippy_lint! {
/// **What it does:** Warns on any exported `enum`s that are not tagged `#[non_exhaustive]`
///

View file

@ -1,7 +1,6 @@
use crate::utils::paths;
use crate::utils::{
is_expn_of, last_path_segment, match_def_path, match_function_call, snippet, snippet_opt, span_lint_and_then,
};
use crate::utils::{is_expn_of, last_path_segment, match_def_path, match_function_call, span_lint_and_then};
use clippy_utils::source::{snippet, snippet_opt};
use clippy_utils::ty::is_type_diagnostic_item;
use if_chain::if_chain;
use rustc_ast::ast::LitKind;

View file

@ -1,4 +1,5 @@
use crate::utils::{differing_macro_contexts, snippet_opt, span_lint_and_help, span_lint_and_note};
use crate::utils::{differing_macro_contexts, span_lint_and_help, span_lint_and_note};
use clippy_utils::source::snippet_opt;
use if_chain::if_chain;
use rustc_ast::ast::{BinOpKind, Block, Expr, ExprKind, StmtKind, UnOp};
use rustc_lint::{EarlyContext, EarlyLintPass};

View file

@ -1,8 +1,8 @@
use crate::utils::{
attr_by_name, attrs::is_proc_macro, is_trait_impl_item, iter_input_pats, match_def_path, must_use_attr,
path_to_local, return_ty, snippet, snippet_opt, span_lint, span_lint_and_help, span_lint_and_then,
trait_ref_of_method,
path_to_local, return_ty, span_lint, span_lint_and_help, span_lint_and_then, trait_ref_of_method,
};
use clippy_utils::source::{snippet, snippet_opt};
use clippy_utils::ty::{is_must_use_ty, is_type_diagnostic_item, type_is_unsafe_function};
use if_chain::if_chain;
use rustc_ast::ast::Attribute;

View file

@ -1,6 +1,7 @@
//! lint on using `x.get(x.len() - 1)` instead of `x.last()`
use crate::utils::{snippet_with_applicability, span_lint_and_sugg, SpanlessEq};
use crate::utils::{span_lint_and_sugg, SpanlessEq};
use clippy_utils::source::snippet_with_applicability;
use clippy_utils::ty::is_type_diagnostic_item;
use if_chain::if_chain;
use rustc_ast::ast::LitKind;

View file

@ -1,3 +1,4 @@
use clippy_utils::source::snippet;
use if_chain::if_chain;
use rustc_hir::{BinOp, BinOpKind, Expr, ExprKind};
use rustc_lint::{LateContext, LateLintPass};
@ -6,7 +7,7 @@ use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_span::source_map::Span;
use crate::consts::{constant_simple, Constant};
use crate::utils::{clip, snippet, span_lint, unsext};
use crate::utils::{clip, span_lint, unsext};
declare_clippy_lint! {
/// **What it does:** Checks for identity operations, e.g., `x + 0`.

View file

@ -1,4 +1,5 @@
use crate::utils::{method_chain_args, snippet_with_applicability, span_lint_and_sugg};
use crate::utils::{method_chain_args, span_lint_and_sugg};
use clippy_utils::source::snippet_with_applicability;
use clippy_utils::ty::is_type_diagnostic_item;
use if_chain::if_chain;
use rustc_errors::Applicability;

View file

@ -1,4 +1,5 @@
use crate::utils;
use clippy_utils::source::snippet_with_macro_callsite;
use if_chain::if_chain;
use rustc_hir::{Expr, ExprKind};
use rustc_lint::{LateContext, LateLintPass, LintContext};
@ -82,13 +83,13 @@ impl LateLintPass<'_> for IfThenSomeElseNone {
if let ExprKind::Path(ref els_call_qpath) = els_expr.kind;
if utils::match_qpath(els_call_qpath, &utils::paths::OPTION_NONE);
then {
let cond_snip = utils::snippet_with_macro_callsite(cx, cond.span, "[condition]");
let cond_snip = snippet_with_macro_callsite(cx, cond.span, "[condition]");
let cond_snip = if matches!(cond.kind, ExprKind::Unary(_, _) | ExprKind::Binary(_, _, _)) {
format!("({})", cond_snip)
} else {
cond_snip.into_owned()
};
let arg_snip = utils::snippet_with_macro_callsite(cx, then_arg.span, "");
let arg_snip = snippet_with_macro_callsite(cx, then_arg.span, "");
let closure_body = if then_block.stmts.is_empty() {
arg_snip.into_owned()
} else {

View file

@ -1,4 +1,5 @@
use crate::utils::{match_panic_def_id, snippet_opt, span_lint_and_then};
use crate::utils::{match_panic_def_id, span_lint_and_then};
use clippy_utils::source::snippet_opt;
use if_chain::if_chain;
use rustc_errors::Applicability;
use rustc_hir::intravisit::FnKind;

View file

@ -1,3 +1,5 @@
use clippy_utils::source::snippet;
use if_chain::if_chain;
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::Applicability;
use rustc_hir::{self as hir, ExprKind};
@ -5,9 +7,7 @@ use rustc_lint::{LateContext, LateLintPass};
use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_span::symbol::Symbol;
use if_chain::if_chain;
use crate::utils::{snippet, span_lint_and_sugg};
use crate::utils::span_lint_and_sugg;
declare_clippy_lint! {
/// **What it does:** Checks for struct constructors where all fields are shorthand and

View file

@ -1,11 +1,12 @@
//! lint on blocks unnecessarily using >= with a + 1 or - 1
use clippy_utils::source::snippet_opt;
use rustc_ast::ast::{BinOpKind, Expr, ExprKind, Lit, LitKind};
use rustc_errors::Applicability;
use rustc_lint::{EarlyContext, EarlyLintPass};
use rustc_session::{declare_lint_pass, declare_tool_lint};
use crate::utils::{snippet_opt, span_lint_and_sugg};
use crate::utils::span_lint_and_sugg;
declare_clippy_lint! {
/// **What it does:** Checks for usage of `x >= y + 1` or `x - 1 >= y` (and `<=`) in a block

View file

@ -1,6 +1,7 @@
//! lint when there is a large size difference between variants on an enum
use crate::utils::{snippet_opt, span_lint_and_then};
use crate::utils::span_lint_and_then;
use clippy_utils::source::snippet_opt;
use rustc_errors::Applicability;
use rustc_hir::{Item, ItemKind, VariantData};
use rustc_lint::{LateContext, LateLintPass};

View file

@ -1,13 +1,13 @@
use clippy_utils::source::snippet;
use if_chain::if_chain;
use rustc_hir::{Expr, ExprKind};
use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::mir::interpret::ConstValue;
use rustc_middle::ty::{self, ConstKind};
use rustc_session::{declare_tool_lint, impl_lint_pass};
use if_chain::if_chain;
use crate::rustc_target::abi::LayoutOf;
use crate::utils::{snippet, span_lint_and_help};
use crate::utils::span_lint_and_help;
declare_clippy_lint! {
/// **What it does:** Checks for local arrays that may be too large.

View file

@ -1,7 +1,5 @@
use crate::utils::{
get_item_name, get_parent_as_impl, is_allowed, snippet_with_applicability, span_lint, span_lint_and_sugg,
span_lint_and_then,
};
use crate::utils::{get_item_name, get_parent_as_impl, is_allowed, span_lint, span_lint_and_sugg, span_lint_and_then};
use clippy_utils::source::snippet_with_applicability;
use if_chain::if_chain;
use rustc_ast::ast::LitKind;
use rustc_data_structures::fx::FxHashSet;

View file

@ -1,4 +1,5 @@
use crate::utils::{path_to_local_id, snippet, span_lint_and_then, visitors::LocalUsedVisitor};
use crate::utils::{path_to_local_id, span_lint_and_then, visitors::LocalUsedVisitor};
use clippy_utils::source::snippet;
use if_chain::if_chain;
use rustc_errors::Applicability;
use rustc_hir as hir;

View file

@ -4,8 +4,9 @@
use crate::utils::{
in_macro,
numeric_literal::{NumericLiteral, Radix},
snippet_opt, span_lint_and_sugg,
span_lint_and_sugg,
};
use clippy_utils::source::snippet_opt;
use if_chain::if_chain;
use rustc_ast::ast::{Expr, ExprKind, Lit, LitKind};
use rustc_errors::Applicability;

View file

@ -1,7 +1,8 @@
use super::{
get_span_of_entire_for_loop, make_iterator_snippet, IncrementVisitor, InitializeVisitor, EXPLICIT_COUNTER_LOOP,
};
use crate::utils::{get_enclosing_block, is_integer_const, snippet_with_applicability, span_lint_and_sugg};
use crate::utils::{get_enclosing_block, is_integer_const, span_lint_and_sugg};
use clippy_utils::source::snippet_with_applicability;
use if_chain::if_chain;
use rustc_errors::Applicability;
use rustc_hir::intravisit::{walk_block, walk_expr};

View file

@ -1,5 +1,6 @@
use super::EXPLICIT_INTO_ITER_LOOP;
use crate::utils::{snippet_with_applicability, span_lint_and_sugg};
use crate::utils::span_lint_and_sugg;
use clippy_utils::source::snippet_with_applicability;
use rustc_errors::Applicability;
use rustc_hir::Expr;
use rustc_lint::LateContext;

View file

@ -1,4 +1,6 @@
use super::EXPLICIT_ITER_LOOP;
use crate::utils::{match_trait_method, paths, span_lint_and_sugg};
use clippy_utils::source::snippet_with_applicability;
use clippy_utils::ty::{is_type_diagnostic_item, match_type};
use rustc_errors::Applicability;
use rustc_hir::{Expr, Mutability};
@ -6,8 +8,6 @@ use rustc_lint::LateContext;
use rustc_middle::ty::{self, Ty, TyS};
use rustc_span::sym;
use crate::utils::{match_trait_method, paths, snippet_with_applicability, span_lint_and_sugg};
pub(super) fn check(cx: &LateContext<'_>, args: &[Expr<'_>], arg: &Expr<'_>, method_name: &str) {
let should_lint = match method_name {
"iter" | "iter_mut" => is_ref_iterable_type(cx, &args[0]),

View file

@ -1,6 +1,7 @@
use super::FOR_KV_MAP;
use crate::utils::visitors::LocalUsedVisitor;
use crate::utils::{multispan_sugg, paths, snippet, span_lint_and_then, sugg};
use crate::utils::{multispan_sugg, paths, span_lint_and_then, sugg};
use clippy_utils::source::snippet;
use clippy_utils::ty::{is_type_diagnostic_item, match_type};
use rustc_hir::{BorrowKind, Expr, ExprKind, Mutability, Pat, PatKind};
use rustc_lint::LateContext;

View file

@ -1,6 +1,8 @@
use super::FOR_LOOPS_OVER_FALLIBLES;
use crate::utils::{snippet, span_lint_and_help};
use clippy_utils::source::snippet;
use clippy_utils::ty::is_type_diagnostic_item;
use super::FOR_LOOPS_OVER_FALLIBLES;
use crate::utils::span_lint_and_help;
use rustc_hir::{Expr, Pat};
use rustc_lint::LateContext;
use rustc_span::symbol::sym;

View file

@ -1,6 +1,7 @@
use super::{get_span_of_entire_for_loop, IncrementVisitor, InitializeVisitor, MANUAL_MEMCPY};
use crate::utils::sugg::Sugg;
use crate::utils::{get_enclosing_block, higher, path_to_local, snippet, span_lint_and_sugg, sugg};
use crate::utils::{get_enclosing_block, higher, path_to_local, span_lint_and_sugg, sugg};
use clippy_utils::source::snippet;
use clippy_utils::ty::is_type_diagnostic_item;
use if_chain::if_chain;
use rustc_ast::ast;

View file

@ -1,6 +1,7 @@
use super::NEEDLESS_COLLECT;
use crate::utils::sugg::Sugg;
use crate::utils::{is_trait_method, path_to_local_id, paths, snippet, span_lint_and_sugg, span_lint_and_then};
use crate::utils::{is_trait_method, path_to_local_id, paths, span_lint_and_sugg, span_lint_and_then};
use clippy_utils::source::snippet;
use clippy_utils::ty::{is_type_diagnostic_item, match_type};
use if_chain::if_chain;
use rustc_errors::Applicability;

View file

@ -1,9 +1,10 @@
use super::NEEDLESS_RANGE_LOOP;
use crate::utils::visitors::LocalUsedVisitor;
use crate::utils::{
contains_name, higher, is_integer_const, match_trait_method, multispan_sugg, path_to_local_id, paths, snippet,
contains_name, higher, is_integer_const, match_trait_method, multispan_sugg, path_to_local_id, paths,
span_lint_and_then, sugg, SpanlessEq,
};
use clippy_utils::source::snippet;
use clippy_utils::ty::has_iter_method;
use if_chain::if_chain;
use rustc_ast::ast;

View file

@ -1,5 +1,6 @@
use super::SAME_ITEM_PUSH;
use crate::utils::{snippet_with_macro_callsite, span_lint_and_help};
use crate::utils::span_lint_and_help;
use clippy_utils::source::snippet_with_macro_callsite;
use clippy_utils::ty::{implements_trait, is_type_diagnostic_item};
use if_chain::if_chain;
use rustc_hir::def::{DefKind, Res};

View file

@ -1,5 +1,6 @@
use super::{get_span_of_entire_for_loop, SINGLE_ELEMENT_LOOP};
use crate::utils::{indent_of, single_segment_path, snippet, span_lint_and_sugg};
use crate::utils::{single_segment_path, span_lint_and_sugg};
use clippy_utils::source::{indent_of, snippet};
use if_chain::if_chain;
use rustc_errors::Applicability;
use rustc_hir::{BorrowKind, Expr, ExprKind, Pat, PatKind};

View file

@ -1,5 +1,6 @@
use super::WHILE_LET_LOOP;
use crate::utils::{snippet_with_applicability, span_lint_and_sugg};
use crate::utils::span_lint_and_sugg;
use clippy_utils::source::snippet_with_applicability;
use rustc_errors::Applicability;
use rustc_hir::{Block, Expr, ExprKind, MatchSource, StmtKind};
use rustc_lint::{LateContext, LintContext};

View file

@ -3,8 +3,9 @@ use super::WHILE_LET_ON_ITERATOR;
use crate::utils::usage::mutated_variables;
use crate::utils::{
get_enclosing_block, is_refutable, is_trait_method, last_path_segment, path_to_local, path_to_local_id,
snippet_with_applicability, span_lint_and_sugg,
span_lint_and_sugg,
};
use clippy_utils::source::snippet_with_applicability;
use clippy_utils::ty::implements_trait;
use if_chain::if_chain;
use rustc_errors::Applicability;

View file

@ -1,4 +1,5 @@
use crate::utils::{in_macro, snippet, span_lint_and_sugg};
use crate::utils::{in_macro, span_lint_and_sugg};
use clippy_utils::source::snippet;
use hir::def::{DefKind, Res};
use if_chain::if_chain;
use rustc_ast::ast;

View file

@ -1,9 +1,10 @@
use clippy_utils::source::snippet;
use if_chain::if_chain;
use rustc_hir::{Crate, Expr, ExprKind, QPath};
use rustc_lint::{LateContext, LateLintPass};
use rustc_session::{declare_tool_lint, impl_lint_pass};
use crate::utils::{is_entrypoint_fn, is_no_std_crate, snippet, span_lint_and_help};
use if_chain::if_chain;
use crate::utils::{is_entrypoint_fn, is_no_std_crate, span_lint_and_help};
declare_clippy_lint! {
/// **What it does:** Checks for recursion using the entrypoint.

View file

@ -1,5 +1,6 @@
use crate::utils::paths::FUTURE_FROM_GENERATOR;
use crate::utils::{match_function_call, position_before_rarrow, snippet_block, snippet_opt, span_lint_and_then};
use crate::utils::{match_function_call, span_lint_and_then};
use clippy_utils::source::{position_before_rarrow, snippet_block, snippet_opt};
use if_chain::if_chain;
use rustc_errors::Applicability;
use rustc_hir::intravisit::FnKind;

View file

@ -1,11 +1,9 @@
use crate::{
map_unit_fn::OPTION_MAP_UNIT_FN,
matches::MATCH_AS_REF,
utils::{
is_allowed, match_def_path, match_var, paths, peel_hir_expr_refs, snippet_with_applicability,
snippet_with_context, span_lint_and_sugg,
},
utils::{is_allowed, match_def_path, match_var, paths, peel_hir_expr_refs, span_lint_and_sugg},
};
use clippy_utils::source::{snippet_with_applicability, snippet_with_context};
use clippy_utils::ty::{can_partially_move_ty, is_type_diagnostic_item, peel_mid_ty_refs_is_mutable};
use rustc_ast::util::parser::PREC_POSTFIX;
use rustc_errors::Applicability;

View file

@ -1,4 +1,5 @@
use crate::utils::{meets_msrv, snippet_opt, span_lint_and_then};
use crate::utils::{meets_msrv, span_lint_and_then};
use clippy_utils::source::snippet_opt;
use if_chain::if_chain;
use rustc_ast::ast::{Attribute, Item, ItemKind, StructField, Variant, VariantData, VisibilityKind};
use rustc_attr as attr;

View file

@ -1,6 +1,5 @@
use crate::utils::{
indent_of, match_qpath, path_to_local_id, paths, reindent_multiline, snippet_opt, span_lint_and_sugg,
};
use crate::utils::{match_qpath, path_to_local_id, paths, span_lint_and_sugg};
use clippy_utils::source::{indent_of, reindent_multiline, snippet_opt};
use clippy_utils::ty::is_type_diagnostic_item;
use if_chain::if_chain;
use rustc_errors::Applicability;

View file

@ -1,9 +1,7 @@
use crate::consts::{constant, Constant};
use crate::utils::usage::mutated_variables;
use crate::utils::{
eq_expr_value, higher, match_def_path, meets_msrv, multispan_sugg, paths, snippet, span_lint_and_then,
};
use crate::utils::{eq_expr_value, higher, match_def_path, meets_msrv, multispan_sugg, paths, span_lint_and_then};
use clippy_utils::source::snippet;
use if_chain::if_chain;
use rustc_ast::ast::LitKind;
use rustc_hir::def::Res;

View file

@ -1,6 +1,7 @@
use crate::consts::constant_simple;
use crate::utils;
use crate::utils::{path_to_local_id, sugg};
use clippy_utils::source::{indent_of, reindent_multiline, snippet_opt};
use clippy_utils::ty::is_type_diagnostic_item;
use if_chain::if_chain;
use rustc_errors::Applicability;
@ -105,12 +106,12 @@ fn lint_manual_unwrap_or<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
None
};
if let Some(or_arm) = applicable_or_arm(match_arms);
if let Some(or_body_snippet) = utils::snippet_opt(cx, or_arm.body.span);
if let Some(indent) = utils::indent_of(cx, expr.span);
if let Some(or_body_snippet) = snippet_opt(cx, or_arm.body.span);
if let Some(indent) = indent_of(cx, expr.span);
if constant_simple(cx, cx.typeck_results(), or_arm.body).is_some();
then {
let reindented_or_body =
utils::reindent_multiline(or_body_snippet.into(), true, Some(indent));
reindent_multiline(or_body_snippet.into(), true, Some(indent));
utils::span_lint_and_sugg(
cx,
MANUAL_UNWRAP_OR, expr.span,

View file

@ -1,5 +1,6 @@
use crate::utils::is_trait_method;
use crate::utils::{remove_blocks, snippet_with_applicability, span_lint_and_sugg};
use crate::utils::{remove_blocks, span_lint_and_sugg};
use clippy_utils::source::snippet_with_applicability;
use clippy_utils::ty::{is_copy, is_type_diagnostic_item};
use if_chain::if_chain;
use rustc_errors::Applicability;

View file

@ -1,4 +1,5 @@
use crate::utils::{iter_input_pats, method_chain_args, snippet, span_lint_and_then};
use crate::utils::{iter_input_pats, method_chain_args, span_lint_and_then};
use clippy_utils::source::snippet;
use clippy_utils::ty::is_type_diagnostic_item;
use if_chain::if_chain;
use rustc_errors::Applicability;

View file

@ -1,4 +1,5 @@
use crate::utils::{snippet, span_lint_and_sugg};
use crate::utils::span_lint_and_sugg;
use clippy_utils::source::snippet;
use clippy_utils::ty::{is_type_diagnostic_item, is_type_lang_item};
use if_chain::if_chain;
use rustc_errors::Applicability;

View file

@ -2,12 +2,12 @@ use crate::consts::{constant, miri_to_const, Constant};
use crate::utils::sugg::Sugg;
use crate::utils::visitors::LocalUsedVisitor;
use crate::utils::{
expr_block, get_parent_expr, in_macro, indent_of, is_allowed, is_expn_of, is_refutable, is_wild, match_qpath,
meets_msrv, multispan_sugg, path_to_local, path_to_local_id, peel_hir_pat_refs, peel_n_hir_expr_refs,
remove_blocks, snippet, snippet_block, snippet_opt, snippet_with_applicability, span_lint_and_help,
get_parent_expr, in_macro, is_allowed, is_expn_of, is_refutable, is_wild, match_qpath, meets_msrv, multispan_sugg,
path_to_local, path_to_local_id, peel_hir_pat_refs, peel_n_hir_expr_refs, remove_blocks, span_lint_and_help,
span_lint_and_note, span_lint_and_sugg, span_lint_and_then, strip_pat_refs,
};
use crate::utils::{paths, search_same, SpanlessEq, SpanlessHash};
use clippy_utils::source::{expr_block, indent_of, snippet, snippet_block, snippet_opt, snippet_with_applicability};
use clippy_utils::ty::{implements_trait, is_type_diagnostic_item, match_type, peel_mid_ty_refs};
use if_chain::if_chain;
use rustc_ast::ast::LitKind;
@ -1614,7 +1614,8 @@ where
mod redundant_pattern_match {
use super::REDUNDANT_PATTERN_MATCHING;
use crate::utils::{is_trait_method, match_qpath, paths, snippet, span_lint_and_then};
use crate::utils::{is_trait_method, match_qpath, paths, span_lint_and_then};
use clippy_utils::source::snippet;
use if_chain::if_chain;
use rustc_ast::ast::LitKind;
use rustc_errors::Applicability;

View file

@ -1,4 +1,5 @@
use crate::utils::{match_def_path, paths, snippet, span_lint_and_then};
use crate::utils::{match_def_path, paths, span_lint_and_then};
use clippy_utils::source::snippet;
use clippy_utils::ty::walk_ptrs_ty_depth;
use if_chain::if_chain;
use rustc_errors::Applicability;

View file

@ -1,7 +1,9 @@
use crate::utils::{
in_macro, match_def_path, match_qpath, meets_msrv, paths, snippet, snippet_with_applicability, span_lint_and_help,
span_lint_and_sugg, span_lint_and_then,
in_macro, match_def_path, match_qpath, meets_msrv, paths, span_lint_and_help, span_lint_and_sugg,
span_lint_and_then,
};
use clippy_utils::is_diagnostic_assoc_item;
use clippy_utils::source::{snippet, snippet_with_applicability};
use if_chain::if_chain;
use rustc_errors::Applicability;
use rustc_hir::def_id::DefId;
@ -13,8 +15,6 @@ use rustc_session::{declare_tool_lint, impl_lint_pass};
use rustc_span::source_map::Span;
use rustc_span::symbol::sym;
use clippy_utils::is_diagnostic_assoc_item;
declare_clippy_lint! {
/// **What it does:** Checks for `mem::replace()` on an `Option` with
/// `None`.

View file

@ -1,8 +1,9 @@
use super::{contains_return, BIND_INSTEAD_OF_MAP};
use crate::utils::{
in_macro, match_qpath, method_calls, multispan_sugg_with_applicability, paths, remove_blocks, snippet,
snippet_with_macro_callsite, span_lint_and_sugg, span_lint_and_then, visitors::find_all_ret_expressions,
in_macro, match_qpath, method_calls, multispan_sugg_with_applicability, paths, remove_blocks, span_lint_and_sugg,
span_lint_and_then, visitors::find_all_ret_expressions,
};
use clippy_utils::source::{snippet, snippet_with_macro_callsite};
use clippy_utils::ty::match_type;
use if_chain::if_chain;
use rustc_errors::Applicability;

View file

@ -1,4 +1,5 @@
use crate::utils::{snippet_with_applicability, span_lint_and_sugg};
use crate::utils::span_lint_and_sugg;
use clippy_utils::source::snippet_with_applicability;
use clippy_utils::ty::is_type_diagnostic_item;
use if_chain::if_chain;
use rustc_errors::Applicability;

View file

@ -1,4 +1,5 @@
use crate::utils::{paths, snippet_with_macro_callsite, span_lint_and_sugg};
use crate::utils::{paths, span_lint_and_sugg};
use clippy_utils::source::snippet_with_macro_callsite;
use clippy_utils::ty::{is_type_diagnostic_item, match_type};
use rustc_errors::Applicability;
use rustc_hir as hir;

View file

@ -1,4 +1,5 @@
use crate::utils::{is_expn_of, snippet, snippet_with_applicability, span_lint_and_sugg};
use crate::utils::{is_expn_of, span_lint_and_sugg};
use clippy_utils::source::{snippet, snippet_with_applicability};
use clippy_utils::ty::is_type_diagnostic_item;
use if_chain::if_chain;
use rustc_errors::Applicability;

View file

@ -1,4 +1,5 @@
use crate::utils::{is_trait_method, path_to_local_id, snippet, span_lint_and_sugg, SpanlessEq};
use crate::utils::{is_trait_method, path_to_local_id, span_lint_and_sugg, SpanlessEq};
use clippy_utils::source::snippet;
use if_chain::if_chain;
use rustc_errors::Applicability;
use rustc_hir as hir;

View file

@ -1,4 +1,5 @@
use crate::utils::{is_trait_method, meets_msrv, snippet, span_lint, span_lint_and_sugg};
use crate::utils::{is_trait_method, meets_msrv, span_lint, span_lint_and_sugg};
use clippy_utils::source::snippet;
use rustc_errors::Applicability;
use rustc_hir as hir;
use rustc_lint::LateContext;

View file

@ -1,4 +1,5 @@
use crate::utils::{is_trait_method, snippet, span_lint, span_lint_and_sugg};
use crate::utils::{is_trait_method, span_lint, span_lint_and_sugg};
use clippy_utils::source::snippet;
use rustc_errors::Applicability;
use rustc_hir as hir;
use rustc_lint::LateContext;

View file

@ -1,5 +1,6 @@
use crate::methods::derefs_to_slice;
use crate::utils::{get_parent_expr, paths, snippet_with_applicability, span_lint_and_sugg};
use crate::utils::{get_parent_expr, paths, span_lint_and_sugg};
use clippy_utils::source::snippet_with_applicability;
use clippy_utils::ty::{is_type_diagnostic_item, match_type};
use if_chain::if_chain;
use rustc_errors::Applicability;

View file

@ -1,5 +1,6 @@
use super::INEFFICIENT_TO_STRING;
use crate::utils::{match_def_path, paths, snippet_with_applicability, span_lint_and_then};
use crate::utils::{match_def_path, paths, span_lint_and_then};
use clippy_utils::source::snippet_with_applicability;
use clippy_utils::ty::{is_type_diagnostic_item, walk_ptrs_ty_depth};
use if_chain::if_chain;
use rustc_errors::Applicability;

View file

@ -1,5 +1,6 @@
use crate::methods::derefs_to_slice;
use crate::utils::{paths, snippet_with_applicability, span_lint_and_sugg};
use crate::utils::{paths, span_lint_and_sugg};
use clippy_utils::source::snippet_with_applicability;
use clippy_utils::ty::{is_type_diagnostic_item, match_type};
use rustc_errors::Applicability;
use rustc_hir::Expr;

View file

@ -1,5 +1,6 @@
use crate::methods::derefs_to_slice;
use crate::utils::{get_parent_expr, higher, snippet_with_applicability, span_lint_and_sugg};
use crate::utils::{get_parent_expr, higher, span_lint_and_sugg};
use clippy_utils::source::snippet_with_applicability;
use clippy_utils::ty::is_type_diagnostic_item;
use if_chain::if_chain;
use rustc_ast::ast;

View file

@ -1,5 +1,6 @@
use crate::consts::{constant, Constant};
use crate::utils::{is_trait_method, snippet_with_applicability, span_lint_and_sugg};
use crate::utils::{is_trait_method, span_lint_and_sugg};
use clippy_utils::source::snippet_with_applicability;
use if_chain::if_chain;
use rustc_errors::Applicability;
use rustc_hir as hir;

View file

@ -1,4 +1,5 @@
use crate::utils::{is_trait_method, snippet, span_lint_and_sugg};
use crate::utils::{is_trait_method, span_lint_and_sugg};
use clippy_utils::source::snippet;
use rustc_errors::Applicability;
use rustc_hir as hir;
use rustc_lint::LateContext;

View file

@ -1,4 +1,5 @@
use crate::utils::{match_qpath, snippet_with_applicability, span_lint_and_sugg};
use crate::utils::{match_qpath, span_lint_and_sugg};
use clippy_utils::source::snippet_with_applicability;
use if_chain::if_chain;
use rustc_ast::ast;
use rustc_errors::Applicability;

View file

@ -1,4 +1,5 @@
use crate::utils::{is_trait_method, snippet, span_lint_and_sugg};
use crate::utils::{is_trait_method, span_lint_and_sugg};
use clippy_utils::source::snippet;
use clippy_utils::ty::is_type_diagnostic_item;
use if_chain::if_chain;
use rustc_errors::Applicability;

View file

@ -1,4 +1,5 @@
use crate::utils::{is_trait_method, snippet, span_lint_and_sugg};
use crate::utils::{is_trait_method, span_lint_and_sugg};
use clippy_utils::source::snippet;
use clippy_utils::ty::is_type_diagnostic_item;
use rustc_errors::Applicability;
use rustc_hir as hir;

View file

@ -1,5 +1,6 @@
use crate::utils::usage::mutated_variables;
use crate::utils::{meets_msrv, snippet, span_lint, span_lint_and_sugg};
use crate::utils::{meets_msrv, span_lint, span_lint_and_sugg};
use clippy_utils::source::snippet;
use clippy_utils::ty::is_type_diagnostic_item;
use rustc_errors::Applicability;
use rustc_hir as hir;

View file

@ -52,6 +52,7 @@ mod wrong_self_convention;
mod zst_offset;
use bind_instead_of_map::BindInsteadOfMap;
use clippy_utils::source::snippet_with_applicability;
use clippy_utils::ty::{contains_ty, implements_trait, is_copy, is_type_diagnostic_item};
use if_chain::if_chain;
use rustc_ast::ast;
@ -68,8 +69,8 @@ use rustc_typeck::hir_ty_to_ty;
use crate::utils::{
contains_return, get_trait_def_id, in_macro, iter_input_pats, match_def_path, match_qpath, method_calls,
method_chain_args, paths, return_ty, single_segment_path, snippet_with_applicability, span_lint,
span_lint_and_help, span_lint_and_sugg, SpanlessEq,
method_chain_args, paths, return_ty, single_segment_path, span_lint, span_lint_and_help, span_lint_and_sugg,
SpanlessEq,
};
declare_clippy_lint! {

View file

@ -1,4 +1,5 @@
use crate::utils::{match_def_path, meets_msrv, path_to_local_id, paths, remove_blocks, snippet, span_lint_and_sugg};
use crate::utils::{match_def_path, meets_msrv, path_to_local_id, paths, remove_blocks, span_lint_and_sugg};
use clippy_utils::source::snippet;
use clippy_utils::ty::is_type_diagnostic_item;
use if_chain::if_chain;
use rustc_errors::Applicability;

View file

@ -1,4 +1,5 @@
use crate::utils::{match_qpath, paths, snippet, span_lint_and_sugg};
use crate::utils::{match_qpath, paths, span_lint_and_sugg};
use clippy_utils::source::snippet;
use clippy_utils::ty::is_type_diagnostic_item;
use rustc_errors::Applicability;
use rustc_hir as hir;

View file

@ -1,4 +1,5 @@
use crate::utils::{differing_macro_contexts, snippet_with_applicability, span_lint_and_then};
use crate::utils::{differing_macro_contexts, span_lint_and_then};
use clippy_utils::source::snippet_with_applicability;
use clippy_utils::ty::is_copy;
use clippy_utils::ty::is_type_diagnostic_item;
use rustc_data_structures::fx::FxHashSet;

View file

@ -1,8 +1,6 @@
use crate::utils::eager_or_lazy::is_lazyness_candidate;
use crate::utils::{
contains_return, get_trait_def_id, last_path_segment, paths, snippet, snippet_with_applicability,
snippet_with_macro_callsite, span_lint_and_sugg,
};
use crate::utils::{contains_return, get_trait_def_id, last_path_segment, paths, span_lint_and_sugg};
use clippy_utils::source::{snippet, snippet_with_applicability, snippet_with_macro_callsite};
use clippy_utils::ty::{implements_trait, is_type_diagnostic_item, match_type};
use if_chain::if_chain;
use rustc_errors::Applicability;

View file

@ -1,6 +1,5 @@
use crate::utils::{
is_trait_method, snippet, snippet_with_applicability, span_lint_and_help, span_lint_and_sugg, strip_pat_refs,
};
use crate::utils::{is_trait_method, span_lint_and_help, span_lint_and_sugg, strip_pat_refs};
use clippy_utils::source::{snippet, snippet_with_applicability};
use clippy_utils::ty::is_type_diagnostic_item;
use if_chain::if_chain;
use rustc_errors::Applicability;

View file

@ -1,5 +1,6 @@
use crate::methods::get_hint_if_single_char_arg;
use crate::utils::{snippet_with_applicability, span_lint_and_sugg};
use crate::utils::span_lint_and_sugg;
use clippy_utils::source::snippet_with_applicability;
use rustc_errors::Applicability;
use rustc_hir as hir;
use rustc_lint::LateContext;

View file

@ -1,5 +1,6 @@
use crate::methods::get_hint_if_single_char_arg;
use crate::utils::{snippet_with_applicability, span_lint_and_sugg};
use crate::utils::span_lint_and_sugg;
use clippy_utils::source::snippet_with_applicability;
use rustc_errors::Applicability;
use rustc_hir as hir;
use rustc_lint::LateContext;

View file

@ -1,4 +1,5 @@
use crate::utils::{method_chain_args, snippet_with_applicability, span_lint_and_sugg};
use crate::utils::{method_chain_args, span_lint_and_sugg};
use clippy_utils::source::snippet_with_applicability;
use clippy_utils::ty::is_type_diagnostic_item;
use rustc_errors::Applicability;
use rustc_hir as hir;

View file

@ -1,6 +1,5 @@
use crate::utils::{
is_trait_method, path_to_local_id, remove_blocks, snippet_with_applicability, span_lint_and_sugg, strip_pat_refs,
};
use crate::utils::{is_trait_method, path_to_local_id, remove_blocks, span_lint_and_sugg, strip_pat_refs};
use clippy_utils::source::snippet_with_applicability;
use if_chain::if_chain;
use rustc_ast::ast;
use rustc_errors::Applicability;

View file

@ -1,5 +1,6 @@
use crate::utils::span_lint_and_sugg;
use crate::utils::{eager_or_lazy, usage};
use crate::utils::{snippet, span_lint_and_sugg};
use clippy_utils::source::snippet;
use clippy_utils::ty::is_type_diagnostic_item;
use rustc_errors::Applicability;
use rustc_hir as hir;

View file

@ -1,4 +1,5 @@
use crate::utils::{get_parent_expr, match_trait_method, paths, snippet_with_applicability, span_lint_and_sugg};
use crate::utils::{get_parent_expr, match_trait_method, paths, span_lint_and_sugg};
use clippy_utils::source::snippet_with_applicability;
use clippy_utils::ty::walk_ptrs_ty_depth;
use if_chain::if_chain;
use rustc_errors::Applicability;

View file

@ -1,3 +1,4 @@
use clippy_utils::source::{snippet, snippet_opt};
use clippy_utils::ty::implements_trait;
use if_chain::if_chain;
use rustc_ast::ast::LitKind;
@ -19,8 +20,8 @@ use crate::consts::{constant, Constant};
use crate::utils::sugg::Sugg;
use crate::utils::{
get_item_name, get_parent_expr, higher, in_constant, is_diagnostic_assoc_item, is_integer_const, iter_input_pats,
last_path_segment, match_qpath, snippet, snippet_opt, span_lint, span_lint_and_sugg, span_lint_and_then,
span_lint_hir_and_then, unsext, SpanlessEq,
last_path_segment, match_qpath, span_lint, span_lint_and_sugg, span_lint_and_then, span_lint_hir_and_then, unsext,
SpanlessEq,
};
declare_clippy_lint! {

View file

@ -1,4 +1,5 @@
use crate::utils::{snippet_opt, span_lint, span_lint_and_help, span_lint_and_sugg, span_lint_and_then};
use crate::utils::{span_lint, span_lint_and_help, span_lint_and_sugg, span_lint_and_then};
use clippy_utils::source::snippet_opt;
use rustc_ast::ast::{
BindingMode, Expr, ExprKind, GenericParamKind, Generics, Lit, LitFloatType, LitIntType, LitKind, Mutability,
NodeId, Pat, PatKind, UnOp,

View file

@ -3,7 +3,8 @@
//! This lint is **warn** by default
use crate::utils::sugg::Sugg;
use crate::utils::{is_expn_of, parent_node_is_if_expr, snippet_with_applicability, span_lint, span_lint_and_sugg};
use crate::utils::{is_expn_of, parent_node_is_if_expr, span_lint, span_lint_and_sugg};
use clippy_utils::source::snippet_with_applicability;
use rustc_ast::ast::LitKind;
use rustc_errors::Applicability;
use rustc_hir::{BinOpKind, Block, Expr, ExprKind, StmtKind, UnOp};

Some files were not shown because too many files have changed in this diff Show more