@@ -129,54 +129,54 @@ fn get_ufcs_type_name(
129
129
method_def_id : def_id:: DefId ,
130
130
self_arg : & Expr ,
131
131
) -> std:: option:: Option < String > {
132
- let expected_type_of_self = & cx. tcx . fn_sig ( method_def_id) . inputs_and_output ( ) . skip_binder ( ) [ 0 ] . sty ;
133
- let actual_type_of_self = & cx. tables . node_type ( self_arg. hir_id ) . sty ;
132
+ let expected_type_of_self = & cx. tcx . fn_sig ( method_def_id) . inputs_and_output ( ) . skip_binder ( ) [ 0 ] ;
133
+ let actual_type_of_self = & cx. tables . node_type ( self_arg. hir_id ) ;
134
134
135
135
if let Some ( trait_id) = cx. tcx . trait_of_item ( method_def_id) {
136
- if match_borrow_depth ( expected_type_of_self, actual_type_of_self) {
136
+ if match_borrow_depth ( expected_type_of_self, & actual_type_of_self) {
137
137
return Some ( cx. tcx . def_path_str ( trait_id) ) ;
138
138
}
139
139
}
140
140
141
141
cx. tcx . impl_of_method ( method_def_id) . and_then ( |_| {
142
142
//a type may implicitly implement other type's methods (e.g. Deref)
143
- if match_types ( expected_type_of_self, actual_type_of_self) {
143
+ if match_types ( expected_type_of_self, & actual_type_of_self) {
144
144
return Some ( get_type_name ( cx, & actual_type_of_self) ) ;
145
145
}
146
146
None
147
147
} )
148
148
}
149
149
150
- fn match_borrow_depth ( lhs : & ty:: TyKind < ' _ > , rhs : & ty:: TyKind < ' _ > ) -> bool {
151
- match ( lhs, rhs) {
152
- ( ty:: Ref ( _, t1, _) , ty:: Ref ( _, t2, _) ) => match_borrow_depth ( & t1. sty , & t2. sty ) ,
150
+ fn match_borrow_depth ( lhs : & ty:: Ty < ' _ > , rhs : & ty:: Ty < ' _ > ) -> bool {
151
+ match ( & lhs. sty , & rhs. sty ) {
152
+ ( ty:: Ref ( _, t1, _) , ty:: Ref ( _, t2, _) ) => match_borrow_depth ( & t1, & t2) ,
153
153
( l, r) => match ( l, r) {
154
154
( ty:: Ref ( _, _, _) , _) | ( _, ty:: Ref ( _, _, _) ) => false ,
155
155
( _, _) => true ,
156
156
} ,
157
157
}
158
158
}
159
159
160
- fn match_types ( lhs : & ty:: TyKind < ' _ > , rhs : & ty:: TyKind < ' _ > ) -> bool {
161
- match ( lhs, rhs) {
160
+ fn match_types ( lhs : & ty:: Ty < ' _ > , rhs : & ty:: Ty < ' _ > ) -> bool {
161
+ match ( & lhs. sty , & rhs. sty ) {
162
162
( ty:: Bool , ty:: Bool )
163
163
| ( ty:: Char , ty:: Char )
164
164
| ( ty:: Int ( _) , ty:: Int ( _) )
165
165
| ( ty:: Uint ( _) , ty:: Uint ( _) )
166
166
| ( ty:: Str , ty:: Str ) => true ,
167
167
( ty:: Ref ( _, t1, _) , ty:: Ref ( _, t2, _) )
168
168
| ( ty:: Array ( t1, _) , ty:: Array ( t2, _) )
169
- | ( ty:: Slice ( t1) , ty:: Slice ( t2) ) => match_types ( & t1. sty , & t2. sty ) ,
169
+ | ( ty:: Slice ( t1) , ty:: Slice ( t2) ) => match_types ( & t1, & t2) ,
170
170
( ty:: Adt ( def1, _) , ty:: Adt ( def2, _) ) => def1 == def2,
171
171
( _, _) => false ,
172
172
}
173
173
}
174
174
175
- fn get_type_name ( cx : & LateContext < ' _ , ' _ > , kind : & ty:: TyKind < ' _ > ) -> String {
176
- match kind {
175
+ fn get_type_name ( cx : & LateContext < ' _ , ' _ > , ty : & ty:: Ty < ' _ > ) -> String {
176
+ match ty . sty {
177
177
ty:: Adt ( t, _) => cx. tcx . def_path_str ( t. did ) ,
178
- ty:: Ref ( _, r, _) => get_type_name ( cx, & r. sty ) ,
179
- _ => kind . to_string ( ) ,
178
+ ty:: Ref ( _, r, _) => get_type_name ( cx, & r) ,
179
+ _ => ty . to_string ( ) ,
180
180
}
181
181
}
182
182
0 commit comments