@@ -21,42 +21,38 @@ pub(crate) fn lints<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'_>, iter_args: &'
21
21
return ;
22
22
} ;
23
23
let ty = cx. typeck_results ( ) . expr_ty ( & iter_args[ 0 ] ) ;
24
- if_chain ! {
25
- let caller_type = if derefs_to_slice( cx, & iter_args[ 0 ] , ty) . is_some( ) {
26
- "slice"
27
- } else if is_type_diagnostic_item( cx, ty, sym:: vec_type) {
28
- "Vec"
29
- } else if is_type_diagnostic_item( cx, ty, sym!( vecdeque_type) ) {
30
- "VecDeque"
31
- } else if is_type_diagnostic_item( cx, ty, sym!( hashset_type) ) {
32
- "HashSet"
33
- } else if is_type_diagnostic_item( cx, ty, sym!( hashmap_type) ) {
34
- "HashMap"
35
- } else if match_type( cx, ty, & paths:: BTREEMAP ) {
36
- "BTreeMap"
37
- } else if match_type( cx, ty, & paths:: BTREESET ) {
38
- "BTreeSet"
39
- } else if match_type( cx, ty, & paths:: LINKED_LIST ) {
40
- "LinkedList"
41
- } else if match_type( cx, ty, & paths:: BINARY_HEAP ) {
42
- "BinaryHeap"
43
- } else {
44
- return
45
- } ;
46
- then {
47
- let mut applicability = Applicability :: MachineApplicable ;
48
- span_lint_and_sugg(
49
- cx,
50
- ITER_COUNT ,
51
- expr. span,
52
- & format!( "called `.{}{}().count()` on a `{}`" , iter_method, mut_str, caller_type) ,
53
- "try" ,
54
- format!(
55
- "{}.len()" ,
56
- snippet_with_applicability( cx, iter_args[ 0 ] . span, ".." , & mut applicability) ,
57
- ) ,
58
- applicability,
59
- ) ;
60
- }
61
- }
24
+ let caller_type = if derefs_to_slice ( cx, & iter_args[ 0 ] , ty) . is_some ( ) {
25
+ "slice"
26
+ } else if is_type_diagnostic_item ( cx, ty, sym:: vec_type) {
27
+ "Vec"
28
+ } else if is_type_diagnostic_item ( cx, ty, sym ! ( vecdeque_type) ) {
29
+ "VecDeque"
30
+ } else if is_type_diagnostic_item ( cx, ty, sym ! ( hashset_type) ) {
31
+ "HashSet"
32
+ } else if is_type_diagnostic_item ( cx, ty, sym ! ( hashmap_type) ) {
33
+ "HashMap"
34
+ } else if match_type ( cx, ty, & paths:: BTREEMAP ) {
35
+ "BTreeMap"
36
+ } else if match_type ( cx, ty, & paths:: BTREESET ) {
37
+ "BTreeSet"
38
+ } else if match_type ( cx, ty, & paths:: LINKED_LIST ) {
39
+ "LinkedList"
40
+ } else if match_type ( cx, ty, & paths:: BINARY_HEAP ) {
41
+ "BinaryHeap"
42
+ } else {
43
+ return ;
44
+ } ;
45
+ let mut applicability = Applicability :: MachineApplicable ;
46
+ span_lint_and_sugg (
47
+ cx,
48
+ ITER_COUNT ,
49
+ expr. span ,
50
+ & format ! ( "called `.{}{}().count()` on a `{}`" , iter_method, mut_str, caller_type) ,
51
+ "try" ,
52
+ format ! (
53
+ "{}.len()" ,
54
+ snippet_with_applicability( cx, iter_args[ 0 ] . span, ".." , & mut applicability) ,
55
+ ) ,
56
+ applicability,
57
+ ) ;
62
58
}
0 commit comments