Skip to content

Commit 1127e8c

Browse files
author
Eric Loren
committed
fix imports, format
1 parent bbd7c02 commit 1127e8c

File tree

1 file changed

+39
-52
lines changed
  • clippy_lints/src/methods

1 file changed

+39
-52
lines changed

clippy_lints/src/methods/mod.rs

Lines changed: 39 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -20,39 +20,25 @@ use rustc_hir as hir;
2020
use rustc_hir::def::Res;
2121
use rustc_hir::intravisit::{self, Visitor};
2222
use rustc_hir::{Expr, ExprKind, PatKind, TraitItem, TraitItemKind, UnOp};
23-
use rustc_hir::{TraitItem, TraitItemKind};
2423
use rustc_lint::{LateContext, LateLintPass, Lint, LintContext};
2524
use rustc_middle::lint::in_external_macro;
2625
use rustc_middle::ty::{self, TraitRef, Ty, TyS};
2726
use rustc_semver::RustcVersion;
2827
use rustc_session::{declare_tool_lint, impl_lint_pass};
2928
use rustc_span::source_map::Span;
3029
use rustc_span::symbol::{sym, Symbol, SymbolStr};
31-
use rustc_span::symbol::{sym, Symbol, SymbolStr};
3230
use rustc_typeck::hir_ty_to_ty;
3331

3432
use crate::consts::{constant, Constant};
3533
use crate::utils::eager_or_lazy::is_lazyness_candidate;
3634
use crate::utils::usage::mutated_variables;
3735
use crate::utils::{
38-
contains_return, contains_return, contains_ty, contains_ty, contains_ty, get_arg_name, get_arg_name,
39-
get_parent_expr, get_parent_expr, get_parent_expr, get_trait_def_id, get_trait_def_id, get_trait_def_id,
40-
has_iter_method, has_iter_method, has_iter_method, higher, higher, higher, implements_trait, implements_trait,
41-
implements_trait, in_macro, in_macro, in_macro, is_copy, is_copy, is_copy, is_expn_of, is_expn_of, is_expn_of,
42-
is_type_diagnostic_item, is_type_diagnostic_item, is_type_diagnostic_item, iter_input_pats, iter_input_pats,
43-
iter_input_pats, last_path_segment, last_path_segment, last_path_segment, match_def_path, match_def_path,
44-
match_def_path, match_qpath, match_qpath, match_qpath, match_trait_method, match_trait_method, match_trait_method,
45-
match_type, match_type, match_type, match_var, match_var, meets_msrv, meets_msrv, method_calls, method_calls,
46-
method_calls, method_chain_args, method_chain_args, method_chain_args, path_to_local_id, paths, paths, paths,
47-
remove_blocks, remove_blocks, remove_blocks, return_ty, return_ty, return_ty, single_segment_path,
48-
single_segment_path, single_segment_path, snippet, snippet, snippet, snippet_block, snippet_block,
49-
snippet_with_applicability, snippet_with_applicability, snippet_with_applicability, snippet_with_applicability,
50-
snippet_with_macro_callsite, snippet_with_macro_callsite, snippet_with_macro_callsite, snippet_with_macro_callsite,
51-
span_lint, span_lint, span_lint, span_lint, span_lint_and_help, span_lint_and_help, span_lint_and_help,
52-
span_lint_and_help, span_lint_and_sugg, span_lint_and_sugg, span_lint_and_sugg, span_lint_and_sugg,
53-
span_lint_and_then, span_lint_and_then, span_lint_and_then, span_lint_and_then, strip_pat_refs, sugg, sugg, sugg,
54-
sugg, walk_ptrs_ty_depth, walk_ptrs_ty_depth, walk_ptrs_ty_depth, walk_ptrs_ty_depth, SpanlessEq, SpanlessEq,
55-
SpanlessEq, SpanlessEq,
36+
contains_return, contains_ty, get_parent_expr, get_trait_def_id, has_iter_method, higher, implements_trait,
37+
in_macro, is_copy, is_expn_of, is_type_diagnostic_item, iter_input_pats, last_path_segment, match_def_path,
38+
match_qpath, match_trait_method, match_type, match_var, meets_msrv, method_calls, method_chain_args,
39+
path_to_local_id, paths, remove_blocks, return_ty, single_segment_path, snippet, snippet_block,
40+
snippet_with_applicability, snippet_with_macro_callsite, span_lint, span_lint_and_help, span_lint_and_sugg,
41+
span_lint_and_then, strip_pat_refs, sugg, walk_ptrs_ty_depth, SpanlessEq,
5642
};
5743

5844
declare_clippy_lint! {
@@ -2212,13 +2198,13 @@ fn lint_expect_fun_call(
22122198
match node {
22132199
hir::ExprKind::AddrOf(hir::BorrowKind::Ref, _, expr) => {
22142200
is_call(&expr.kind)
2215-
},
2201+
}
22162202
hir::ExprKind::Call(..)
22172203
| hir::ExprKind::MethodCall(..)
22182204
// These variants are debatable or require further examination
22192205
| hir::ExprKind::If(..)
22202206
| hir::ExprKind::Match(..)
2221-
| hir::ExprKind::Block{ .. } => true,
2207+
| hir::ExprKind::Block { .. } => true,
22222208
_ => false,
22232209
}
22242210
}
@@ -4022,6 +4008,7 @@ struct ShouldImplTraitCase {
40224008
// certain methods with explicit lifetimes can't implement the equivalent trait method
40234009
lint_explicit_lifetime: bool,
40244010
}
4011+
40254012
impl ShouldImplTraitCase {
40264013
const fn new(
40274014
trait_name: &'static str,
@@ -4058,37 +4045,37 @@ impl ShouldImplTraitCase {
40584045

40594046
#[rustfmt::skip]
40604047
const TRAIT_METHODS: [ShouldImplTraitCase; 30] = [
4061-
ShouldImplTraitCase::new("std::ops::Add", "add", 2, FN_HEADER, SelfKind::Value, OutType::Any, true),
4062-
ShouldImplTraitCase::new("std::convert::AsMut", "as_mut", 1, FN_HEADER, SelfKind::RefMut, OutType::Ref, true),
4063-
ShouldImplTraitCase::new("std::convert::AsRef", "as_ref", 1, FN_HEADER, SelfKind::Ref, OutType::Ref, true),
4064-
ShouldImplTraitCase::new("std::ops::BitAnd", "bitand", 2, FN_HEADER, SelfKind::Value, OutType::Any, true),
4065-
ShouldImplTraitCase::new("std::ops::BitOr", "bitor", 2, FN_HEADER, SelfKind::Value, OutType::Any, true),
4066-
ShouldImplTraitCase::new("std::ops::BitXor", "bitxor", 2, FN_HEADER, SelfKind::Value, OutType::Any, true),
4067-
ShouldImplTraitCase::new("std::borrow::Borrow", "borrow", 1, FN_HEADER, SelfKind::Ref, OutType::Ref, true),
4068-
ShouldImplTraitCase::new("std::borrow::BorrowMut", "borrow_mut", 1, FN_HEADER, SelfKind::RefMut, OutType::Ref, true),
4069-
ShouldImplTraitCase::new("std::clone::Clone", "clone", 1, FN_HEADER, SelfKind::Ref, OutType::Any, true),
4070-
ShouldImplTraitCase::new("std::cmp::Ord", "cmp", 2, FN_HEADER, SelfKind::Ref, OutType::Any, true),
4048+
ShouldImplTraitCase::new("std::ops::Add", "add", 2, FN_HEADER, SelfKind::Value, OutType::Any, true),
4049+
ShouldImplTraitCase::new("std::convert::AsMut", "as_mut", 1, FN_HEADER, SelfKind::RefMut, OutType::Ref, true),
4050+
ShouldImplTraitCase::new("std::convert::AsRef", "as_ref", 1, FN_HEADER, SelfKind::Ref, OutType::Ref, true),
4051+
ShouldImplTraitCase::new("std::ops::BitAnd", "bitand", 2, FN_HEADER, SelfKind::Value, OutType::Any, true),
4052+
ShouldImplTraitCase::new("std::ops::BitOr", "bitor", 2, FN_HEADER, SelfKind::Value, OutType::Any, true),
4053+
ShouldImplTraitCase::new("std::ops::BitXor", "bitxor", 2, FN_HEADER, SelfKind::Value, OutType::Any, true),
4054+
ShouldImplTraitCase::new("std::borrow::Borrow", "borrow", 1, FN_HEADER, SelfKind::Ref, OutType::Ref, true),
4055+
ShouldImplTraitCase::new("std::borrow::BorrowMut", "borrow_mut", 1, FN_HEADER, SelfKind::RefMut, OutType::Ref, true),
4056+
ShouldImplTraitCase::new("std::clone::Clone", "clone", 1, FN_HEADER, SelfKind::Ref, OutType::Any, true),
4057+
ShouldImplTraitCase::new("std::cmp::Ord", "cmp", 2, FN_HEADER, SelfKind::Ref, OutType::Any, true),
40714058
// FIXME: default doesn't work
4072-
ShouldImplTraitCase::new("std::default::Default", "default", 0, FN_HEADER, SelfKind::No, OutType::Any, true),
4073-
ShouldImplTraitCase::new("std::ops::Deref", "deref", 1, FN_HEADER, SelfKind::Ref, OutType::Ref, true),
4074-
ShouldImplTraitCase::new("std::ops::DerefMut", "deref_mut", 1, FN_HEADER, SelfKind::RefMut, OutType::Ref, true),
4075-
ShouldImplTraitCase::new("std::ops::Div", "div", 2, FN_HEADER, SelfKind::Value, OutType::Any, true),
4076-
ShouldImplTraitCase::new("std::ops::Drop", "drop", 1, FN_HEADER, SelfKind::RefMut, OutType::Unit, true),
4077-
ShouldImplTraitCase::new("std::cmp::PartialEq", "eq", 2, FN_HEADER, SelfKind::Ref, OutType::Bool, true),
4078-
ShouldImplTraitCase::new("std::iter::FromIterator", "from_iter", 1, FN_HEADER, SelfKind::No, OutType::Any, true),
4079-
ShouldImplTraitCase::new("std::str::FromStr", "from_str", 1, FN_HEADER, SelfKind::No, OutType::Any, true),
4080-
ShouldImplTraitCase::new("std::hash::Hash", "hash", 2, FN_HEADER, SelfKind::Ref, OutType::Unit, true),
4081-
ShouldImplTraitCase::new("std::ops::Index", "index", 2, FN_HEADER, SelfKind::Ref, OutType::Ref, true),
4082-
ShouldImplTraitCase::new("std::ops::IndexMut", "index_mut", 2, FN_HEADER, SelfKind::RefMut, OutType::Ref, true),
4083-
ShouldImplTraitCase::new("std::iter::IntoIterator", "into_iter", 1, FN_HEADER, SelfKind::Value, OutType::Any, true),
4084-
ShouldImplTraitCase::new("std::ops::Mul", "mul", 2, FN_HEADER, SelfKind::Value, OutType::Any, true),
4085-
ShouldImplTraitCase::new("std::ops::Neg", "neg", 1, FN_HEADER, SelfKind::Value, OutType::Any, true),
4086-
ShouldImplTraitCase::new("std::iter::Iterator", "next", 1, FN_HEADER, SelfKind::RefMut, OutType::Any, false),
4087-
ShouldImplTraitCase::new("std::ops::Not", "not", 1, FN_HEADER, SelfKind::Value, OutType::Any, true),
4088-
ShouldImplTraitCase::new("std::ops::Rem", "rem", 2, FN_HEADER, SelfKind::Value, OutType::Any, true),
4089-
ShouldImplTraitCase::new("std::ops::Shl", "shl", 2, FN_HEADER, SelfKind::Value, OutType::Any, true),
4090-
ShouldImplTraitCase::new("std::ops::Shr", "shr", 2, FN_HEADER, SelfKind::Value, OutType::Any, true),
4091-
ShouldImplTraitCase::new("std::ops::Sub", "sub", 2, FN_HEADER, SelfKind::Value, OutType::Any, true),
4059+
ShouldImplTraitCase::new("std::default::Default", "default", 0, FN_HEADER, SelfKind::No, OutType::Any, true),
4060+
ShouldImplTraitCase::new("std::ops::Deref", "deref", 1, FN_HEADER, SelfKind::Ref, OutType::Ref, true),
4061+
ShouldImplTraitCase::new("std::ops::DerefMut", "deref_mut", 1, FN_HEADER, SelfKind::RefMut, OutType::Ref, true),
4062+
ShouldImplTraitCase::new("std::ops::Div", "div", 2, FN_HEADER, SelfKind::Value, OutType::Any, true),
4063+
ShouldImplTraitCase::new("std::ops::Drop", "drop", 1, FN_HEADER, SelfKind::RefMut, OutType::Unit, true),
4064+
ShouldImplTraitCase::new("std::cmp::PartialEq", "eq", 2, FN_HEADER, SelfKind::Ref, OutType::Bool, true),
4065+
ShouldImplTraitCase::new("std::iter::FromIterator", "from_iter", 1, FN_HEADER, SelfKind::No, OutType::Any, true),
4066+
ShouldImplTraitCase::new("std::str::FromStr", "from_str", 1, FN_HEADER, SelfKind::No, OutType::Any, true),
4067+
ShouldImplTraitCase::new("std::hash::Hash", "hash", 2, FN_HEADER, SelfKind::Ref, OutType::Unit, true),
4068+
ShouldImplTraitCase::new("std::ops::Index", "index", 2, FN_HEADER, SelfKind::Ref, OutType::Ref, true),
4069+
ShouldImplTraitCase::new("std::ops::IndexMut", "index_mut", 2, FN_HEADER, SelfKind::RefMut, OutType::Ref, true),
4070+
ShouldImplTraitCase::new("std::iter::IntoIterator", "into_iter", 1, FN_HEADER, SelfKind::Value, OutType::Any, true),
4071+
ShouldImplTraitCase::new("std::ops::Mul", "mul", 2, FN_HEADER, SelfKind::Value, OutType::Any, true),
4072+
ShouldImplTraitCase::new("std::ops::Neg", "neg", 1, FN_HEADER, SelfKind::Value, OutType::Any, true),
4073+
ShouldImplTraitCase::new("std::iter::Iterator", "next", 1, FN_HEADER, SelfKind::RefMut, OutType::Any, false),
4074+
ShouldImplTraitCase::new("std::ops::Not", "not", 1, FN_HEADER, SelfKind::Value, OutType::Any, true),
4075+
ShouldImplTraitCase::new("std::ops::Rem", "rem", 2, FN_HEADER, SelfKind::Value, OutType::Any, true),
4076+
ShouldImplTraitCase::new("std::ops::Shl", "shl", 2, FN_HEADER, SelfKind::Value, OutType::Any, true),
4077+
ShouldImplTraitCase::new("std::ops::Shr", "shr", 2, FN_HEADER, SelfKind::Value, OutType::Any, true),
4078+
ShouldImplTraitCase::new("std::ops::Sub", "sub", 2, FN_HEADER, SelfKind::Value, OutType::Any, true),
40924079
];
40934080

40944081
#[rustfmt::skip]

0 commit comments

Comments
 (0)