mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-24 21:53:23 +00:00
Auto merge of #6907 - camsteffen:ty-utils, r=flip1995
Move some utils to `clippy_utils::ty` changelog: none `clippy_utils::*` has become a giant junk drawer. This is one step to clean it up a bit. One motivation is that I believe the long import statements cause more merge conflicts.
This commit is contained in:
commit
9cd0f504a9
114 changed files with 578 additions and 509 deletions
|
@ -1,7 +1,6 @@
|
|||
use crate::utils::{
|
||||
eq_expr_value, get_trait_def_id, implements_trait, snippet_opt, span_lint_and_then, trait_ref_of_method,
|
||||
};
|
||||
use crate::utils::{eq_expr_value, get_trait_def_id, snippet_opt, span_lint_and_then, trait_ref_of_method};
|
||||
use crate::utils::{higher, sugg};
|
||||
use clippy_utils::ty::implements_trait;
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::utils::{implements_trait, snippet, span_lint_and_then};
|
||||
use crate::utils::{snippet, span_lint_and_then};
|
||||
use clippy_utils::ty::implements_trait;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{AsyncGeneratorKind, Body, BodyId, ExprKind, GeneratorKind, QPath};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::utils::{
|
||||
differing_macro_contexts, get_parent_expr, implements_trait, snippet_block_with_applicability, span_lint,
|
||||
span_lint_and_sugg,
|
||||
differing_macro_contexts, get_parent_expr, snippet_block_with_applicability, span_lint, span_lint_and_sugg,
|
||||
};
|
||||
use clippy_utils::ty::implements_trait;
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::utils::{
|
||||
eq_expr_value, get_trait_def_id, implements_trait, in_macro, is_type_diagnostic_item, paths, snippet_opt,
|
||||
span_lint_and_sugg, span_lint_and_then,
|
||||
eq_expr_value, get_trait_def_id, in_macro, paths, snippet_opt, span_lint_and_sugg, span_lint_and_then,
|
||||
};
|
||||
use clippy_utils::ty::{implements_trait, is_type_diagnostic_item};
|
||||
use if_chain::if_chain;
|
||||
use rustc_ast::ast::LitKind;
|
||||
use rustc_errors::Applicability;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use crate::utils::{
|
||||
contains_name, get_pat_name, match_type, paths, single_segment_path, snippet_with_applicability, span_lint_and_sugg,
|
||||
contains_name, get_pat_name, paths, single_segment_path, snippet_with_applicability, span_lint_and_sugg,
|
||||
};
|
||||
use clippy_utils::ty::match_type;
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{BinOpKind, BorrowKind, Expr, ExprKind, UnOp};
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
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, is_isize_or_usize, snippet_opt, span_lint_and_sugg};
|
||||
use crate::utils::{in_constant, snippet_opt, span_lint_and_sugg};
|
||||
|
||||
use super::{utils, CAST_LOSSLESS};
|
||||
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
use clippy_utils::ty::is_isize_or_usize;
|
||||
use rustc_hir::Expr;
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_middle::ty::{self, FloatTy, Ty};
|
||||
|
||||
use crate::utils::{is_isize_or_usize, span_lint};
|
||||
use crate::utils::span_lint;
|
||||
|
||||
use super::{utils, CAST_POSSIBLE_TRUNCATION};
|
||||
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
use clippy_utils::ty::is_isize_or_usize;
|
||||
use rustc_hir::Expr;
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_middle::ty::Ty;
|
||||
|
||||
use crate::utils::{is_isize_or_usize, span_lint};
|
||||
use crate::utils::span_lint;
|
||||
|
||||
use super::{utils, CAST_POSSIBLE_WRAP};
|
||||
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
use clippy_utils::ty::is_isize_or_usize;
|
||||
use rustc_hir::Expr;
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_middle::ty::{self, FloatTy, Ty};
|
||||
|
||||
use crate::utils::{is_isize_or_usize, span_lint};
|
||||
use crate::utils::span_lint;
|
||||
|
||||
use super::{utils, CAST_PRECISION_LOSS};
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
//! calculate cognitive complexity and warn about overly complex functions
|
||||
|
||||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use rustc_ast::ast::Attribute;
|
||||
use rustc_hir::intravisit::{walk_expr, FnKind, NestedVisitorMap, Visitor};
|
||||
use rustc_hir::{Body, Expr, ExprKind, FnDecl, HirId};
|
||||
|
@ -9,7 +10,7 @@ use rustc_session::{declare_tool_lint, impl_lint_pass};
|
|||
use rustc_span::source_map::Span;
|
||||
use rustc_span::{sym, BytePos};
|
||||
|
||||
use crate::utils::{is_type_diagnostic_item, snippet_opt, span_lint_and_help, LimitStack};
|
||||
use crate::utils::{snippet_opt, span_lint_and_help, LimitStack};
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for methods with high cognitive complexity.
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use crate::utils::{
|
||||
get_trait_def_id, if_sequence, implements_trait, parent_node_is_if_expr, paths, span_lint_and_help, SpanlessEq,
|
||||
};
|
||||
use crate::utils::{get_trait_def_id, if_sequence, parent_node_is_if_expr, paths, span_lint_and_help, SpanlessEq};
|
||||
use clippy_utils::ty::implements_trait;
|
||||
use rustc_hir::{BinOpKind, Expr, ExprKind};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::utils::{is_copy, span_lint_and_note};
|
||||
use crate::utils::span_lint_and_note;
|
||||
use clippy_utils::ty::is_copy;
|
||||
use rustc_hir::{Impl, Item, ItemKind};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::utils::{get_parent_node, in_macro, is_allowed, peel_mid_ty_refs, snippet_with_context, span_lint_and_sugg};
|
||||
use crate::utils::{get_parent_node, in_macro, is_allowed, snippet_with_context, span_lint_and_sugg};
|
||||
use clippy_utils::ty::peel_mid_ty_refs;
|
||||
use rustc_ast::util::parser::PREC_PREFIX;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{BorrowKind, Expr, ExprKind, HirId, MatchSource, Mutability, Node, UnOp};
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
use crate::utils::paths;
|
||||
use crate::utils::{
|
||||
get_trait_def_id, is_allowed, is_automatically_derived, is_copy, match_def_path, span_lint_and_help,
|
||||
span_lint_and_note, span_lint_and_then,
|
||||
get_trait_def_id, is_allowed, is_automatically_derived, match_def_path, span_lint_and_help, span_lint_and_note,
|
||||
span_lint_and_then,
|
||||
};
|
||||
use clippy_utils::ty::is_copy;
|
||||
use if_chain::if_chain;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::intravisit::{walk_expr, walk_fn, walk_item, FnKind, NestedVisitorMap, Visitor};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::utils::{
|
||||
implements_trait, is_entrypoint_fn, is_expn_of, is_type_diagnostic_item, match_panic_def_id, method_chain_args,
|
||||
return_ty, span_lint, span_lint_and_note,
|
||||
is_entrypoint_fn, is_expn_of, match_panic_def_id, method_chain_args, return_ty, span_lint, span_lint_and_note,
|
||||
};
|
||||
use clippy_utils::ty::{implements_trait, is_type_diagnostic_item};
|
||||
use if_chain::if_chain;
|
||||
use itertools::Itertools;
|
||||
use rustc_ast::ast::{Async, AttrKind, Attribute, FnKind, FnRetTy, ItemKind};
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::utils::{is_copy, match_def_path, paths, span_lint_and_note};
|
||||
use crate::utils::{match_def_path, paths, span_lint_and_note};
|
||||
use clippy_utils::ty::is_copy;
|
||||
use if_chain::if_chain;
|
||||
use rustc_hir::{Expr, ExprKind};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use clippy_utils::ty::match_type;
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{BinOpKind, Expr, ExprKind};
|
||||
|
@ -7,7 +8,7 @@ use rustc_span::source_map::Spanned;
|
|||
|
||||
use crate::consts::{constant, Constant};
|
||||
use crate::utils::paths;
|
||||
use crate::utils::{match_type, snippet_with_applicability, span_lint_and_sugg};
|
||||
use crate::utils::{snippet_with_applicability, span_lint_and_sugg};
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for calculation of subsecond microseconds or milliseconds
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use crate::utils::SpanlessEq;
|
||||
use crate::utils::{get_item_name, is_type_diagnostic_item, match_type, paths, snippet, snippet_opt};
|
||||
use crate::utils::{get_item_name, paths, snippet, snippet_opt};
|
||||
use crate::utils::{snippet_with_applicability, span_lint_and_then};
|
||||
use clippy_utils::ty::{is_type_diagnostic_item, match_type};
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use crate::utils::{
|
||||
ast_utils::is_useless_with_eq_exprs, eq_expr_value, higher, implements_trait, in_macro, is_copy, 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, snippet,
|
||||
span_lint, span_lint_and_then,
|
||||
};
|
||||
use clippy_utils::ty::{implements_trait, is_copy};
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{BinOpKind, BorrowKind, Expr, ExprKind, StmtKind};
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use clippy_utils::ty::contains_ty;
|
||||
use rustc_hir::intravisit;
|
||||
use rustc_hir::{self, AssocItemKind, Body, FnDecl, HirId, HirIdSet, Impl, ItemKind, Node};
|
||||
use rustc_infer::infer::TyCtxtInferExt;
|
||||
|
@ -10,7 +11,7 @@ use rustc_target::abi::LayoutOf;
|
|||
use rustc_target::spec::abi::Abi;
|
||||
use rustc_typeck::expr_use_visitor::{ConsumeMode, Delegate, ExprUseVisitor, PlaceBase, PlaceWithHirId};
|
||||
|
||||
use crate::utils::{contains_ty, span_lint};
|
||||
use crate::utils::span_lint;
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct BoxedLocal {
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
use clippy_utils::higher;
|
||||
use clippy_utils::higher::VecArgs;
|
||||
use clippy_utils::ty::{implements_trait, type_is_unsafe_function};
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{def_id, Expr, ExprKind, Param, PatKind, QPath};
|
||||
|
@ -6,12 +9,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::{
|
||||
implements_trait, is_adjusted, iter_input_pats, snippet_opt, span_lint_and_sugg, span_lint_and_then,
|
||||
type_is_unsafe_function,
|
||||
};
|
||||
use clippy_utils::higher;
|
||||
use clippy_utils::higher::VecArgs;
|
||||
use crate::utils::{is_adjusted, iter_input_pats, snippet_opt, span_lint_and_sugg, span_lint_and_then};
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for closures which just call another function where
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::utils::{is_expn_of, is_type_diagnostic_item, match_panic_def_id, method_chain_args, span_lint_and_then};
|
||||
use crate::utils::{is_expn_of, match_panic_def_id, method_chain_args, span_lint_and_then};
|
||||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use if_chain::if_chain;
|
||||
use rustc_hir as hir;
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use crate::utils::paths;
|
||||
use crate::utils::{
|
||||
is_expn_of, is_type_diagnostic_item, last_path_segment, match_def_path, match_function_call, snippet, snippet_opt,
|
||||
span_lint_and_then,
|
||||
is_expn_of, last_path_segment, match_def_path, match_function_call, snippet, snippet_opt, span_lint_and_then,
|
||||
};
|
||||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use if_chain::if_chain;
|
||||
use rustc_ast::ast::LitKind;
|
||||
use rustc_errors::Applicability;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{def, Expr, ExprKind, PrimTy, QPath, TyKind};
|
||||
|
@ -6,7 +7,6 @@ use rustc_middle::ty::Ty;
|
|||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::symbol::sym;
|
||||
|
||||
use crate::utils::is_type_diagnostic_item;
|
||||
use crate::utils::span_lint_and_sugg;
|
||||
use crate::utils::sugg::Sugg;
|
||||
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
use crate::utils::{
|
||||
attr_by_name, attrs::is_proc_macro, is_must_use_ty, is_trait_impl_item, is_type_diagnostic_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, type_is_unsafe_function,
|
||||
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,
|
||||
};
|
||||
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;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
//! lint on using `x.get(x.len() - 1)` instead of `x.last()`
|
||||
|
||||
use crate::utils::{is_type_diagnostic_item, snippet_with_applicability, span_lint_and_sugg, SpanlessEq};
|
||||
use crate::utils::{snippet_with_applicability, span_lint_and_sugg, SpanlessEq};
|
||||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use if_chain::if_chain;
|
||||
use rustc_ast::ast::LitKind;
|
||||
use rustc_errors::Applicability;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::utils::{is_type_diagnostic_item, span_lint_and_help, SpanlessEq};
|
||||
use crate::utils::{span_lint_and_help, SpanlessEq};
|
||||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use if_chain::if_chain;
|
||||
use rustc_hir::intravisit::{self as visit, NestedVisitorMap, Visitor};
|
||||
use rustc_hir::{Expr, ExprKind, MatchSource};
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::utils::{is_type_diagnostic_item, method_chain_args, snippet_with_applicability, span_lint_and_sugg};
|
||||
use crate::utils::{method_chain_args, snippet_with_applicability, span_lint_and_sugg};
|
||||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{Expr, ExprKind, MatchSource, PatKind, QPath};
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
use clippy_utils::ty::{implements_trait, match_type};
|
||||
use rustc_hir::{BorrowKind, Expr, ExprKind};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
|
||||
use crate::utils::{get_trait_def_id, higher, implements_trait, match_qpath, match_type, paths, span_lint};
|
||||
use crate::utils::{get_trait_def_id, higher, match_qpath, paths, span_lint};
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for iteration that is guaranteed to be infinite.
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
use clippy_utils::ty::{implements_trait, is_type_diagnostic_item};
|
||||
use if_chain::if_chain;
|
||||
use rustc_hir::{ImplItem, ImplItemKind};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::sym;
|
||||
|
||||
use crate::utils::{
|
||||
get_trait_def_id, implements_trait, is_type_diagnostic_item, paths, return_ty, span_lint_and_help,
|
||||
trait_ref_of_method,
|
||||
};
|
||||
use crate::utils::{get_trait_def_id, paths, return_ty, span_lint_and_help, trait_ref_of_method};
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for the definition of inherent methods with a signature of `to_string(&self) -> String`.
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use clippy_utils::ty::{is_must_use_ty, match_type};
|
||||
use if_chain::if_chain;
|
||||
use rustc_hir::{Local, PatKind};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
|
@ -5,7 +6,7 @@ use rustc_middle::lint::in_external_macro;
|
|||
use rustc_middle::ty::subst::GenericArgKind;
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
|
||||
use crate::utils::{is_must_use_func_call, is_must_use_ty, match_type, paths, span_lint_and_help};
|
||||
use crate::utils::{is_must_use_func_call, paths, span_lint_and_help};
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for `let _ = <expr>`
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use super::EXPLICIT_ITER_LOOP;
|
||||
use crate::utils::{match_trait_method, snippet_with_applicability, span_lint_and_sugg};
|
||||
use clippy_utils::ty::{is_type_diagnostic_item, match_type};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{Expr, Mutability};
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_middle::ty::{self, Ty, TyS};
|
||||
use rustc_span::sym;
|
||||
|
||||
use crate::utils::{is_type_diagnostic_item, match_type, paths};
|
||||
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 {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use super::FOR_KV_MAP;
|
||||
use crate::utils::visitors::LocalUsedVisitor;
|
||||
use crate::utils::{is_type_diagnostic_item, match_type, multispan_sugg, paths, snippet, span_lint_and_then, sugg};
|
||||
use crate::utils::{multispan_sugg, paths, snippet, span_lint_and_then, sugg};
|
||||
use clippy_utils::ty::{is_type_diagnostic_item, match_type};
|
||||
use rustc_hir::{BorrowKind, Expr, ExprKind, Mutability, Pat, PatKind};
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_middle::ty;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use super::FOR_LOOPS_OVER_FALLIBLES;
|
||||
use crate::utils::{is_type_diagnostic_item, snippet, span_lint_and_help};
|
||||
use crate::utils::{snippet, span_lint_and_help};
|
||||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use rustc_hir::{Expr, Pat};
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_span::symbol::sym;
|
||||
|
|
|
@ -1,8 +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, is_type_diagnostic_item, path_to_local, snippet, span_lint_and_sugg, sugg,
|
||||
};
|
||||
use crate::utils::{get_enclosing_block, higher, path_to_local, snippet, span_lint_and_sugg, sugg};
|
||||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use if_chain::if_chain;
|
||||
use rustc_ast::ast;
|
||||
use rustc_errors::Applicability;
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
use super::NEEDLESS_COLLECT;
|
||||
use crate::utils::sugg::Sugg;
|
||||
use crate::utils::{
|
||||
is_trait_method, is_type_diagnostic_item, match_type, 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, snippet, span_lint_and_sugg, span_lint_and_then};
|
||||
use clippy_utils::ty::{is_type_diagnostic_item, match_type};
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::intravisit::{walk_block, walk_expr, NestedVisitorMap, Visitor};
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
use super::NEEDLESS_RANGE_LOOP;
|
||||
use crate::utils::visitors::LocalUsedVisitor;
|
||||
use crate::utils::{
|
||||
contains_name, has_iter_method, higher, is_integer_const, match_trait_method, multispan_sugg, path_to_local_id,
|
||||
paths, snippet, span_lint_and_then, sugg, SpanlessEq,
|
||||
contains_name, higher, is_integer_const, match_trait_method, multispan_sugg, path_to_local_id, paths, snippet,
|
||||
span_lint_and_then, sugg, SpanlessEq,
|
||||
};
|
||||
use clippy_utils::ty::has_iter_method;
|
||||
use if_chain::if_chain;
|
||||
use rustc_ast::ast;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use super::SAME_ITEM_PUSH;
|
||||
use crate::utils::{implements_trait, is_type_diagnostic_item, snippet_with_macro_callsite, span_lint_and_help};
|
||||
use crate::utils::{snippet_with_macro_callsite, span_lint_and_help};
|
||||
use clippy_utils::ty::{implements_trait, is_type_diagnostic_item};
|
||||
use if_chain::if_chain;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use crate::utils::{
|
||||
get_parent_expr, has_iter_method, implements_trait, is_integer_const, path_to_local, path_to_local_id, sugg,
|
||||
};
|
||||
use crate::utils::{get_parent_expr, is_integer_const, path_to_local, path_to_local_id, sugg};
|
||||
use clippy_utils::ty::{has_iter_method, implements_trait};
|
||||
use if_chain::if_chain;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_errors::Applicability;
|
||||
|
|
|
@ -2,16 +2,16 @@ use super::utils::{LoopNestVisitor, Nesting};
|
|||
use super::WHILE_LET_ON_ITERATOR;
|
||||
use crate::utils::usage::mutated_variables;
|
||||
use crate::utils::{
|
||||
get_enclosing_block, implements_trait, is_refutable, is_trait_method, last_path_segment, path_to_local,
|
||||
path_to_local_id, snippet_with_applicability, span_lint_and_sugg,
|
||||
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,
|
||||
};
|
||||
use clippy_utils::ty::implements_trait;
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::intravisit::{walk_block, walk_expr, NestedVisitorMap, Visitor};
|
||||
use rustc_hir::{Expr, ExprKind, HirId, MatchSource, Node, PatKind};
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_middle::hir::map::Map;
|
||||
|
||||
use rustc_span::symbol::sym;
|
||||
|
||||
pub(super) fn check(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
|
||||
|
|
|
@ -2,11 +2,11 @@ use crate::{
|
|||
map_unit_fn::OPTION_MAP_UNIT_FN,
|
||||
matches::MATCH_AS_REF,
|
||||
utils::{
|
||||
can_partially_move_ty, is_allowed, is_type_diagnostic_item, match_def_path, match_var, paths,
|
||||
peel_hir_expr_refs, peel_mid_ty_refs_is_mutable, snippet_with_applicability, snippet_with_context,
|
||||
span_lint_and_sugg,
|
||||
is_allowed, match_def_path, match_var, paths, peel_hir_expr_refs, snippet_with_applicability,
|
||||
snippet_with_context, span_lint_and_sugg,
|
||||
},
|
||||
};
|
||||
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;
|
||||
use rustc_hir::{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::utils::{
|
||||
indent_of, is_type_diagnostic_item, match_qpath, path_to_local_id, paths, reindent_multiline, snippet_opt,
|
||||
span_lint_and_sugg,
|
||||
indent_of, match_qpath, path_to_local_id, paths, reindent_multiline, snippet_opt, span_lint_and_sugg,
|
||||
};
|
||||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{Expr, ExprKind, PatKind};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use crate::consts::constant_simple;
|
||||
use crate::utils;
|
||||
use crate::utils::{path_to_local_id, sugg};
|
||||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{Arm, Expr, ExprKind, Pat, PatKind};
|
||||
|
@ -96,9 +97,9 @@ fn lint_manual_unwrap_or<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
|
|||
if_chain! {
|
||||
if let ExprKind::Match(scrutinee, match_arms, _) = expr.kind;
|
||||
let ty = cx.typeck_results().expr_ty(scrutinee);
|
||||
if let Some(case) = if utils::is_type_diagnostic_item(cx, ty, sym::option_type) {
|
||||
if let Some(case) = if is_type_diagnostic_item(cx, ty, sym::option_type) {
|
||||
Some(Case::Option)
|
||||
} else if utils::is_type_diagnostic_item(cx, ty, sym::result_type) {
|
||||
} else if is_type_diagnostic_item(cx, ty, sym::result_type) {
|
||||
Some(Case::Result)
|
||||
} else {
|
||||
None
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::utils::{
|
||||
is_copy, is_trait_method, is_type_diagnostic_item, remove_blocks, snippet_with_applicability, span_lint_and_sugg,
|
||||
};
|
||||
use crate::utils::is_trait_method;
|
||||
use crate::utils::{remove_blocks, snippet_with_applicability, span_lint_and_sugg};
|
||||
use clippy_utils::ty::{is_copy, is_type_diagnostic_item};
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
use crate::utils::{
|
||||
is_adjusted, is_trait_method, is_type_diagnostic_item, match_path, match_var, paths, remove_blocks,
|
||||
span_lint_and_sugg,
|
||||
};
|
||||
use crate::utils::{is_adjusted, is_trait_method, match_path, match_var, paths, remove_blocks, span_lint_and_sugg};
|
||||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{Body, Expr, ExprKind, Pat, PatKind, QPath, StmtKind};
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::utils::{is_type_diagnostic_item, iter_input_pats, method_chain_args, snippet, span_lint_and_then};
|
||||
use crate::utils::{iter_input_pats, method_chain_args, snippet, span_lint_and_then};
|
||||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::utils::{is_type_diagnostic_item, is_type_lang_item, snippet, span_lint_and_sugg};
|
||||
use crate::utils::{snippet, span_lint_and_sugg};
|
||||
use clippy_utils::ty::{is_type_diagnostic_item, is_type_lang_item};
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{Expr, ExprKind, LangItem, MatchSource};
|
||||
|
|
|
@ -2,13 +2,13 @@ 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, implements_trait, in_macro, indent_of, is_allowed, is_expn_of, is_refutable,
|
||||
is_type_diagnostic_item, is_wild, match_qpath, match_type, meets_msrv, multispan_sugg, path_to_local,
|
||||
path_to_local_id, peel_hir_pat_refs, peel_mid_ty_refs, peel_n_hir_expr_refs, remove_blocks, snippet, snippet_block,
|
||||
snippet_opt, snippet_with_applicability, span_lint_and_help, span_lint_and_note, span_lint_and_sugg,
|
||||
span_lint_and_then, strip_pat_refs,
|
||||
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,
|
||||
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::ty::{implements_trait, is_type_diagnostic_item, match_type, peel_mid_ty_refs};
|
||||
use if_chain::if_chain;
|
||||
use rustc_ast::ast::LitKind;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use crate::utils::{match_def_path, paths, snippet, span_lint_and_then, walk_ptrs_ty_depth};
|
||||
use crate::utils::{match_def_path, paths, snippet, span_lint_and_then};
|
||||
use clippy_utils::ty::walk_ptrs_ty_depth;
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{BorrowKind, Expr, ExprKind};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
|
||||
use std::iter;
|
||||
|
||||
declare_clippy_lint! {
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
use super::{contains_return, BIND_INSTEAD_OF_MAP};
|
||||
use crate::utils::{
|
||||
in_macro, match_qpath, match_type, method_calls, multispan_sugg_with_applicability, paths, remove_blocks, snippet,
|
||||
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,
|
||||
};
|
||||
use clippy_utils::ty::match_type;
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::utils::{is_type_diagnostic_item, snippet_with_applicability, span_lint_and_sugg};
|
||||
use crate::utils::{snippet_with_applicability, span_lint_and_sugg};
|
||||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{Expr, ExprKind};
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::utils::{is_copy, span_lint_and_then, sugg};
|
||||
use crate::utils::{span_lint_and_then, sugg};
|
||||
use clippy_utils::ty::is_copy;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
use rustc_lint::LateContext;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::utils::{is_type_diagnostic_item, match_type, paths, snippet_with_macro_callsite, span_lint_and_sugg};
|
||||
use crate::utils::{paths, snippet_with_macro_callsite, span_lint_and_sugg};
|
||||
use clippy_utils::ty::{is_type_diagnostic_item, match_type};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
use rustc_lint::LateContext;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::utils::{is_expn_of, is_type_diagnostic_item, snippet, snippet_with_applicability, span_lint_and_sugg};
|
||||
use crate::utils::{is_expn_of, snippet, snippet_with_applicability, span_lint_and_sugg};
|
||||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::utils::{is_type_diagnostic_item, span_lint_and_help};
|
||||
use crate::utils::span_lint_and_help;
|
||||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use rustc_hir as hir;
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_span::sym;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::utils::{get_parent_expr, match_type, paths, span_lint_and_help};
|
||||
use crate::utils::{get_parent_expr, paths, span_lint_and_help};
|
||||
use clippy_utils::ty::match_type;
|
||||
use if_chain::if_chain;
|
||||
use rustc_hir as hir;
|
||||
use rustc_lint::LateContext;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::utils::{get_trait_def_id, implements_trait, paths, span_lint_and_sugg, sugg};
|
||||
use crate::utils::{get_trait_def_id, paths, span_lint_and_sugg, sugg};
|
||||
use clippy_utils::ty::implements_trait;
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use crate::methods::derefs_to_slice;
|
||||
use crate::utils::{
|
||||
get_parent_expr, is_type_diagnostic_item, match_type, paths, snippet_with_applicability, span_lint_and_sugg,
|
||||
};
|
||||
use crate::utils::{get_parent_expr, paths, snippet_with_applicability, span_lint_and_sugg};
|
||||
use clippy_utils::ty::{is_type_diagnostic_item, match_type};
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use super::INEFFICIENT_TO_STRING;
|
||||
use crate::utils::{
|
||||
is_type_diagnostic_item, match_def_path, paths, snippet_with_applicability, span_lint_and_then, walk_ptrs_ty_depth,
|
||||
};
|
||||
use crate::utils::{match_def_path, paths, snippet_with_applicability, span_lint_and_then};
|
||||
use clippy_utils::ty::{is_type_diagnostic_item, walk_ptrs_ty_depth};
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::utils::{has_iter_method, match_trait_method, paths, span_lint_and_sugg};
|
||||
use crate::utils::{match_trait_method, paths, span_lint_and_sugg};
|
||||
use clippy_utils::ty::has_iter_method;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
use rustc_lint::LateContext;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use crate::methods::derefs_to_slice;
|
||||
use crate::utils::{is_type_diagnostic_item, span_lint_and_sugg};
|
||||
use crate::utils::span_lint_and_sugg;
|
||||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::methods::derefs_to_slice;
|
||||
use crate::utils::{is_type_diagnostic_item, match_type, paths, snippet_with_applicability, span_lint_and_sugg};
|
||||
|
||||
use crate::utils::{paths, snippet_with_applicability, span_lint_and_sugg};
|
||||
use clippy_utils::ty::{is_type_diagnostic_item, match_type};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::Expr;
|
||||
use rustc_lint::LateContext;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use crate::methods::derefs_to_slice;
|
||||
use crate::utils::{get_parent_expr, higher, is_type_diagnostic_item, snippet_with_applicability, span_lint_and_sugg};
|
||||
use crate::utils::{get_parent_expr, higher, snippet_with_applicability, span_lint_and_sugg};
|
||||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use if_chain::if_chain;
|
||||
use rustc_ast::ast;
|
||||
use rustc_errors::Applicability;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use crate::methods::derefs_to_slice;
|
||||
use crate::methods::iter_nth_zero;
|
||||
use crate::utils::{is_type_diagnostic_item, span_lint_and_help};
|
||||
use crate::utils::span_lint_and_help;
|
||||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use rustc_hir as hir;
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_span::symbol::sym;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::utils::{is_trait_method, is_type_diagnostic_item, snippet, span_lint_and_sugg};
|
||||
use crate::utils::{is_trait_method, snippet, span_lint_and_sugg};
|
||||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::utils::{is_trait_method, is_type_diagnostic_item, snippet, span_lint_and_sugg};
|
||||
use crate::utils::{is_trait_method, snippet, span_lint_and_sugg};
|
||||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
use rustc_lint::LateContext;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use crate::utils::usage::mutated_variables;
|
||||
use crate::utils::{is_type_diagnostic_item, meets_msrv, snippet, span_lint, span_lint_and_sugg};
|
||||
use crate::utils::{meets_msrv, snippet, span_lint, span_lint_and_sugg};
|
||||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
use rustc_lint::LateContext;
|
||||
|
|
|
@ -52,6 +52,7 @@ mod wrong_self_convention;
|
|||
mod zst_offset;
|
||||
|
||||
use bind_instead_of_map::BindInsteadOfMap;
|
||||
use clippy_utils::ty::{contains_ty, implements_trait, is_copy, is_type_diagnostic_item};
|
||||
use if_chain::if_chain;
|
||||
use rustc_ast::ast;
|
||||
use rustc_errors::Applicability;
|
||||
|
@ -66,9 +67,9 @@ use rustc_span::symbol::{sym, SymbolStr};
|
|||
use rustc_typeck::hir_ty_to_ty;
|
||||
|
||||
use crate::utils::{
|
||||
contains_return, contains_ty, get_trait_def_id, implements_trait, in_macro, is_copy, is_type_diagnostic_item,
|
||||
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,
|
||||
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,
|
||||
};
|
||||
|
||||
declare_clippy_lint! {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::utils::{implements_trait, is_type_diagnostic_item, span_lint_and_help};
|
||||
use crate::utils::span_lint_and_help;
|
||||
use clippy_utils::ty::{implements_trait, is_type_diagnostic_item};
|
||||
use if_chain::if_chain;
|
||||
use rustc_hir as hir;
|
||||
use rustc_lint::LateContext;
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
use crate::utils::{
|
||||
is_type_diagnostic_item, 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, snippet, span_lint_and_sugg};
|
||||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::utils::{is_type_diagnostic_item, match_qpath, paths, snippet, span_lint_and_sugg};
|
||||
use crate::utils::{match_qpath, paths, snippet, span_lint_and_sugg};
|
||||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
use rustc_lint::LateContext;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use crate::utils::{differing_macro_contexts, snippet_with_applicability, span_lint_and_then};
|
||||
use crate::utils::{is_copy, is_type_diagnostic_item};
|
||||
use clippy_utils::ty::is_copy;
|
||||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::intravisit::{walk_path, NestedVisitorMap, Visitor};
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
use crate::utils::eager_or_lazy::is_lazyness_candidate;
|
||||
use crate::utils::{
|
||||
contains_return, get_trait_def_id, implements_trait, is_type_diagnostic_item, last_path_segment, match_type, paths,
|
||||
snippet, snippet_with_applicability, snippet_with_macro_callsite, span_lint_and_sugg,
|
||||
contains_return, get_trait_def_id, last_path_segment, paths, snippet, snippet_with_applicability,
|
||||
snippet_with_macro_callsite, span_lint_and_sugg,
|
||||
};
|
||||
use clippy_utils::ty::{implements_trait, is_type_diagnostic_item, match_type};
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::utils::{
|
||||
is_trait_method, is_type_diagnostic_item, snippet, snippet_with_applicability, span_lint_and_help,
|
||||
span_lint_and_sugg, strip_pat_refs,
|
||||
is_trait_method, snippet, snippet_with_applicability, span_lint_and_help, span_lint_and_sugg, strip_pat_refs,
|
||||
};
|
||||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::utils::{is_type_diagnostic_item, method_chain_args, snippet_with_applicability, span_lint_and_sugg};
|
||||
use crate::utils::{method_chain_args, snippet_with_applicability, span_lint_and_sugg};
|
||||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
use rustc_lint::LateContext;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use crate::utils::{eager_or_lazy, usage};
|
||||
use crate::utils::{is_type_diagnostic_item, snippet, span_lint_and_sugg};
|
||||
use crate::utils::{snippet, span_lint_and_sugg};
|
||||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
use rustc_lint::LateContext;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::utils::{is_type_diagnostic_item, span_lint_and_help};
|
||||
use crate::utils::span_lint_and_help;
|
||||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use rustc_hir as hir;
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_span::sym;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use crate::utils::{
|
||||
get_parent_expr, match_trait_method, paths, snippet_with_applicability, span_lint_and_sugg, walk_ptrs_ty_depth,
|
||||
};
|
||||
use crate::utils::{get_parent_expr, match_trait_method, paths, snippet_with_applicability, span_lint_and_sugg};
|
||||
use clippy_utils::ty::walk_ptrs_ty_depth;
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use clippy_utils::ty::implements_trait;
|
||||
use if_chain::if_chain;
|
||||
use rustc_ast::ast::LitKind;
|
||||
use rustc_errors::Applicability;
|
||||
|
@ -17,9 +18,9 @@ use rustc_span::symbol::sym;
|
|||
use crate::consts::{constant, Constant};
|
||||
use crate::utils::sugg::Sugg;
|
||||
use crate::utils::{
|
||||
get_item_name, get_parent_expr, higher, implements_trait, 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,
|
||||
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,
|
||||
};
|
||||
|
||||
declare_clippy_lint! {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use crate::utils::qualify_min_const_fn::is_min_const_fn;
|
||||
use crate::utils::{
|
||||
fn_has_unsatisfiable_preds, has_drop, is_entrypoint_fn, meets_msrv, span_lint, trait_ref_of_method,
|
||||
};
|
||||
use crate::utils::{fn_has_unsatisfiable_preds, is_entrypoint_fn, meets_msrv, span_lint, trait_ref_of_method};
|
||||
use clippy_utils::ty::has_drop;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::intravisit::FnKind;
|
||||
use rustc_hir::{Body, Constness, FnDecl, GenericParamKind, HirId};
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::utils::{is_type_diagnostic_item, span_lint_and_sugg};
|
||||
use crate::utils::span_lint_and_sugg;
|
||||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{Expr, ExprKind, Mutability};
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
//!
|
||||
//! This lint is **warn** by default
|
||||
|
||||
use crate::utils::{is_type_diagnostic_item, span_lint};
|
||||
use crate::utils::span_lint;
|
||||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use rustc_hir::Expr;
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_middle::ty::{self, Ty};
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
use crate::utils::ptr::get_spans;
|
||||
use crate::utils::{
|
||||
get_trait_def_id, implements_trait, is_copy, is_self, is_type_diagnostic_item, multispan_sugg, paths, snippet,
|
||||
snippet_opt, span_lint_and_then,
|
||||
};
|
||||
use crate::utils::{get_trait_def_id, is_self, multispan_sugg, paths, snippet, snippet_opt, span_lint_and_then};
|
||||
use clippy_utils::ty::{implements_trait, is_copy, is_type_diagnostic_item};
|
||||
use if_chain::if_chain;
|
||||
use rustc_ast::ast::Attribute;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{Body, Expr, ExprKind, LangItem, MatchSource, QPath};
|
||||
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
||||
|
@ -175,8 +176,8 @@ fn is_some_or_ok_call<'a>(
|
|||
let outer_ty = cx.typeck_results().expr_ty(expr);
|
||||
|
||||
// Check if outer and inner type are Option
|
||||
let outer_is_some = utils::is_type_diagnostic_item(cx, outer_ty, sym::option_type);
|
||||
let inner_is_some = utils::is_type_diagnostic_item(cx, inner_ty, sym::option_type);
|
||||
let outer_is_some = is_type_diagnostic_item(cx, outer_ty, sym::option_type);
|
||||
let inner_is_some = is_type_diagnostic_item(cx, inner_ty, sym::option_type);
|
||||
|
||||
// Check for Option MSRV
|
||||
let meets_option_msrv = utils::meets_msrv(nqml.msrv.as_ref(), &NEEDLESS_QUESTION_MARK_OPTION_MSRV);
|
||||
|
@ -185,8 +186,8 @@ fn is_some_or_ok_call<'a>(
|
|||
}
|
||||
|
||||
// Check if outer and inner type are Result
|
||||
let outer_is_result = utils::is_type_diagnostic_item(cx, outer_ty, sym::result_type);
|
||||
let inner_is_result = utils::is_type_diagnostic_item(cx, inner_ty, sym::result_type);
|
||||
let outer_is_result = is_type_diagnostic_item(cx, outer_ty, sym::result_type);
|
||||
let inner_is_result = is_type_diagnostic_item(cx, inner_ty, sym::result_type);
|
||||
|
||||
// Additional check: if the error type of the Result can be converted
|
||||
// via the From trait, then don't match
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use clippy_utils::ty::implements_trait;
|
||||
use if_chain::if_chain;
|
||||
use rustc_hir::{BinOpKind, Expr, ExprKind, UnOp};
|
||||
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
||||
|
@ -60,7 +61,7 @@ impl<'tcx> LateLintPass<'tcx> for NoNegCompOpForPartialOrd {
|
|||
|
||||
let implements_ord = {
|
||||
if let Some(id) = utils::get_trait_def_id(cx, &paths::ORD) {
|
||||
utils::implements_trait(cx, ty, id, &[])
|
||||
implements_trait(cx, ty, id, &[])
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
@ -68,7 +69,7 @@ impl<'tcx> LateLintPass<'tcx> for NoNegCompOpForPartialOrd {
|
|||
|
||||
let implements_partial_ord = {
|
||||
if let Some(id) = cx.tcx.lang_items().partial_ord_trait() {
|
||||
utils::implements_trait(cx, ty, id, &[])
|
||||
implements_trait(cx, ty, id, &[])
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::utils::{has_drop, snippet_opt, span_lint, span_lint_and_sugg};
|
||||
use crate::utils::{snippet_opt, span_lint, span_lint_and_sugg};
|
||||
use clippy_utils::ty::has_drop;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_hir::{BinOpKind, BlockCheckMode, Expr, ExprKind, Stmt, StmtKind, UnsafeSource};
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::utils::{match_type, paths, span_lint};
|
||||
use crate::utils::{paths, span_lint};
|
||||
use clippy_utils::ty::match_type;
|
||||
use rustc_ast::ast::LitKind;
|
||||
use rustc_hir::{Expr, ExprKind};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use crate::utils;
|
||||
use crate::utils::eager_or_lazy;
|
||||
use crate::utils::sugg::Sugg;
|
||||
use crate::utils::{is_type_diagnostic_item, paths, span_lint_and_sugg};
|
||||
use crate::utils::{paths, span_lint_and_sugg};
|
||||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use if_chain::if_chain;
|
||||
|
||||
use rustc_errors::Applicability;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::utils::{find_macro_calls, is_type_diagnostic_item, return_ty, span_lint_and_then};
|
||||
use crate::utils::{find_macro_calls, return_ty, span_lint_and_then};
|
||||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::intravisit::FnKind;
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use std::cmp;
|
||||
|
||||
use crate::utils::{is_copy, is_self_ty, snippet, span_lint_and_sugg};
|
||||
use crate::utils::{is_self_ty, snippet, span_lint_and_sugg};
|
||||
use clippy_utils::ty::is_copy;
|
||||
use if_chain::if_chain;
|
||||
use rustc_ast::attr;
|
||||
use rustc_errors::Applicability;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::utils::{is_type_diagnostic_item, span_lint_and_sugg};
|
||||
use crate::utils::span_lint_and_sugg;
|
||||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use if_chain::if_chain;
|
||||
use rustc_ast::ast::LitKind;
|
||||
use rustc_errors::Applicability;
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
//! Checks for usage of `&Vec[_]` and `&String`.
|
||||
|
||||
use crate::utils::ptr::get_spans;
|
||||
use crate::utils::{
|
||||
is_allowed, is_type_diagnostic_item, match_qpath, match_type, paths, snippet_opt, span_lint, span_lint_and_sugg,
|
||||
span_lint_and_then, walk_ptrs_hir_ty,
|
||||
};
|
||||
use crate::utils::{is_allowed, match_qpath, paths, snippet_opt, span_lint, span_lint_and_sugg, span_lint_and_then};
|
||||
use clippy_utils::ty::{is_type_diagnostic_item, match_type, walk_ptrs_hir_ty};
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
|
@ -7,10 +8,7 @@ use rustc_session::{declare_lint_pass, declare_tool_lint};
|
|||
use rustc_span::sym;
|
||||
|
||||
use crate::utils::sugg::Sugg;
|
||||
use crate::utils::{
|
||||
eq_expr_value, is_type_diagnostic_item, match_def_path, match_qpath, paths, snippet_with_applicability,
|
||||
span_lint_and_sugg,
|
||||
};
|
||||
use crate::utils::{eq_expr_value, match_def_path, match_qpath, paths, snippet_with_applicability, span_lint_and_sugg};
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for expressions that could be replaced by the question mark operator.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::utils::{
|
||||
fn_has_unsatisfiable_preds, has_drop, is_copy, is_type_diagnostic_item, match_def_path, paths, snippet_opt,
|
||||
span_lint_hir, span_lint_hir_and_then, walk_ptrs_ty_depth,
|
||||
fn_has_unsatisfiable_preds, match_def_path, paths, snippet_opt, span_lint_hir, span_lint_hir_and_then,
|
||||
};
|
||||
use clippy_utils::ty::{has_drop, is_copy, is_type_diagnostic_item, walk_ptrs_ty_depth};
|
||||
use if_chain::if_chain;
|
||||
use rustc_data_structures::{fx::FxHashMap, transitive_relation::TransitiveRelation};
|
||||
use rustc_errors::Applicability;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use clippy_utils::ty::is_type_lang_item;
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{Expr, ExprKind, LangItem};
|
||||
|
@ -5,7 +6,7 @@ use rustc_lint::{LateContext, LateLintPass, LintContext};
|
|||
use rustc_middle::{lint::in_external_macro, ty::TyS};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
|
||||
use crate::utils::{is_type_lang_item, snippet_with_applicability, span_lint_and_sugg};
|
||||
use crate::utils::{snippet_with_applicability, span_lint_and_sugg};
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for redundant slicing expressions which use the full range, and
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use crate::consts::{constant_context, Constant};
|
||||
use crate::utils::{in_macro, is_type_diagnostic_item, snippet, span_lint_and_sugg};
|
||||
use crate::utils::{in_macro, snippet, span_lint_and_sugg};
|
||||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{Expr, ExprKind};
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
use crate::utils::SpanlessEq;
|
||||
use crate::utils::{
|
||||
get_parent_expr, is_allowed, match_function_call, method_calls, paths, span_lint, span_lint_and_help,
|
||||
span_lint_and_sugg,
|
||||
};
|
||||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{BinOpKind, BorrowKind, Expr, ExprKind, LangItem, QPath};
|
||||
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
||||
|
@ -7,14 +14,6 @@ use rustc_session::{declare_lint_pass, declare_tool_lint};
|
|||
use rustc_span::source_map::Spanned;
|
||||
use rustc_span::sym;
|
||||
|
||||
use if_chain::if_chain;
|
||||
|
||||
use crate::utils::SpanlessEq;
|
||||
use crate::utils::{
|
||||
get_parent_expr, is_allowed, is_type_diagnostic_item, match_function_call, method_calls, paths, span_lint,
|
||||
span_lint_and_help, span_lint_and_sugg,
|
||||
};
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for string appends of the form `x = x + y` (without
|
||||
/// `let`!).
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use crate::utils::sugg::Sugg;
|
||||
use crate::utils::{
|
||||
differing_macro_contexts, eq_expr_value, is_type_diagnostic_item, snippet_with_applicability, span_lint_and_then,
|
||||
};
|
||||
use crate::utils::{differing_macro_contexts, eq_expr_value, snippet_with_applicability, span_lint_and_then};
|
||||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{Block, Expr, ExprKind, PatKind, QPath, StmtKind};
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::utils::{is_normalizable, last_path_segment, snippet};
|
||||
use crate::utils::{last_path_segment, snippet};
|
||||
use clippy_utils::ty::is_normalizable;
|
||||
use if_chain::if_chain;
|
||||
use rustc_hir::{Expr, GenericArg, QPath, TyKind};
|
||||
use rustc_lint::LateContext;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use crate::utils::{
|
||||
differing_macro_contexts, in_macro, is_type_diagnostic_item, match_def_path, match_qpath, paths, snippet,
|
||||
snippet_with_macro_callsite, span_lint_and_sugg,
|
||||
differing_macro_contexts, in_macro, match_def_path, match_qpath, paths, snippet, snippet_with_macro_callsite,
|
||||
span_lint_and_sugg,
|
||||
};
|
||||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{Expr, ExprKind, LangItem, MatchSource, QPath};
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue