mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-28 07:30:57 +00:00
Auto merge of #6918 - camsteffen:utils-re-export, r=flip1995
Don't re-export `clippy_utils::*` changelog: none This should wrap up the utils-related really big changes. I personally don't see any more sub-modules to be added to `clippy_utils`.
This commit is contained in:
commit
6595d5571b
243 changed files with 344 additions and 399 deletions
|
@ -1,7 +1,7 @@
|
||||||
use crate::consts::{constant, Constant};
|
use crate::consts::{constant, Constant};
|
||||||
use crate::utils::{is_direct_expn_of, is_expn_of, match_panic_call};
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_help;
|
use clippy_utils::diagnostics::span_lint_and_help;
|
||||||
use clippy_utils::source::snippet_opt;
|
use clippy_utils::source::snippet_opt;
|
||||||
|
use clippy_utils::{is_direct_expn_of, is_expn_of, match_panic_call};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_hir::{Expr, ExprKind, UnOp};
|
use rustc_hir::{Expr, ExprKind, UnOp};
|
||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass};
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use crate::utils::{eq_expr_value, get_trait_def_id, trait_ref_of_method};
|
|
||||||
use crate::utils::{higher, sugg};
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_then;
|
use clippy_utils::diagnostics::span_lint_and_then;
|
||||||
use clippy_utils::source::snippet_opt;
|
use clippy_utils::source::snippet_opt;
|
||||||
use clippy_utils::ty::implements_trait;
|
use clippy_utils::ty::implements_trait;
|
||||||
|
use clippy_utils::{eq_expr_value, get_trait_def_id, trait_ref_of_method};
|
||||||
|
use clippy_utils::{higher, paths, sugg};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
|
@ -93,7 +93,7 @@ impl<'tcx> LateLintPass<'tcx> for AssignOps {
|
||||||
$($trait_name:ident),+) => {
|
$($trait_name:ident),+) => {
|
||||||
match $op {
|
match $op {
|
||||||
$(hir::BinOpKind::$trait_name => {
|
$(hir::BinOpKind::$trait_name => {
|
||||||
let [krate, module] = crate::utils::paths::OPS_MODULE;
|
let [krate, module] = paths::OPS_MODULE;
|
||||||
let path: [&str; 3] = [krate, module, concat!(stringify!($trait_name), "Assign")];
|
let path: [&str; 3] = [krate, module, concat!(stringify!($trait_name), "Assign")];
|
||||||
let trait_id = if let Some(trait_id) = get_trait_def_id($cx, &path) {
|
let trait_id = if let Some(trait_id) = get_trait_def_id($cx, &path) {
|
||||||
trait_id
|
trait_id
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::utils::match_def_path;
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_help;
|
use clippy_utils::diagnostics::span_lint_and_help;
|
||||||
|
use clippy_utils::match_def_path;
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
use rustc_hir::{Expr, ExprKind};
|
use rustc_hir::{Expr, ExprKind};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//! checks for attributes
|
//! checks for attributes
|
||||||
|
|
||||||
use crate::utils::match_panic_def_id;
|
|
||||||
use clippy_utils::diagnostics::{span_lint, span_lint_and_help, span_lint_and_sugg, span_lint_and_then};
|
use clippy_utils::diagnostics::{span_lint, span_lint_and_help, span_lint_and_sugg, span_lint_and_then};
|
||||||
|
use clippy_utils::match_panic_def_id;
|
||||||
use clippy_utils::source::{first_line_of_span, is_present_in_source, snippet_opt, without_block_comments};
|
use clippy_utils::source::{first_line_of_span, is_present_in_source, snippet_opt, without_block_comments};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_ast::{AttrKind, AttrStyle, Attribute, Lit, LitKind, MetaItemKind, NestedMetaItem};
|
use rustc_ast::{AttrKind, AttrStyle, Attribute, Lit, LitKind, MetaItemKind, NestedMetaItem};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::utils::{match_def_path, paths};
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_note;
|
use clippy_utils::diagnostics::span_lint_and_note;
|
||||||
|
use clippy_utils::{match_def_path, paths};
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
use rustc_hir::{AsyncGeneratorKind, Body, BodyId, GeneratorKind};
|
use rustc_hir::{AsyncGeneratorKind, Body, BodyId, GeneratorKind};
|
||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::consts::{constant, Constant};
|
use crate::consts::{constant, Constant};
|
||||||
use crate::utils::sugg::Sugg;
|
|
||||||
use clippy_utils::diagnostics::{span_lint, span_lint_and_then};
|
use clippy_utils::diagnostics::{span_lint, span_lint_and_then};
|
||||||
|
use clippy_utils::sugg::Sugg;
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_ast::ast::LitKind;
|
use rustc_ast::ast::LitKind;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::utils::{differing_macro_contexts, get_parent_expr};
|
|
||||||
use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg};
|
use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg};
|
||||||
use clippy_utils::source::snippet_block_with_applicability;
|
use clippy_utils::source::snippet_block_with_applicability;
|
||||||
use clippy_utils::ty::implements_trait;
|
use clippy_utils::ty::implements_trait;
|
||||||
|
use clippy_utils::{differing_macro_contexts, get_parent_expr};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
|
use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::utils::{eq_expr_value, get_trait_def_id, in_macro, paths};
|
|
||||||
use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then};
|
use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then};
|
||||||
use clippy_utils::source::snippet_opt;
|
use clippy_utils::source::snippet_opt;
|
||||||
use clippy_utils::ty::{implements_trait, is_type_diagnostic_item};
|
use clippy_utils::ty::{implements_trait, is_type_diagnostic_item};
|
||||||
|
use clippy_utils::{eq_expr_value, get_trait_def_id, in_macro, paths};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_ast::ast::LitKind;
|
use rustc_ast::ast::LitKind;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::utils::{contains_name, get_pat_name, paths, single_segment_path};
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_sugg;
|
use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||||
use clippy_utils::source::snippet_with_applicability;
|
use clippy_utils::source::snippet_with_applicability;
|
||||||
use clippy_utils::ty::match_type;
|
use clippy_utils::ty::match_type;
|
||||||
|
use clippy_utils::{contains_name, get_pat_name, paths, single_segment_path};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir::{BinOpKind, BorrowKind, Expr, ExprKind, UnOp};
|
use rustc_hir::{BinOpKind, BorrowKind, Expr, ExprKind, UnOp};
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use crate::utils::run_lints;
|
|
||||||
use clippy_utils::diagnostics::span_lint;
|
use clippy_utils::diagnostics::span_lint;
|
||||||
|
use clippy_utils::run_lints;
|
||||||
use rustc_hir::{hir_id::CRATE_HIR_ID, Crate};
|
use rustc_hir::{hir_id::CRATE_HIR_ID, Crate};
|
||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass};
|
||||||
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use clippy_utils::diagnostics::span_lint_and_sugg;
|
use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||||
|
use clippy_utils::in_constant;
|
||||||
use clippy_utils::source::snippet_opt;
|
use clippy_utils::source::snippet_opt;
|
||||||
use clippy_utils::ty::is_isize_or_usize;
|
use clippy_utils::ty::is_isize_or_usize;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
|
@ -6,8 +7,6 @@ use rustc_hir::{Expr, ExprKind};
|
||||||
use rustc_lint::LateContext;
|
use rustc_lint::LateContext;
|
||||||
use rustc_middle::ty::{self, FloatTy, Ty};
|
use rustc_middle::ty::{self, FloatTy, Ty};
|
||||||
|
|
||||||
use crate::utils::in_constant;
|
|
||||||
|
|
||||||
use super::{utils, CAST_LOSSLESS};
|
use super::{utils, CAST_LOSSLESS};
|
||||||
|
|
||||||
pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_op: &Expr<'_>, cast_from: Ty<'_>, cast_to: Ty<'_>) {
|
pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_op: &Expr<'_>, cast_from: Ty<'_>, cast_to: Ty<'_>) {
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
|
use clippy_utils::diagnostics::span_lint;
|
||||||
use clippy_utils::ty::is_isize_or_usize;
|
use clippy_utils::ty::is_isize_or_usize;
|
||||||
use rustc_hir::Expr;
|
use rustc_hir::Expr;
|
||||||
use rustc_lint::LateContext;
|
use rustc_lint::LateContext;
|
||||||
use rustc_middle::ty::{self, FloatTy, Ty};
|
use rustc_middle::ty::{self, FloatTy, Ty};
|
||||||
|
|
||||||
use clippy_utils::diagnostics::span_lint;
|
|
||||||
|
|
||||||
use super::{utils, CAST_POSSIBLE_TRUNCATION};
|
use super::{utils, CAST_POSSIBLE_TRUNCATION};
|
||||||
|
|
||||||
pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_from: Ty<'_>, cast_to: Ty<'_>) {
|
pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_from: Ty<'_>, cast_to: Ty<'_>) {
|
||||||
|
|
|
@ -1,14 +1,12 @@
|
||||||
use clippy_utils::diagnostics::span_lint;
|
use clippy_utils::diagnostics::span_lint;
|
||||||
|
use clippy_utils::is_hir_ty_cfg_dependant;
|
||||||
|
use if_chain::if_chain;
|
||||||
use rustc_hir::{Expr, ExprKind, GenericArg};
|
use rustc_hir::{Expr, ExprKind, GenericArg};
|
||||||
use rustc_lint::LateContext;
|
use rustc_lint::LateContext;
|
||||||
use rustc_middle::ty::{self, Ty};
|
use rustc_middle::ty::{self, Ty};
|
||||||
use rustc_span::symbol::sym;
|
use rustc_span::symbol::sym;
|
||||||
use rustc_target::abi::LayoutOf;
|
use rustc_target::abi::LayoutOf;
|
||||||
|
|
||||||
use if_chain::if_chain;
|
|
||||||
|
|
||||||
use crate::utils::is_hir_ty_cfg_dependant;
|
|
||||||
|
|
||||||
use super::CAST_PTR_ALIGNMENT;
|
use super::CAST_PTR_ALIGNMENT;
|
||||||
|
|
||||||
pub(super) fn check(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
|
pub(super) fn check(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
|
use crate::consts::{constant, Constant};
|
||||||
|
use clippy_utils::diagnostics::span_lint;
|
||||||
|
use clippy_utils::{method_chain_args, sext};
|
||||||
|
use if_chain::if_chain;
|
||||||
use rustc_hir::{Expr, ExprKind};
|
use rustc_hir::{Expr, ExprKind};
|
||||||
use rustc_lint::LateContext;
|
use rustc_lint::LateContext;
|
||||||
use rustc_middle::ty::{self, Ty};
|
use rustc_middle::ty::{self, Ty};
|
||||||
|
|
||||||
use if_chain::if_chain;
|
|
||||||
|
|
||||||
use crate::consts::{constant, Constant};
|
|
||||||
use crate::utils::{method_chain_args, sext};
|
|
||||||
use clippy_utils::diagnostics::span_lint;
|
|
||||||
|
|
||||||
use super::CAST_SIGN_LOSS;
|
use super::CAST_SIGN_LOSS;
|
||||||
|
|
||||||
pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_op: &Expr<'_>, cast_from: Ty<'_>, cast_to: Ty<'_>) {
|
pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_op: &Expr<'_>, cast_from: Ty<'_>, cast_to: Ty<'_>) {
|
||||||
|
|
|
@ -12,14 +12,13 @@ mod ptr_as_ptr;
|
||||||
mod unnecessary_cast;
|
mod unnecessary_cast;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
|
use clippy_utils::is_hir_ty_cfg_dependant;
|
||||||
use rustc_hir::{Expr, ExprKind};
|
use rustc_hir::{Expr, ExprKind};
|
||||||
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
||||||
use rustc_middle::lint::in_external_macro;
|
use rustc_middle::lint::in_external_macro;
|
||||||
use rustc_semver::RustcVersion;
|
use rustc_semver::RustcVersion;
|
||||||
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
||||||
|
|
||||||
use crate::utils::is_hir_ty_cfg_dependant;
|
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
/// **What it does:** Checks for casts from any numerical to a float type where
|
/// **What it does:** Checks for casts from any numerical to a float type where
|
||||||
/// the receiving type cannot store all values from the original type without
|
/// the receiving type cannot store all values from the original type without
|
||||||
|
|
|
@ -1,17 +1,15 @@
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
|
use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||||
|
use clippy_utils::meets_msrv;
|
||||||
|
use clippy_utils::sugg::Sugg;
|
||||||
|
use if_chain::if_chain;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir::{Expr, ExprKind, Mutability, TyKind};
|
use rustc_hir::{Expr, ExprKind, Mutability, TyKind};
|
||||||
use rustc_lint::LateContext;
|
use rustc_lint::LateContext;
|
||||||
use rustc_middle::ty::{self, TypeAndMut};
|
use rustc_middle::ty::{self, TypeAndMut};
|
||||||
use rustc_semver::RustcVersion;
|
use rustc_semver::RustcVersion;
|
||||||
|
|
||||||
use if_chain::if_chain;
|
|
||||||
|
|
||||||
use crate::utils::meets_msrv;
|
|
||||||
use crate::utils::sugg::Sugg;
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_sugg;
|
|
||||||
|
|
||||||
use super::PTR_AS_PTR;
|
use super::PTR_AS_PTR;
|
||||||
|
|
||||||
const PTR_AS_PTR_MSRV: RustcVersion = RustcVersion::new(1, 38, 0);
|
const PTR_AS_PTR_MSRV: RustcVersion = RustcVersion::new(1, 38, 0);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use clippy_utils::diagnostics::span_lint_and_sugg;
|
use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||||
|
use clippy_utils::numeric_literal::NumericLiteral;
|
||||||
use clippy_utils::source::snippet_opt;
|
use clippy_utils::source::snippet_opt;
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_ast::{LitFloatType, LitIntType, LitKind};
|
use rustc_ast::{LitFloatType, LitIntType, LitKind};
|
||||||
|
@ -8,8 +9,6 @@ use rustc_lint::{LateContext, LintContext};
|
||||||
use rustc_middle::lint::in_external_macro;
|
use rustc_middle::lint::in_external_macro;
|
||||||
use rustc_middle::ty::{self, FloatTy, InferTy, Ty};
|
use rustc_middle::ty::{self, FloatTy, InferTy, Ty};
|
||||||
|
|
||||||
use crate::utils::numeric_literal::NumericLiteral;
|
|
||||||
|
|
||||||
use super::UNNECESSARY_CAST;
|
use super::UNNECESSARY_CAST;
|
||||||
|
|
||||||
pub(super) fn check(
|
pub(super) fn check(
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_sugg;
|
use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||||
use clippy_utils::source::snippet_with_applicability;
|
use clippy_utils::source::snippet_with_applicability;
|
||||||
|
use clippy_utils::{meets_msrv, SpanlessEq};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_ast::ast::LitKind;
|
use rustc_ast::ast::LitKind;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
|
@ -11,8 +12,6 @@ use rustc_middle::lint::in_external_macro;
|
||||||
use rustc_semver::RustcVersion;
|
use rustc_semver::RustcVersion;
|
||||||
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
||||||
|
|
||||||
use crate::utils::{meets_msrv, SpanlessEq};
|
|
||||||
|
|
||||||
const CHECKED_CONVERSIONS_MSRV: RustcVersion = RustcVersion::new(1, 34, 0);
|
const CHECKED_CONVERSIONS_MSRV: RustcVersion = RustcVersion::new(1, 34, 0);
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
use clippy_utils::diagnostics::span_lint_and_help;
|
use clippy_utils::diagnostics::span_lint_and_help;
|
||||||
use clippy_utils::source::snippet_opt;
|
use clippy_utils::source::snippet_opt;
|
||||||
use clippy_utils::ty::is_type_diagnostic_item;
|
use clippy_utils::ty::is_type_diagnostic_item;
|
||||||
|
use clippy_utils::LimitStack;
|
||||||
use rustc_ast::ast::Attribute;
|
use rustc_ast::ast::Attribute;
|
||||||
use rustc_hir::intravisit::{walk_expr, FnKind, NestedVisitorMap, Visitor};
|
use rustc_hir::intravisit::{walk_expr, FnKind, NestedVisitorMap, Visitor};
|
||||||
use rustc_hir::{Body, Expr, ExprKind, FnDecl, HirId};
|
use rustc_hir::{Body, Expr, ExprKind, FnDecl, HirId};
|
||||||
|
@ -12,8 +13,6 @@ use rustc_session::{declare_tool_lint, impl_lint_pass};
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::source_map::Span;
|
||||||
use rustc_span::{sym, BytePos};
|
use rustc_span::{sym, BytePos};
|
||||||
|
|
||||||
use crate::utils::LimitStack;
|
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
/// **What it does:** Checks for methods with high cognitive complexity.
|
/// **What it does:** Checks for methods with high cognitive complexity.
|
||||||
///
|
///
|
||||||
|
|
|
@ -14,14 +14,13 @@
|
||||||
|
|
||||||
use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then};
|
use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then};
|
||||||
use clippy_utils::source::{snippet_block, snippet_block_with_applicability};
|
use clippy_utils::source::{snippet_block, snippet_block_with_applicability};
|
||||||
|
use clippy_utils::sugg::Sugg;
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_ast::ast;
|
use rustc_ast::ast;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_lint::{EarlyContext, EarlyLintPass};
|
use rustc_lint::{EarlyContext, EarlyLintPass};
|
||||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||||
|
|
||||||
use crate::utils::sugg::Sugg;
|
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
/// **What it does:** Checks for nested `if` statements which can be collapsed
|
/// **What it does:** Checks for nested `if` statements which can be collapsed
|
||||||
/// by `&&`-combining their conditions.
|
/// by `&&`-combining their conditions.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::utils::visitors::LocalUsedVisitor;
|
|
||||||
use crate::utils::{path_to_local, SpanlessEq};
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_then;
|
use clippy_utils::diagnostics::span_lint_and_then;
|
||||||
|
use clippy_utils::visitors::LocalUsedVisitor;
|
||||||
|
use clippy_utils::{path_to_local, SpanlessEq};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res};
|
use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res};
|
||||||
use rustc_hir::{Arm, Expr, ExprKind, Guard, HirId, Pat, PatKind, QPath, StmtKind, UnOp};
|
use rustc_hir::{Arm, Expr, ExprKind, Guard, HirId, Pat, PatKind, QPath, StmtKind, UnOp};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::utils::{get_trait_def_id, if_sequence, parent_node_is_if_expr, paths, SpanlessEq};
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_help;
|
use clippy_utils::diagnostics::span_lint_and_help;
|
||||||
use clippy_utils::ty::implements_trait;
|
use clippy_utils::ty::implements_trait;
|
||||||
|
use clippy_utils::{get_trait_def_id, if_sequence, parent_node_is_if_expr, paths, SpanlessEq};
|
||||||
use rustc_hir::{BinOpKind, Expr, ExprKind};
|
use rustc_hir::{BinOpKind, Expr, ExprKind};
|
||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass};
|
||||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::utils::{eq_expr_value, in_macro, search_same, SpanlessEq, SpanlessHash};
|
|
||||||
use crate::utils::{get_parent_expr, if_sequence};
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_note;
|
use clippy_utils::diagnostics::span_lint_and_note;
|
||||||
|
use clippy_utils::{eq_expr_value, in_macro, search_same, SpanlessEq, SpanlessHash};
|
||||||
|
use clippy_utils::{get_parent_expr, if_sequence};
|
||||||
use rustc_hir::{Block, Expr, ExprKind};
|
use rustc_hir::{Block, Expr, ExprKind};
|
||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass};
|
||||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::utils::{match_def_path, paths};
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_sugg;
|
use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||||
use clippy_utils::source::snippet;
|
use clippy_utils::source::snippet;
|
||||||
|
use clippy_utils::{match_def_path, paths};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir::{Expr, ExprKind};
|
use rustc_hir::{Expr, ExprKind};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::utils::{any_parent_is_automatically_derived, contains_name, match_def_path, paths};
|
|
||||||
use clippy_utils::diagnostics::{span_lint_and_note, span_lint_and_sugg};
|
use clippy_utils::diagnostics::{span_lint_and_note, span_lint_and_sugg};
|
||||||
use clippy_utils::source::snippet_with_macro_callsite;
|
use clippy_utils::source::snippet_with_macro_callsite;
|
||||||
|
use clippy_utils::{any_parent_is_automatically_derived, contains_name, match_def_path, paths};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_data_structures::fx::FxHashSet;
|
use rustc_data_structures::fx::FxHashSet;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::utils::{get_parent_node, in_macro, is_allowed};
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_sugg;
|
use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||||
use clippy_utils::source::snippet_with_context;
|
use clippy_utils::source::snippet_with_context;
|
||||||
use clippy_utils::ty::peel_mid_ty_refs;
|
use clippy_utils::ty::peel_mid_ty_refs;
|
||||||
|
use clippy_utils::{get_parent_node, in_macro, is_allowed};
|
||||||
use rustc_ast::util::parser::PREC_PREFIX;
|
use rustc_ast::util::parser::PREC_PREFIX;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir::{BorrowKind, Expr, ExprKind, HirId, MatchSource, Mutability, Node, UnOp};
|
use rustc_hir::{BorrowKind, Expr, ExprKind, HirId, MatchSource, Mutability, Node, UnOp};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::utils::paths;
|
|
||||||
use crate::utils::{get_trait_def_id, is_allowed, is_automatically_derived, match_def_path};
|
|
||||||
use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_note, span_lint_and_then};
|
use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_note, span_lint_and_then};
|
||||||
|
use clippy_utils::paths;
|
||||||
use clippy_utils::ty::is_copy;
|
use clippy_utils::ty::is_copy;
|
||||||
|
use clippy_utils::{get_trait_def_id, is_allowed, is_automatically_derived, match_def_path};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
use rustc_hir::intravisit::{walk_expr, walk_fn, walk_item, FnKind, NestedVisitorMap, Visitor};
|
use rustc_hir::intravisit::{walk_expr, walk_fn, walk_item, FnKind, NestedVisitorMap, Visitor};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::utils::fn_def_id;
|
|
||||||
use clippy_utils::diagnostics::span_lint;
|
use clippy_utils::diagnostics::span_lint;
|
||||||
|
use clippy_utils::fn_def_id;
|
||||||
|
|
||||||
use rustc_data_structures::fx::FxHashSet;
|
use rustc_data_structures::fx::FxHashSet;
|
||||||
use rustc_hir::Expr;
|
use rustc_hir::Expr;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::utils::{is_entrypoint_fn, is_expn_of, match_panic_def_id, method_chain_args, return_ty};
|
|
||||||
use clippy_utils::diagnostics::{span_lint, span_lint_and_note};
|
use clippy_utils::diagnostics::{span_lint, span_lint_and_note};
|
||||||
use clippy_utils::ty::{implements_trait, is_type_diagnostic_item};
|
use clippy_utils::ty::{implements_trait, is_type_diagnostic_item};
|
||||||
|
use clippy_utils::{is_entrypoint_fn, is_expn_of, match_panic_def_id, method_chain_args, return_ty};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use rustc_ast::ast::{Async, AttrKind, Attribute, FnKind, FnRetTy, ItemKind};
|
use rustc_ast::ast::{Async, AttrKind, Attribute, FnKind, FnRetTy, ItemKind};
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
//! Lint on unnecessary double comparisons. Some examples:
|
//! Lint on unnecessary double comparisons. Some examples:
|
||||||
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_sugg;
|
use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||||
|
use clippy_utils::eq_expr_value;
|
||||||
use clippy_utils::source::snippet_with_applicability;
|
use clippy_utils::source::snippet_with_applicability;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir::{BinOpKind, Expr, ExprKind};
|
use rustc_hir::{BinOpKind, Expr, ExprKind};
|
||||||
|
@ -8,8 +9,6 @@ use rustc_lint::{LateContext, LateLintPass};
|
||||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::source_map::Span;
|
||||||
|
|
||||||
use crate::utils::eq_expr_value;
|
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
/// **What it does:** Checks for double comparisons that could be simplified to a single expression.
|
/// **What it does:** Checks for double comparisons that could be simplified to a single expression.
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::utils::{match_def_path, paths};
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_note;
|
use clippy_utils::diagnostics::span_lint_and_note;
|
||||||
use clippy_utils::ty::is_copy;
|
use clippy_utils::ty::is_copy;
|
||||||
|
use clippy_utils::{match_def_path, paths};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_hir::{Expr, ExprKind};
|
use rustc_hir::{Expr, ExprKind};
|
||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass};
|
||||||
|
|
|
@ -8,8 +8,8 @@ use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||||
use rustc_span::source_map::Spanned;
|
use rustc_span::source_map::Spanned;
|
||||||
|
|
||||||
use crate::consts::{constant, Constant};
|
use crate::consts::{constant, Constant};
|
||||||
use crate::utils::paths;
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_sugg;
|
use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||||
|
use clippy_utils::paths;
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
/// **What it does:** Checks for calculation of subsecond microseconds or milliseconds
|
/// **What it does:** Checks for calculation of subsecond microseconds or milliseconds
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use crate::utils::SpanlessEq;
|
|
||||||
use crate::utils::{get_item_name, paths};
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_then;
|
use clippy_utils::diagnostics::span_lint_and_then;
|
||||||
use clippy_utils::source::{snippet, snippet_opt, snippet_with_applicability};
|
use clippy_utils::source::{snippet, snippet_opt, snippet_with_applicability};
|
||||||
use clippy_utils::ty::{is_type_diagnostic_item, match_type};
|
use clippy_utils::ty::{is_type_diagnostic_item, match_type};
|
||||||
|
use clippy_utils::SpanlessEq;
|
||||||
|
use clippy_utils::{get_item_name, paths};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
|
use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
//! lint on enum variants that are prefixed or suffixed by the same characters
|
//! lint on enum variants that are prefixed or suffixed by the same characters
|
||||||
|
|
||||||
use crate::utils::camel_case;
|
use clippy_utils::camel_case;
|
||||||
use clippy_utils::diagnostics::{span_lint, span_lint_and_help};
|
use clippy_utils::diagnostics::{span_lint, span_lint_and_help};
|
||||||
use clippy_utils::source::is_present_in_source;
|
use clippy_utils::source::is_present_in_source;
|
||||||
use rustc_ast::ast::{EnumDef, Item, ItemKind, VisibilityKind};
|
use rustc_ast::ast::{EnumDef, Item, ItemKind, VisibilityKind};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::utils::{ast_utils::is_useless_with_eq_exprs, eq_expr_value, higher, in_macro, is_expn_of};
|
|
||||||
use clippy_utils::diagnostics::{multispan_sugg, span_lint, span_lint_and_then};
|
use clippy_utils::diagnostics::{multispan_sugg, span_lint, span_lint_and_then};
|
||||||
use clippy_utils::source::snippet;
|
use clippy_utils::source::snippet;
|
||||||
use clippy_utils::ty::{implements_trait, is_copy};
|
use clippy_utils::ty::{implements_trait, is_copy};
|
||||||
|
use clippy_utils::{ast_utils::is_useless_with_eq_exprs, eq_expr_value, higher, in_macro, is_expn_of};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir::{BinOpKind, BorrowKind, Expr, ExprKind, StmtKind};
|
use rustc_hir::{BinOpKind, BorrowKind, Expr, ExprKind, StmtKind};
|
||||||
|
|
|
@ -3,6 +3,7 @@ use clippy_utils::higher;
|
||||||
use clippy_utils::higher::VecArgs;
|
use clippy_utils::higher::VecArgs;
|
||||||
use clippy_utils::source::snippet_opt;
|
use clippy_utils::source::snippet_opt;
|
||||||
use clippy_utils::ty::{implements_trait, type_is_unsafe_function};
|
use clippy_utils::ty::{implements_trait, type_is_unsafe_function};
|
||||||
|
use clippy_utils::{is_adjusted, iter_input_pats};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir::{def_id, Expr, ExprKind, Param, PatKind, QPath};
|
use rustc_hir::{def_id, Expr, ExprKind, Param, PatKind, QPath};
|
||||||
|
@ -11,8 +12,6 @@ use rustc_middle::lint::in_external_macro;
|
||||||
use rustc_middle::ty::{self, Ty};
|
use rustc_middle::ty::{self, Ty};
|
||||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||||
|
|
||||||
use crate::utils::{is_adjusted, iter_input_pats};
|
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
/// **What it does:** Checks for closures which just call another function where
|
/// **What it does:** Checks for closures which just call another function where
|
||||||
/// the function can be called directly. `unsafe` functions or calls where types
|
/// the function can be called directly. `unsafe` functions or calls where types
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::utils::{get_parent_expr, path_to_local, path_to_local_id};
|
|
||||||
use clippy_utils::diagnostics::{span_lint, span_lint_and_note};
|
use clippy_utils::diagnostics::{span_lint, span_lint_and_note};
|
||||||
|
use clippy_utils::{get_parent_expr, path_to_local, path_to_local_id};
|
||||||
use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
|
use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
|
||||||
use rustc_hir::{BinOpKind, Block, Expr, ExprKind, Guard, HirId, Local, Node, Stmt, StmtKind};
|
use rustc_hir::{BinOpKind, Block, Expr, ExprKind, Guard, HirId, Local, Node, Stmt, StmtKind};
|
||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::utils::{attr_by_name, in_macro, match_path_ast};
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_help;
|
use clippy_utils::diagnostics::span_lint_and_help;
|
||||||
|
use clippy_utils::{attr_by_name, in_macro, match_path_ast};
|
||||||
use rustc_ast::ast::{AssocItemKind, Extern, FnKind, FnSig, ImplKind, Item, ItemKind, TraitKind, Ty, TyKind};
|
use rustc_ast::ast::{AssocItemKind, Extern, FnKind, FnSig, ImplKind, Item, ItemKind, TraitKind, Ty, TyKind};
|
||||||
use rustc_lint::{EarlyContext, EarlyLintPass};
|
use rustc_lint::{EarlyContext, EarlyLintPass};
|
||||||
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::utils::{is_entrypoint_fn, match_def_path, paths};
|
|
||||||
use clippy_utils::diagnostics::span_lint;
|
use clippy_utils::diagnostics::span_lint;
|
||||||
|
use clippy_utils::{is_entrypoint_fn, match_def_path, paths};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_hir::{Expr, ExprKind, Item, ItemKind, Node};
|
use rustc_hir::{Expr, ExprKind, Item, ItemKind, Node};
|
||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::utils::{is_expn_of, match_function_call, paths};
|
|
||||||
use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg};
|
use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg};
|
||||||
|
use clippy_utils::{is_expn_of, match_function_call, paths};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_ast::ast::LitKind;
|
use rustc_ast::ast::LitKind;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::utils::{is_expn_of, match_panic_def_id, method_chain_args};
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_then;
|
use clippy_utils::diagnostics::span_lint_and_then;
|
||||||
use clippy_utils::ty::is_type_diagnostic_item;
|
use clippy_utils::ty::is_type_diagnostic_item;
|
||||||
|
use clippy_utils::{is_expn_of, match_panic_def_id, method_chain_args};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::utils::{match_def_path, paths, sugg};
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_then;
|
use clippy_utils::diagnostics::span_lint_and_then;
|
||||||
|
use clippy_utils::{match_def_path, paths, sugg};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_ast::util::parser::AssocOp;
|
use rustc_ast::util::parser::AssocOp;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::utils::numeric_literal;
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_sugg;
|
use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||||
|
use clippy_utils::numeric_literal;
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_ast::ast::{self, LitFloatType, LitKind};
|
use rustc_ast::ast::{self, LitFloatType, LitKind};
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
|
|
|
@ -2,8 +2,8 @@ use crate::consts::{
|
||||||
constant, constant_simple, Constant,
|
constant, constant_simple, Constant,
|
||||||
Constant::{Int, F32, F64},
|
Constant::{Int, F32, F64},
|
||||||
};
|
};
|
||||||
use crate::utils::{eq_expr_value, get_parent_expr, numeric_literal, sugg};
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_sugg;
|
use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||||
|
use clippy_utils::{eq_expr_value, get_parent_expr, numeric_literal, sugg};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir::{BinOpKind, Expr, ExprKind, PathSegment, UnOp};
|
use rustc_hir::{BinOpKind, Expr, ExprKind, PathSegment, UnOp};
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use crate::utils::paths;
|
|
||||||
use crate::utils::{is_expn_of, last_path_segment, match_def_path, match_function_call};
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_then;
|
use clippy_utils::diagnostics::span_lint_and_then;
|
||||||
|
use clippy_utils::paths;
|
||||||
use clippy_utils::source::{snippet, snippet_opt};
|
use clippy_utils::source::{snippet, snippet_opt};
|
||||||
use clippy_utils::ty::is_type_diagnostic_item;
|
use clippy_utils::ty::is_type_diagnostic_item;
|
||||||
|
use clippy_utils::{is_expn_of, last_path_segment, match_def_path, match_function_call};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_ast::ast::LitKind;
|
use rustc_ast::ast::LitKind;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::utils::differing_macro_contexts;
|
|
||||||
use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_note};
|
use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_note};
|
||||||
|
use clippy_utils::differing_macro_contexts;
|
||||||
use clippy_utils::source::snippet_opt;
|
use clippy_utils::source::snippet_opt;
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_ast::ast::{BinOpKind, Block, Expr, ExprKind, StmtKind, UnOp};
|
use rustc_ast::ast::{BinOpKind, Block, Expr, ExprKind, StmtKind, UnOp};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::utils::paths::INTO;
|
|
||||||
use crate::utils::{match_def_path, meets_msrv};
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_help;
|
use clippy_utils::diagnostics::span_lint_and_help;
|
||||||
|
use clippy_utils::paths::INTO;
|
||||||
|
use clippy_utils::{match_def_path, meets_msrv};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use clippy_utils::diagnostics::span_lint_and_sugg;
|
use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||||
|
use clippy_utils::sugg::Sugg;
|
||||||
use clippy_utils::ty::is_type_diagnostic_item;
|
use clippy_utils::ty::is_type_diagnostic_item;
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
|
@ -8,8 +9,6 @@ use rustc_middle::ty::Ty;
|
||||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||||
use rustc_span::symbol::sym;
|
use rustc_span::symbol::sym;
|
||||||
|
|
||||||
use crate::utils::sugg::Sugg;
|
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
/// **What it does:**
|
/// **What it does:**
|
||||||
/// Checks for function invocations of the form `primitive::from_str_radix(s, 10)`
|
/// Checks for function invocations of the form `primitive::from_str_radix(s, 10)`
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
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, trait_ref_of_method,
|
|
||||||
};
|
|
||||||
use clippy_utils::diagnostics::{span_lint, span_lint_and_help, span_lint_and_then};
|
use clippy_utils::diagnostics::{span_lint, span_lint_and_help, span_lint_and_then};
|
||||||
use clippy_utils::source::{snippet, snippet_opt};
|
use clippy_utils::source::{snippet, snippet_opt};
|
||||||
use clippy_utils::ty::{is_must_use_ty, is_type_diagnostic_item, type_is_unsafe_function};
|
use clippy_utils::ty::{is_must_use_ty, is_type_diagnostic_item, type_is_unsafe_function};
|
||||||
|
use clippy_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, trait_ref_of_method,
|
||||||
|
};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_ast::ast::Attribute;
|
use rustc_ast::ast::Attribute;
|
||||||
use rustc_data_structures::fx::FxHashSet;
|
use rustc_data_structures::fx::FxHashSet;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::utils;
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_then;
|
use clippy_utils::diagnostics::span_lint_and_then;
|
||||||
|
use clippy_utils::return_ty;
|
||||||
use rustc_hir::intravisit::FnKind;
|
use rustc_hir::intravisit::FnKind;
|
||||||
use rustc_hir::{Body, FnDecl, HirId};
|
use rustc_hir::{Body, FnDecl, HirId};
|
||||||
use rustc_infer::infer::TyCtxtInferExt;
|
use rustc_infer::infer::TyCtxtInferExt;
|
||||||
|
@ -62,7 +62,7 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
|
||||||
if let FnKind::Closure = kind {
|
if let FnKind::Closure = kind {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let ret_ty = utils::return_ty(cx, hir_id);
|
let ret_ty = return_ty(cx, hir_id);
|
||||||
if let Opaque(id, subst) = *ret_ty.kind() {
|
if let Opaque(id, subst) = *ret_ty.kind() {
|
||||||
let preds = cx.tcx.explicit_item_bounds(id);
|
let preds = cx.tcx.explicit_item_bounds(id);
|
||||||
let mut is_future = false;
|
let mut is_future = false;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
//! lint on using `x.get(x.len() - 1)` instead of `x.last()`
|
//! lint on using `x.get(x.len() - 1)` instead of `x.last()`
|
||||||
|
|
||||||
use crate::utils::SpanlessEq;
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_sugg;
|
use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||||
use clippy_utils::source::snippet_with_applicability;
|
use clippy_utils::source::snippet_with_applicability;
|
||||||
use clippy_utils::ty::is_type_diagnostic_item;
|
use clippy_utils::ty::is_type_diagnostic_item;
|
||||||
|
use clippy_utils::SpanlessEq;
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_ast::ast::LitKind;
|
use rustc_ast::ast::LitKind;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
|
|
|
@ -7,8 +7,8 @@ use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::source_map::Span;
|
||||||
|
|
||||||
use crate::consts::{constant_simple, Constant};
|
use crate::consts::{constant_simple, Constant};
|
||||||
use crate::utils::{clip, unsext};
|
|
||||||
use clippy_utils::diagnostics::span_lint;
|
use clippy_utils::diagnostics::span_lint;
|
||||||
|
use clippy_utils::{clip, unsext};
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
/// **What it does:** Checks for identity operations, e.g., `x + 0`.
|
/// **What it does:** Checks for identity operations, e.g., `x + 0`.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::utils::SpanlessEq;
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_help;
|
use clippy_utils::diagnostics::span_lint_and_help;
|
||||||
use clippy_utils::ty::is_type_diagnostic_item;
|
use clippy_utils::ty::is_type_diagnostic_item;
|
||||||
|
use clippy_utils::SpanlessEq;
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_hir::intravisit::{self as visit, NestedVisitorMap, Visitor};
|
use rustc_hir::intravisit::{self as visit, NestedVisitorMap, Visitor};
|
||||||
use rustc_hir::{Expr, ExprKind, MatchSource};
|
use rustc_hir::{Expr, ExprKind, MatchSource};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::utils::method_chain_args;
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_sugg;
|
use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||||
|
use clippy_utils::method_chain_args;
|
||||||
use clippy_utils::source::snippet_with_applicability;
|
use clippy_utils::source::snippet_with_applicability;
|
||||||
use clippy_utils::ty::is_type_diagnostic_item;
|
use clippy_utils::ty::is_type_diagnostic_item;
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::utils;
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_help;
|
use clippy_utils::diagnostics::span_lint_and_help;
|
||||||
use clippy_utils::source::snippet_with_macro_callsite;
|
use clippy_utils::source::snippet_with_macro_callsite;
|
||||||
|
use clippy_utils::{match_qpath, meets_msrv, parent_node_is_if_expr};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_hir::{Expr, ExprKind};
|
use rustc_hir::{Expr, ExprKind};
|
||||||
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
||||||
|
@ -58,7 +58,7 @@ impl_lint_pass!(IfThenSomeElseNone => [IF_THEN_SOME_ELSE_NONE]);
|
||||||
|
|
||||||
impl LateLintPass<'_> for IfThenSomeElseNone {
|
impl LateLintPass<'_> for IfThenSomeElseNone {
|
||||||
fn check_expr(&mut self, cx: &LateContext<'_>, expr: &'tcx Expr<'_>) {
|
fn check_expr(&mut self, cx: &LateContext<'_>, expr: &'tcx Expr<'_>) {
|
||||||
if !utils::meets_msrv(self.msrv.as_ref(), &IF_THEN_SOME_ELSE_NONE_MSRV) {
|
if !meets_msrv(self.msrv.as_ref(), &IF_THEN_SOME_ELSE_NONE_MSRV) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ impl LateLintPass<'_> for IfThenSomeElseNone {
|
||||||
}
|
}
|
||||||
|
|
||||||
// We only care about the top-most `if` in the chain
|
// We only care about the top-most `if` in the chain
|
||||||
if utils::parent_node_is_if_expr(expr, cx) {
|
if parent_node_is_if_expr(expr, cx) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,12 +77,12 @@ impl LateLintPass<'_> for IfThenSomeElseNone {
|
||||||
if let Some(ref then_expr) = then_block.expr;
|
if let Some(ref then_expr) = then_block.expr;
|
||||||
if let ExprKind::Call(ref then_call, [then_arg]) = then_expr.kind;
|
if let ExprKind::Call(ref then_call, [then_arg]) = then_expr.kind;
|
||||||
if let ExprKind::Path(ref then_call_qpath) = then_call.kind;
|
if let ExprKind::Path(ref then_call_qpath) = then_call.kind;
|
||||||
if utils::match_qpath(then_call_qpath, &utils::paths::OPTION_SOME);
|
if match_qpath(then_call_qpath, &clippy_utils::paths::OPTION_SOME);
|
||||||
if let ExprKind::Block(ref els_block, _) = els.kind;
|
if let ExprKind::Block(ref els_block, _) = els.kind;
|
||||||
if els_block.stmts.is_empty();
|
if els_block.stmts.is_empty();
|
||||||
if let Some(ref els_expr) = els_block.expr;
|
if let Some(ref els_expr) = els_block.expr;
|
||||||
if let ExprKind::Path(ref els_call_qpath) = els_expr.kind;
|
if let ExprKind::Path(ref els_call_qpath) = els_expr.kind;
|
||||||
if utils::match_qpath(els_call_qpath, &utils::paths::OPTION_NONE);
|
if match_qpath(els_call_qpath, &clippy_utils::paths::OPTION_NONE);
|
||||||
then {
|
then {
|
||||||
let cond_snip = 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(_, _, _)) {
|
let cond_snip = if matches!(cond.kind, ExprKind::Unary(_, _) | ExprKind::Binary(_, _, _)) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::utils::match_panic_def_id;
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_then;
|
use clippy_utils::diagnostics::span_lint_and_then;
|
||||||
|
use clippy_utils::match_panic_def_id;
|
||||||
use clippy_utils::source::snippet_opt;
|
use clippy_utils::source::snippet_opt;
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::utils::{in_macro, match_qpath, SpanlessEq};
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_sugg;
|
use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||||
|
use clippy_utils::{in_macro, match_qpath, SpanlessEq};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_ast::ast::LitKind;
|
use rustc_ast::ast::LitKind;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
//! lint on indexing and slicing operations
|
//! lint on indexing and slicing operations
|
||||||
|
|
||||||
use crate::consts::{constant, Constant};
|
use crate::consts::{constant, Constant};
|
||||||
use crate::utils::higher;
|
|
||||||
use clippy_utils::diagnostics::{span_lint, span_lint_and_help};
|
use clippy_utils::diagnostics::{span_lint, span_lint_and_help};
|
||||||
|
use clippy_utils::higher;
|
||||||
use rustc_ast::ast::RangeLimits;
|
use rustc_ast::ast::RangeLimits;
|
||||||
use rustc_hir::{Expr, ExprKind};
|
use rustc_hir::{Expr, ExprKind};
|
||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass};
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
use clippy_utils::diagnostics::span_lint;
|
use clippy_utils::diagnostics::span_lint;
|
||||||
use clippy_utils::ty::{implements_trait, match_type};
|
use clippy_utils::ty::{implements_trait, match_type};
|
||||||
|
use clippy_utils::{get_trait_def_id, higher, match_qpath, paths};
|
||||||
use rustc_hir::{BorrowKind, Expr, ExprKind};
|
use rustc_hir::{BorrowKind, Expr, ExprKind};
|
||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass};
|
||||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||||
|
|
||||||
use crate::utils::{get_trait_def_id, higher, match_qpath, paths};
|
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
/// **What it does:** Checks for iteration that is guaranteed to be infinite.
|
/// **What it does:** Checks for iteration that is guaranteed to be infinite.
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//! lint on inherent implementations
|
//! lint on inherent implementations
|
||||||
|
|
||||||
use crate::utils::in_macro;
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_then;
|
use clippy_utils::diagnostics::span_lint_and_then;
|
||||||
|
use clippy_utils::in_macro;
|
||||||
use rustc_data_structures::fx::FxHashMap;
|
use rustc_data_structures::fx::FxHashMap;
|
||||||
use rustc_hir::{def_id, Crate, Impl, Item, ItemKind};
|
use rustc_hir::{def_id, Crate, Impl, Item, ItemKind};
|
||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass};
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
use clippy_utils::diagnostics::span_lint_and_help;
|
use clippy_utils::diagnostics::span_lint_and_help;
|
||||||
use clippy_utils::ty::{implements_trait, is_type_diagnostic_item};
|
use clippy_utils::ty::{implements_trait, is_type_diagnostic_item};
|
||||||
|
use clippy_utils::{get_trait_def_id, paths, return_ty, trait_ref_of_method};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_hir::{ImplItem, ImplItemKind};
|
use rustc_hir::{ImplItem, ImplItemKind};
|
||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass};
|
||||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||||
use rustc_span::sym;
|
use rustc_span::sym;
|
||||||
|
|
||||||
use crate::utils::{get_trait_def_id, paths, return_ty, trait_ref_of_method};
|
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
/// **What it does:** Checks for the definition of inherent methods with a signature of `to_string(&self) -> String`.
|
/// **What it does:** Checks for the definition of inherent methods with a signature of `to_string(&self) -> String`.
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//! checks for `#[inline]` on trait methods without bodies
|
//! checks for `#[inline]` on trait methods without bodies
|
||||||
|
|
||||||
use crate::utils::sugg::DiagnosticBuilderExt;
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_then;
|
use clippy_utils::diagnostics::span_lint_and_then;
|
||||||
|
use clippy_utils::sugg::DiagnosticBuilderExt;
|
||||||
use rustc_ast::ast::Attribute;
|
use rustc_ast::ast::Attribute;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir::{TraitFn, TraitItem, TraitItemKind};
|
use rustc_hir::{TraitFn, TraitItem, TraitItemKind};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::utils::{get_item_name, get_parent_as_impl, is_allowed};
|
|
||||||
use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg, span_lint_and_then};
|
use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg, span_lint_and_then};
|
||||||
use clippy_utils::source::snippet_with_applicability;
|
use clippy_utils::source::snippet_with_applicability;
|
||||||
|
use clippy_utils::{get_item_name, get_parent_as_impl, is_allowed};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_ast::ast::LitKind;
|
use rustc_ast::ast::LitKind;
|
||||||
use rustc_data_structures::fx::FxHashSet;
|
use rustc_data_structures::fx::FxHashSet;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::utils::{path_to_local_id, visitors::LocalUsedVisitor};
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_then;
|
use clippy_utils::diagnostics::span_lint_and_then;
|
||||||
use clippy_utils::source::snippet;
|
use clippy_utils::source::snippet;
|
||||||
|
use clippy_utils::{path_to_local_id, visitors::LocalUsedVisitor};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use clippy_utils::diagnostics::span_lint_and_help;
|
use clippy_utils::diagnostics::span_lint_and_help;
|
||||||
use clippy_utils::ty::{is_must_use_ty, match_type};
|
use clippy_utils::ty::{is_must_use_ty, match_type};
|
||||||
|
use clippy_utils::{is_must_use_func_call, paths};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_hir::{Local, PatKind};
|
use rustc_hir::{Local, PatKind};
|
||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass};
|
||||||
|
@ -7,8 +8,6 @@ use rustc_middle::lint::in_external_macro;
|
||||||
use rustc_middle::ty::subst::GenericArgKind;
|
use rustc_middle::ty::subst::GenericArgKind;
|
||||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||||
|
|
||||||
use crate::utils::{is_must_use_func_call, paths};
|
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
/// **What it does:** Checks for `let _ = <expr>`
|
/// **What it does:** Checks for `let _ = <expr>`
|
||||||
/// where expr is #[must_use]
|
/// where expr is #[must_use]
|
||||||
|
|
|
@ -42,7 +42,7 @@ extern crate rustc_target;
|
||||||
extern crate rustc_trait_selection;
|
extern crate rustc_trait_selection;
|
||||||
extern crate rustc_typeck;
|
extern crate rustc_typeck;
|
||||||
|
|
||||||
use crate::utils::parse_msrv;
|
use clippy_utils::parse_msrv;
|
||||||
use rustc_data_structures::fx::FxHashSet;
|
use rustc_data_structures::fx::FxHashSet;
|
||||||
use rustc_lint::LintId;
|
use rustc_lint::LintId;
|
||||||
use rustc_session::Session;
|
use rustc_session::Session;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::utils::{in_macro, trait_ref_of_method};
|
|
||||||
use clippy_utils::diagnostics::span_lint;
|
use clippy_utils::diagnostics::span_lint;
|
||||||
|
use clippy_utils::{in_macro, trait_ref_of_method};
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||||
use rustc_hir::intravisit::{
|
use rustc_hir::intravisit::{
|
||||||
walk_fn_decl, walk_generic_param, walk_generics, walk_item, walk_param_bound, walk_poly_trait_ref, walk_ty,
|
walk_fn_decl, walk_generic_param, walk_generics, walk_item, walk_param_bound, walk_poly_trait_ref, walk_ty,
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
//! Lints concerned with the grouping of digits with underscores in integral or
|
//! Lints concerned with the grouping of digits with underscores in integral or
|
||||||
//! floating-point literal expressions.
|
//! floating-point literal expressions.
|
||||||
|
|
||||||
use crate::utils::{
|
use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||||
|
use clippy_utils::source::snippet_opt;
|
||||||
|
use clippy_utils::{
|
||||||
in_macro,
|
in_macro,
|
||||||
numeric_literal::{NumericLiteral, Radix},
|
numeric_literal::{NumericLiteral, Radix},
|
||||||
};
|
};
|
||||||
use clippy_utils::diagnostics::span_lint_and_sugg;
|
|
||||||
use clippy_utils::source::snippet_opt;
|
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_ast::ast::{Expr, ExprKind, Lit, LitKind};
|
use rustc_ast::ast::{Expr, ExprKind, Lit, LitKind};
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use super::EMPTY_LOOP;
|
use super::EMPTY_LOOP;
|
||||||
use crate::utils::{is_in_panic_handler, is_no_std_crate};
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_help;
|
use clippy_utils::diagnostics::span_lint_and_help;
|
||||||
|
use clippy_utils::{is_in_panic_handler, is_no_std_crate};
|
||||||
|
|
||||||
use rustc_hir::{Block, Expr};
|
use rustc_hir::{Block, Expr};
|
||||||
use rustc_lint::LateContext;
|
use rustc_lint::LateContext;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use super::{
|
use super::{
|
||||||
get_span_of_entire_for_loop, make_iterator_snippet, IncrementVisitor, InitializeVisitor, EXPLICIT_COUNTER_LOOP,
|
get_span_of_entire_for_loop, make_iterator_snippet, IncrementVisitor, InitializeVisitor, EXPLICIT_COUNTER_LOOP,
|
||||||
};
|
};
|
||||||
use crate::utils::{get_enclosing_block, is_integer_const};
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_sugg;
|
use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||||
use clippy_utils::source::snippet_with_applicability;
|
use clippy_utils::source::snippet_with_applicability;
|
||||||
|
use clippy_utils::{get_enclosing_block, is_integer_const};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir::intravisit::{walk_block, walk_expr};
|
use rustc_hir::intravisit::{walk_block, walk_expr};
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use super::EXPLICIT_ITER_LOOP;
|
use super::EXPLICIT_ITER_LOOP;
|
||||||
use crate::utils::{match_trait_method, paths};
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_sugg;
|
use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||||
use clippy_utils::source::snippet_with_applicability;
|
use clippy_utils::source::snippet_with_applicability;
|
||||||
use clippy_utils::ty::{is_type_diagnostic_item, match_type};
|
use clippy_utils::ty::{is_type_diagnostic_item, match_type};
|
||||||
|
use clippy_utils::{match_trait_method, paths};
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir::{Expr, Mutability};
|
use rustc_hir::{Expr, Mutability};
|
||||||
use rustc_lint::LateContext;
|
use rustc_lint::LateContext;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use super::FOR_KV_MAP;
|
use super::FOR_KV_MAP;
|
||||||
use crate::utils::visitors::LocalUsedVisitor;
|
|
||||||
use crate::utils::{paths, sugg};
|
|
||||||
use clippy_utils::diagnostics::{multispan_sugg, span_lint_and_then};
|
use clippy_utils::diagnostics::{multispan_sugg, span_lint_and_then};
|
||||||
use clippy_utils::source::snippet;
|
use clippy_utils::source::snippet;
|
||||||
use clippy_utils::ty::{is_type_diagnostic_item, match_type};
|
use clippy_utils::ty::{is_type_diagnostic_item, match_type};
|
||||||
|
use clippy_utils::visitors::LocalUsedVisitor;
|
||||||
|
use clippy_utils::{paths, sugg};
|
||||||
use rustc_hir::{BorrowKind, Expr, ExprKind, Mutability, Pat, PatKind};
|
use rustc_hir::{BorrowKind, Expr, ExprKind, Mutability, Pat, PatKind};
|
||||||
use rustc_lint::LateContext;
|
use rustc_lint::LateContext;
|
||||||
use rustc_middle::ty;
|
use rustc_middle::ty;
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
use super::ITER_NEXT_LOOP;
|
use super::ITER_NEXT_LOOP;
|
||||||
use clippy_utils::diagnostics::span_lint;
|
use clippy_utils::diagnostics::span_lint;
|
||||||
|
use clippy_utils::is_trait_method;
|
||||||
use rustc_hir::Expr;
|
use rustc_hir::Expr;
|
||||||
use rustc_lint::LateContext;
|
use rustc_lint::LateContext;
|
||||||
use rustc_span::sym;
|
use rustc_span::sym;
|
||||||
|
|
||||||
use crate::utils::is_trait_method;
|
|
||||||
|
|
||||||
pub(super) fn check(cx: &LateContext<'_>, arg: &Expr<'_>, expr: &Expr<'_>) -> bool {
|
pub(super) fn check(cx: &LateContext<'_>, arg: &Expr<'_>, expr: &Expr<'_>) -> bool {
|
||||||
if is_trait_method(cx, arg, sym::Iterator) {
|
if is_trait_method(cx, arg, sym::Iterator) {
|
||||||
span_lint(
|
span_lint(
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use super::utils::make_iterator_snippet;
|
use super::utils::make_iterator_snippet;
|
||||||
use super::MANUAL_FLATTEN;
|
use super::MANUAL_FLATTEN;
|
||||||
use crate::utils::{is_ok_ctor, is_some_ctor, path_to_local_id};
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_then;
|
use clippy_utils::diagnostics::span_lint_and_then;
|
||||||
|
use clippy_utils::{is_ok_ctor, is_some_ctor, path_to_local_id};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir::{Expr, ExprKind, MatchSource, Pat, PatKind, QPath, StmtKind};
|
use rustc_hir::{Expr, ExprKind, MatchSource, Pat, PatKind, QPath, StmtKind};
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use super::{get_span_of_entire_for_loop, IncrementVisitor, InitializeVisitor, MANUAL_MEMCPY};
|
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, sugg};
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_sugg;
|
use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||||
use clippy_utils::source::snippet;
|
use clippy_utils::source::snippet;
|
||||||
|
use clippy_utils::sugg::Sugg;
|
||||||
use clippy_utils::ty::is_type_diagnostic_item;
|
use clippy_utils::ty::is_type_diagnostic_item;
|
||||||
|
use clippy_utils::{get_enclosing_block, higher, path_to_local, sugg};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_ast::ast;
|
use rustc_ast::ast;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
|
|
|
@ -18,7 +18,7 @@ mod while_immutable_condition;
|
||||||
mod while_let_loop;
|
mod while_let_loop;
|
||||||
mod while_let_on_iterator;
|
mod while_let_on_iterator;
|
||||||
|
|
||||||
use crate::utils::higher;
|
use clippy_utils::higher;
|
||||||
use rustc_hir::{Expr, ExprKind, LoopSource, Pat};
|
use rustc_hir::{Expr, ExprKind, LoopSource, Pat};
|
||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass};
|
||||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use super::MUT_RANGE_BOUND;
|
use super::MUT_RANGE_BOUND;
|
||||||
use crate::utils::{higher, path_to_local};
|
|
||||||
use clippy_utils::diagnostics::span_lint;
|
use clippy_utils::diagnostics::span_lint;
|
||||||
|
use clippy_utils::{higher, path_to_local};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_hir::{BindingAnnotation, Expr, HirId, Node, PatKind};
|
use rustc_hir::{BindingAnnotation, Expr, HirId, Node, PatKind};
|
||||||
use rustc_infer::infer::TyCtxtInferExt;
|
use rustc_infer::infer::TyCtxtInferExt;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use super::NEEDLESS_COLLECT;
|
use super::NEEDLESS_COLLECT;
|
||||||
use crate::utils::sugg::Sugg;
|
|
||||||
use crate::utils::{is_trait_method, path_to_local_id, paths};
|
|
||||||
use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then};
|
use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then};
|
||||||
use clippy_utils::source::snippet;
|
use clippy_utils::source::snippet;
|
||||||
|
use clippy_utils::sugg::Sugg;
|
||||||
use clippy_utils::ty::{is_type_diagnostic_item, match_type};
|
use clippy_utils::ty::{is_type_diagnostic_item, match_type};
|
||||||
|
use clippy_utils::{is_trait_method, path_to_local_id, paths};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir::intravisit::{walk_block, walk_expr, NestedVisitorMap, Visitor};
|
use rustc_hir::intravisit::{walk_block, walk_expr, NestedVisitorMap, Visitor};
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
use super::NEEDLESS_RANGE_LOOP;
|
use super::NEEDLESS_RANGE_LOOP;
|
||||||
use crate::utils::visitors::LocalUsedVisitor;
|
|
||||||
use crate::utils::{
|
|
||||||
contains_name, higher, is_integer_const, match_trait_method, path_to_local_id, paths, sugg, SpanlessEq,
|
|
||||||
};
|
|
||||||
use clippy_utils::diagnostics::{multispan_sugg, span_lint_and_then};
|
use clippy_utils::diagnostics::{multispan_sugg, span_lint_and_then};
|
||||||
use clippy_utils::source::snippet;
|
use clippy_utils::source::snippet;
|
||||||
use clippy_utils::ty::has_iter_method;
|
use clippy_utils::ty::has_iter_method;
|
||||||
|
use clippy_utils::visitors::LocalUsedVisitor;
|
||||||
|
use clippy_utils::{
|
||||||
|
contains_name, higher, is_integer_const, match_trait_method, path_to_local_id, paths, sugg, SpanlessEq,
|
||||||
|
};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_ast::ast;
|
use rustc_ast::ast;
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use super::{get_span_of_entire_for_loop, SINGLE_ELEMENT_LOOP};
|
use super::{get_span_of_entire_for_loop, SINGLE_ELEMENT_LOOP};
|
||||||
use crate::utils::single_segment_path;
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_sugg;
|
use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||||
|
use clippy_utils::single_segment_path;
|
||||||
use clippy_utils::source::{indent_of, snippet};
|
use clippy_utils::source::{indent_of, snippet};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
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 clippy_utils::ty::{has_iter_method, implements_trait};
|
||||||
|
use clippy_utils::{get_parent_expr, is_integer_const, path_to_local, path_to_local_id, sugg};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_data_structures::fx::FxHashMap;
|
use rustc_data_structures::fx::FxHashMap;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use super::WHILE_IMMUTABLE_CONDITION;
|
use super::WHILE_IMMUTABLE_CONDITION;
|
||||||
use crate::consts::constant;
|
use crate::consts::constant;
|
||||||
use crate::utils::usage::mutated_variables;
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_then;
|
use clippy_utils::diagnostics::span_lint_and_then;
|
||||||
|
use clippy_utils::usage::mutated_variables;
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||||
use rustc_hir::def::{DefKind, Res};
|
use rustc_hir::def::{DefKind, Res};
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
use super::utils::{LoopNestVisitor, Nesting};
|
use super::utils::{LoopNestVisitor, Nesting};
|
||||||
use super::WHILE_LET_ON_ITERATOR;
|
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,
|
|
||||||
};
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_sugg;
|
use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||||
use clippy_utils::source::snippet_with_applicability;
|
use clippy_utils::source::snippet_with_applicability;
|
||||||
use clippy_utils::ty::implements_trait;
|
use clippy_utils::ty::implements_trait;
|
||||||
|
use clippy_utils::usage::mutated_variables;
|
||||||
|
use clippy_utils::{
|
||||||
|
get_enclosing_block, is_refutable, is_trait_method, last_path_segment, path_to_local, path_to_local_id,
|
||||||
|
};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir::intravisit::{walk_block, walk_expr, NestedVisitorMap, Visitor};
|
use rustc_hir::intravisit::{walk_block, walk_expr, NestedVisitorMap, Visitor};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::utils::in_macro;
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_sugg;
|
use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||||
|
use clippy_utils::in_macro;
|
||||||
use clippy_utils::source::snippet;
|
use clippy_utils::source::snippet;
|
||||||
use hir::def::{DefKind, Res};
|
use hir::def::{DefKind, Res};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
use clippy_utils::diagnostics::span_lint_and_help;
|
use clippy_utils::diagnostics::span_lint_and_help;
|
||||||
use clippy_utils::source::snippet;
|
use clippy_utils::source::snippet;
|
||||||
|
use clippy_utils::{is_entrypoint_fn, is_no_std_crate};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_hir::{Crate, Expr, ExprKind, QPath};
|
use rustc_hir::{Crate, Expr, ExprKind, QPath};
|
||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass};
|
||||||
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
||||||
|
|
||||||
use crate::utils::{is_entrypoint_fn, is_no_std_crate};
|
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
/// **What it does:** Checks for recursion using the entrypoint.
|
/// **What it does:** Checks for recursion using the entrypoint.
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::utils::match_function_call;
|
|
||||||
use crate::utils::paths::FUTURE_FROM_GENERATOR;
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_then;
|
use clippy_utils::diagnostics::span_lint_and_then;
|
||||||
|
use clippy_utils::match_function_call;
|
||||||
|
use clippy_utils::paths::FUTURE_FROM_GENERATOR;
|
||||||
use clippy_utils::source::{position_before_rarrow, snippet_block, snippet_opt};
|
use clippy_utils::source::{position_before_rarrow, snippet_block, snippet_opt};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
use crate::{
|
use crate::{map_unit_fn::OPTION_MAP_UNIT_FN, matches::MATCH_AS_REF};
|
||||||
map_unit_fn::OPTION_MAP_UNIT_FN,
|
|
||||||
matches::MATCH_AS_REF,
|
|
||||||
utils::{is_allowed, match_def_path, match_var, paths, peel_hir_expr_refs},
|
|
||||||
};
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_sugg;
|
use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||||
use clippy_utils::source::{snippet_with_applicability, snippet_with_context};
|
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 clippy_utils::ty::{can_partially_move_ty, is_type_diagnostic_item, peel_mid_ty_refs_is_mutable};
|
||||||
|
use clippy_utils::{is_allowed, match_def_path, match_var, paths, peel_hir_expr_refs};
|
||||||
use rustc_ast::util::parser::PREC_POSTFIX;
|
use rustc_ast::util::parser::PREC_POSTFIX;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir::{
|
use rustc_hir::{
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::utils::meets_msrv;
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_then;
|
use clippy_utils::diagnostics::span_lint_and_then;
|
||||||
|
use clippy_utils::meets_msrv;
|
||||||
use clippy_utils::source::snippet_opt;
|
use clippy_utils::source::snippet_opt;
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_ast::ast::{Attribute, Item, ItemKind, StructField, Variant, VariantData, VisibilityKind};
|
use rustc_ast::ast::{Attribute, Item, ItemKind, StructField, Variant, VariantData, VisibilityKind};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::utils::{match_qpath, path_to_local_id, paths};
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_sugg;
|
use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||||
use clippy_utils::source::{indent_of, reindent_multiline, snippet_opt};
|
use clippy_utils::source::{indent_of, reindent_multiline, snippet_opt};
|
||||||
use clippy_utils::ty::is_type_diagnostic_item;
|
use clippy_utils::ty::is_type_diagnostic_item;
|
||||||
|
use clippy_utils::{match_qpath, path_to_local_id, paths};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir::{Expr, ExprKind, PatKind};
|
use rustc_hir::{Expr, ExprKind, PatKind};
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use crate::consts::{constant, Constant};
|
use crate::consts::{constant, Constant};
|
||||||
use crate::utils::usage::mutated_variables;
|
|
||||||
use crate::utils::{eq_expr_value, higher, match_def_path, meets_msrv, paths};
|
|
||||||
use clippy_utils::diagnostics::{multispan_sugg, span_lint_and_then};
|
use clippy_utils::diagnostics::{multispan_sugg, span_lint_and_then};
|
||||||
use clippy_utils::source::snippet;
|
use clippy_utils::source::snippet;
|
||||||
|
use clippy_utils::usage::mutated_variables;
|
||||||
|
use clippy_utils::{eq_expr_value, higher, match_def_path, meets_msrv, paths};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_ast::ast::LitKind;
|
use rustc_ast::ast::LitKind;
|
||||||
use rustc_hir::def::Res;
|
use rustc_hir::def::Res;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use crate::consts::constant_simple;
|
use crate::consts::constant_simple;
|
||||||
use crate::utils;
|
|
||||||
use crate::utils::{in_constant, path_to_local_id, sugg};
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_sugg;
|
use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||||
use clippy_utils::source::{indent_of, reindent_multiline, snippet_opt};
|
use clippy_utils::source::{indent_of, reindent_multiline, snippet_opt};
|
||||||
use clippy_utils::ty::is_type_diagnostic_item;
|
use clippy_utils::ty::is_type_diagnostic_item;
|
||||||
|
use clippy_utils::usage::contains_return_break_continue_macro;
|
||||||
|
use clippy_utils::{in_constant, match_qpath, path_to_local_id, paths, sugg};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir::{Arm, Expr, ExprKind, Pat, PatKind};
|
use rustc_hir::{Arm, Expr, ExprKind, Pat, PatKind};
|
||||||
|
@ -75,19 +75,19 @@ fn lint_manual_unwrap_or<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
|
||||||
if let Some((idx, or_arm)) = arms.iter().enumerate().find(|(_, arm)|
|
if let Some((idx, or_arm)) = arms.iter().enumerate().find(|(_, arm)|
|
||||||
match arm.pat.kind {
|
match arm.pat.kind {
|
||||||
PatKind::Path(ref some_qpath) =>
|
PatKind::Path(ref some_qpath) =>
|
||||||
utils::match_qpath(some_qpath, &utils::paths::OPTION_NONE),
|
match_qpath(some_qpath, &paths::OPTION_NONE),
|
||||||
PatKind::TupleStruct(ref err_qpath, &[Pat { kind: PatKind::Wild, .. }], _) =>
|
PatKind::TupleStruct(ref err_qpath, &[Pat { kind: PatKind::Wild, .. }], _) =>
|
||||||
utils::match_qpath(err_qpath, &utils::paths::RESULT_ERR),
|
match_qpath(err_qpath, &paths::RESULT_ERR),
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
let unwrap_arm = &arms[1 - idx];
|
let unwrap_arm = &arms[1 - idx];
|
||||||
if let PatKind::TupleStruct(ref unwrap_qpath, &[unwrap_pat], _) = unwrap_arm.pat.kind;
|
if let PatKind::TupleStruct(ref unwrap_qpath, &[unwrap_pat], _) = unwrap_arm.pat.kind;
|
||||||
if utils::match_qpath(unwrap_qpath, &utils::paths::OPTION_SOME)
|
if match_qpath(unwrap_qpath, &paths::OPTION_SOME)
|
||||||
|| utils::match_qpath(unwrap_qpath, &utils::paths::RESULT_OK);
|
|| match_qpath(unwrap_qpath, &paths::RESULT_OK);
|
||||||
if let PatKind::Binding(_, binding_hir_id, ..) = unwrap_pat.kind;
|
if let PatKind::Binding(_, binding_hir_id, ..) = unwrap_pat.kind;
|
||||||
if path_to_local_id(unwrap_arm.body, binding_hir_id);
|
if path_to_local_id(unwrap_arm.body, binding_hir_id);
|
||||||
if !utils::usage::contains_return_break_continue_macro(or_arm.body);
|
if !contains_return_break_continue_macro(or_arm.body);
|
||||||
then {
|
then {
|
||||||
Some(or_arm)
|
Some(or_arm)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::utils::is_trait_method;
|
|
||||||
use crate::utils::remove_blocks;
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_sugg;
|
use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||||
|
use clippy_utils::is_trait_method;
|
||||||
|
use clippy_utils::remove_blocks;
|
||||||
use clippy_utils::source::snippet_with_applicability;
|
use clippy_utils::source::snippet_with_applicability;
|
||||||
use clippy_utils::ty::{is_copy, is_type_diagnostic_item};
|
use clippy_utils::ty::{is_copy, is_type_diagnostic_item};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::utils::{is_adjusted, is_trait_method, match_path, match_var, paths, remove_blocks};
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_sugg;
|
use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||||
use clippy_utils::ty::is_type_diagnostic_item;
|
use clippy_utils::ty::is_type_diagnostic_item;
|
||||||
|
use clippy_utils::{is_adjusted, is_trait_method, match_path, match_var, paths, remove_blocks};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir::{Body, Expr, ExprKind, Pat, PatKind, QPath, StmtKind};
|
use rustc_hir::{Body, Expr, ExprKind, Pat, PatKind, QPath, StmtKind};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::utils::{iter_input_pats, method_chain_args};
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_then;
|
use clippy_utils::diagnostics::span_lint_and_then;
|
||||||
use clippy_utils::source::snippet;
|
use clippy_utils::source::snippet;
|
||||||
use clippy_utils::ty::is_type_diagnostic_item;
|
use clippy_utils::ty::is_type_diagnostic_item;
|
||||||
|
use clippy_utils::{iter_input_pats, method_chain_args};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
use crate::consts::{constant, miri_to_const, Constant};
|
use crate::consts::{constant, miri_to_const, Constant};
|
||||||
use crate::utils::sugg::Sugg;
|
|
||||||
use crate::utils::visitors::LocalUsedVisitor;
|
|
||||||
use crate::utils::{
|
|
||||||
get_parent_expr, in_macro, is_allowed, is_expn_of, is_refutable, is_wild, match_qpath, meets_msrv, path_to_local,
|
|
||||||
path_to_local_id, peel_hir_pat_refs, peel_n_hir_expr_refs, remove_blocks, strip_pat_refs,
|
|
||||||
};
|
|
||||||
use crate::utils::{paths, search_same, SpanlessEq, SpanlessHash};
|
|
||||||
use clippy_utils::diagnostics::{
|
use clippy_utils::diagnostics::{
|
||||||
multispan_sugg, span_lint_and_help, span_lint_and_note, span_lint_and_sugg, span_lint_and_then,
|
multispan_sugg, span_lint_and_help, span_lint_and_note, span_lint_and_sugg, span_lint_and_then,
|
||||||
};
|
};
|
||||||
use clippy_utils::source::{expr_block, indent_of, snippet, snippet_block, snippet_opt, snippet_with_applicability};
|
use clippy_utils::source::{expr_block, indent_of, snippet, snippet_block, snippet_opt, snippet_with_applicability};
|
||||||
|
use clippy_utils::sugg::Sugg;
|
||||||
use clippy_utils::ty::{implements_trait, is_type_diagnostic_item, match_type, peel_mid_ty_refs};
|
use clippy_utils::ty::{implements_trait, is_type_diagnostic_item, match_type, peel_mid_ty_refs};
|
||||||
|
use clippy_utils::visitors::LocalUsedVisitor;
|
||||||
|
use clippy_utils::{
|
||||||
|
get_parent_expr, in_macro, is_allowed, is_expn_of, is_refutable, is_wild, match_qpath, meets_msrv, path_to_local,
|
||||||
|
path_to_local_id, peel_hir_pat_refs, peel_n_hir_expr_refs, remove_blocks, strip_pat_refs,
|
||||||
|
};
|
||||||
|
use clippy_utils::{paths, search_same, SpanlessEq, SpanlessHash};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_ast::ast::LitKind;
|
use rustc_ast::ast::LitKind;
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||||
|
@ -1616,9 +1616,9 @@ where
|
||||||
|
|
||||||
mod redundant_pattern_match {
|
mod redundant_pattern_match {
|
||||||
use super::REDUNDANT_PATTERN_MATCHING;
|
use super::REDUNDANT_PATTERN_MATCHING;
|
||||||
use crate::utils::{is_trait_method, match_qpath, paths};
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_then;
|
use clippy_utils::diagnostics::span_lint_and_then;
|
||||||
use clippy_utils::source::snippet;
|
use clippy_utils::source::snippet;
|
||||||
|
use clippy_utils::{is_trait_method, match_qpath, paths};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_ast::ast::LitKind;
|
use rustc_ast::ast::LitKind;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::utils::{match_def_path, paths};
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_then;
|
use clippy_utils::diagnostics::span_lint_and_then;
|
||||||
use clippy_utils::source::snippet;
|
use clippy_utils::source::snippet;
|
||||||
use clippy_utils::ty::walk_ptrs_ty_depth;
|
use clippy_utils::ty::walk_ptrs_ty_depth;
|
||||||
|
use clippy_utils::{match_def_path, paths};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir::{BorrowKind, Expr, ExprKind};
|
use rustc_hir::{BorrowKind, Expr, ExprKind};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::utils::{match_def_path, paths};
|
|
||||||
use clippy_utils::diagnostics::span_lint;
|
use clippy_utils::diagnostics::span_lint;
|
||||||
|
use clippy_utils::{match_def_path, paths};
|
||||||
use rustc_hir::{Expr, ExprKind};
|
use rustc_hir::{Expr, ExprKind};
|
||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass};
|
||||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::utils::{in_macro, match_def_path, match_qpath, meets_msrv, paths};
|
|
||||||
use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_sugg, span_lint_and_then};
|
use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_sugg, span_lint_and_then};
|
||||||
use clippy_utils::is_diagnostic_assoc_item;
|
use clippy_utils::is_diagnostic_assoc_item;
|
||||||
use clippy_utils::source::{snippet, snippet_with_applicability};
|
use clippy_utils::source::{snippet, snippet_with_applicability};
|
||||||
|
use clippy_utils::{in_macro, match_def_path, match_qpath, meets_msrv, paths};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use super::{contains_return, BIND_INSTEAD_OF_MAP};
|
use super::{contains_return, BIND_INSTEAD_OF_MAP};
|
||||||
use crate::utils::{in_macro, match_qpath, method_calls, paths, remove_blocks, visitors::find_all_ret_expressions};
|
|
||||||
use clippy_utils::diagnostics::{multispan_sugg_with_applicability, span_lint_and_sugg, span_lint_and_then};
|
use clippy_utils::diagnostics::{multispan_sugg_with_applicability, span_lint_and_sugg, span_lint_and_then};
|
||||||
use clippy_utils::source::{snippet, snippet_with_macro_callsite};
|
use clippy_utils::source::{snippet, snippet_with_macro_callsite};
|
||||||
use clippy_utils::ty::match_type;
|
use clippy_utils::ty::match_type;
|
||||||
|
use clippy_utils::{in_macro, match_qpath, method_calls, paths, remove_blocks, visitors::find_all_ret_expressions};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::utils::sugg;
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_then;
|
use clippy_utils::diagnostics::span_lint_and_then;
|
||||||
|
use clippy_utils::sugg;
|
||||||
use clippy_utils::ty::is_copy;
|
use clippy_utils::ty::is_copy;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue