@@ -186,7 +186,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypePass {
186
186
check_fn_decl ( cx, decl) ;
187
187
}
188
188
189
- fn check_struct_field ( & mut self , cx : & LateContext < ' _ , ' _ > , field : & StructField ) {
189
+ fn check_struct_field ( & mut self , cx : & LateContext < ' _ , ' _ > , field : & hir :: StructField ) {
190
190
check_ty ( cx, & field. ty , false ) ;
191
191
}
192
192
@@ -240,21 +240,21 @@ fn match_type_parameter(cx: &LateContext<'_, '_>, qpath: &QPath, path: &[&str])
240
240
///
241
241
/// The parameter `is_local` distinguishes the context of the type; types from
242
242
/// local bindings should only be checked for the `BORROWED_BOX` lint.
243
- fn check_ty ( cx : & LateContext < ' _ , ' _ > , ast_ty : & hir:: Ty , is_local : bool ) {
244
- if in_macro ( ast_ty . span ) {
243
+ fn check_ty ( cx : & LateContext < ' _ , ' _ > , hir_ty : & hir:: Ty , is_local : bool ) {
244
+ if in_macro ( hir_ty . span ) {
245
245
return ;
246
246
}
247
- match ast_ty . node {
247
+ match hir_ty . node {
248
248
TyKind :: Path ( ref qpath) if !is_local => {
249
- let hir_id = cx. tcx . hir ( ) . node_to_hir_id ( ast_ty . id ) ;
249
+ let hir_id = cx. tcx . hir ( ) . node_to_hir_id ( hir_ty . id ) ;
250
250
let def = cx. tables . qpath_def ( qpath, hir_id) ;
251
251
if let Some ( def_id) = opt_def_id ( def) {
252
252
if Some ( def_id) == cx. tcx . lang_items ( ) . owned_box ( ) {
253
253
if match_type_parameter ( cx, qpath, & paths:: VEC ) {
254
254
span_help_and_lint (
255
255
cx,
256
256
BOX_VEC ,
257
- ast_ty . span ,
257
+ hir_ty . span ,
258
258
"you seem to be trying to use `Box<Vec<T>>`. Consider using just `Vec<T>`" ,
259
259
"`Vec<T>` is already on the heap, `Box<Vec<T>>` makes an extra allocation." ,
260
260
) ;
@@ -288,7 +288,7 @@ fn check_ty(cx: &LateContext<'_, '_>, ast_ty: &hir::Ty, is_local: bool) {
288
288
span_lint_and_sugg(
289
289
cx,
290
290
VEC_BOX ,
291
- ast_ty . span,
291
+ hir_ty . span,
292
292
"`Vec<T>` is already on the heap, the boxing is unnecessary." ,
293
293
"try" ,
294
294
format!( "Vec<{}>" , boxed_type) ,
@@ -302,7 +302,7 @@ fn check_ty(cx: &LateContext<'_, '_>, ast_ty: &hir::Ty, is_local: bool) {
302
302
span_lint (
303
303
cx,
304
304
OPTION_OPTION ,
305
- ast_ty . span ,
305
+ hir_ty . span ,
306
306
"consider using `Option<T>` instead of `Option<Option<T>>` or a custom \
307
307
enum if you need to distinguish all 3 cases",
308
308
) ;
@@ -312,7 +312,7 @@ fn check_ty(cx: &LateContext<'_, '_>, ast_ty: &hir::Ty, is_local: bool) {
312
312
span_help_and_lint (
313
313
cx,
314
314
LINKEDLIST ,
315
- ast_ty . span ,
315
+ hir_ty . span ,
316
316
"I see you're using a LinkedList! Perhaps you meant some other data structure?" ,
317
317
"a VecDeque might work" ,
318
318
) ;
@@ -360,7 +360,7 @@ fn check_ty(cx: &LateContext<'_, '_>, ast_ty: &hir::Ty, is_local: bool) {
360
360
} ,
361
361
}
362
362
} ,
363
- TyKind :: Rptr ( ref lt, ref mut_ty) => check_ty_rptr ( cx, ast_ty , is_local, lt, mut_ty) ,
363
+ TyKind :: Rptr ( ref lt, ref mut_ty) => check_ty_rptr ( cx, hir_ty , is_local, lt, mut_ty) ,
364
364
// recurse
365
365
TyKind :: Slice ( ref ty) | TyKind :: Array ( ref ty, _) | TyKind :: Ptr ( MutTy { ref ty, .. } ) => {
366
366
check_ty ( cx, ty, is_local)
@@ -374,7 +374,7 @@ fn check_ty(cx: &LateContext<'_, '_>, ast_ty: &hir::Ty, is_local: bool) {
374
374
}
375
375
}
376
376
377
- fn check_ty_rptr ( cx : & LateContext < ' _ , ' _ > , ast_ty : & hir:: Ty , is_local : bool , lt : & Lifetime , mut_ty : & MutTy ) {
377
+ fn check_ty_rptr ( cx : & LateContext < ' _ , ' _ > , hir_ty : & hir:: Ty , is_local : bool , lt : & Lifetime , mut_ty : & MutTy ) {
378
378
match mut_ty. ty . node {
379
379
TyKind :: Path ( ref qpath) => {
380
380
let hir_id = cx. tcx . hir ( ) . node_to_hir_id ( mut_ty. ty . id ) ;
@@ -410,7 +410,7 @@ fn check_ty_rptr(cx: &LateContext<'_, '_>, ast_ty: &hir::Ty, is_local: bool, lt:
410
410
span_lint_and_sugg(
411
411
cx,
412
412
BORROWED_BOX ,
413
- ast_ty . span,
413
+ hir_ty . span,
414
414
"you seem to be trying to use `&Box<T>`. Consider using just `&T`" ,
415
415
"try" ,
416
416
format!(
@@ -1324,7 +1324,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeComplexityPass {
1324
1324
self . check_fndecl ( cx, decl) ;
1325
1325
}
1326
1326
1327
- fn check_struct_field ( & mut self , cx : & LateContext < ' a , ' tcx > , field : & ' tcx StructField ) {
1327
+ fn check_struct_field ( & mut self , cx : & LateContext < ' a , ' tcx > , field : & ' tcx hir :: StructField ) {
1328
1328
// enum variants are also struct fields now
1329
1329
self . check_type ( cx, & field. ty ) ;
1330
1330
}
0 commit comments