1
1
use itertools:: { repeat_n, Itertools } ;
2
- use rustc:: hir:: * ;
3
- use rustc:: ty:: { AssociatedKind , TyKind } ;
2
+ use rustc:: hir:: { Expr , Stmt , DeclKind , StmtKind , ExprKind } ;
3
+ use rustc:: ty:: { AssociatedKind } ;
4
4
use syntax:: ast:: NodeId ;
5
5
6
6
use std:: collections:: HashSet ;
@@ -9,7 +9,7 @@ use crate::rustc_errors::Applicability;
9
9
use crate :: rustc:: lint:: {
10
10
LateContext , LateLintPass , LintArray , LintPass ,
11
11
} ;
12
- use crate :: rustc:: { declare_tool_lint, lint_array} ;
12
+ use crate :: rustc:: { declare_tool_lint, lint_array, ty } ;
13
13
use crate :: utils:: { match_trait_method, match_type, span_lint_and_sugg} ;
14
14
use crate :: utils:: paths;
15
15
@@ -75,11 +75,11 @@ struct Suggestion {
75
75
76
76
fn format_suggestion_pattern < ' a , ' tcx > (
77
77
cx : & LateContext < ' a , ' tcx > ,
78
- collection_ty : & TyKind < ' _ > ,
78
+ collection_ty : & ty :: Ty < ' _ > ,
79
79
is_option : bool ,
80
80
) -> String {
81
- let collection_pat = match collection_ty {
82
- TyKind :: Adt ( def, subs) => {
81
+ let collection_pat = match collection_ty. sty {
82
+ ty :: Adt ( def, subs) => {
83
83
let mut buf = cx. tcx . item_path_str ( def. did ) ;
84
84
85
85
if !subs. is_empty ( ) {
@@ -90,7 +90,7 @@ fn format_suggestion_pattern<'a, 'tcx>(
90
90
91
91
buf
92
92
} ,
93
- TyKind :: Param ( p) => p. to_string ( ) ,
93
+ ty :: Param ( p) => p. to_string ( ) ,
94
94
_ => "_" . into ( ) ,
95
95
} ;
96
96
@@ -131,13 +131,13 @@ fn check_expr_for_collect<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr
131
131
132
132
return if match_type( cx, normal_ty, & paths:: OPTION ) {
133
133
Some ( Suggestion {
134
- pattern: format_suggestion_pattern( cx, & collect_ty. sty . clone ( ) , true ) ,
134
+ pattern: format_suggestion_pattern( cx, & collect_ty, true ) ,
135
135
type_colloquial: "Option" ,
136
136
success_variant: "Some" ,
137
137
} )
138
138
} else if match_type( cx, normal_ty, & paths:: RESULT ) {
139
139
Some ( Suggestion {
140
- pattern: format_suggestion_pattern( cx, & collect_ty. sty . clone ( ) , false ) ,
140
+ pattern: format_suggestion_pattern( cx, & collect_ty, false ) ,
141
141
type_colloquial: "Result" ,
142
142
success_variant: "Ok" ,
143
143
} )
0 commit comments