@@ -251,9 +251,9 @@ impl<'tcx> LateLintPass<'tcx> for Functions {
251
251
hir_id : hir:: HirId ,
252
252
) {
253
253
let unsafety = match kind {
254
- intravisit:: FnKind :: ItemFn ( _, _, hir:: FnHeader { unsafety, .. } , _, _ ) => unsafety,
255
- intravisit:: FnKind :: Method ( _, sig, _, _ ) => sig. header . unsafety ,
256
- intravisit:: FnKind :: Closure ( _ ) => return ,
254
+ intravisit:: FnKind :: ItemFn ( _, _, hir:: FnHeader { unsafety, .. } , _) => unsafety,
255
+ intravisit:: FnKind :: Method ( _, sig, _) => sig. header . unsafety ,
256
+ intravisit:: FnKind :: Closure => return ,
257
257
} ;
258
258
259
259
// don't warn for implementations, it's not their fault
@@ -267,9 +267,8 @@ impl<'tcx> LateLintPass<'tcx> for Functions {
267
267
..
268
268
} ,
269
269
_,
270
- _,
271
270
)
272
- | intravisit:: FnKind :: ItemFn ( _, _, hir:: FnHeader { abi : Abi :: Rust , .. } , _, _ ) => {
271
+ | intravisit:: FnKind :: ItemFn ( _, _, hir:: FnHeader { abi : Abi :: Rust , .. } , _) => {
273
272
self . check_arg_number ( cx, decl, span. with_hi ( decl. output . span ( ) . hi ( ) ) )
274
273
} ,
275
274
_ => { } ,
@@ -281,7 +280,8 @@ impl<'tcx> LateLintPass<'tcx> for Functions {
281
280
}
282
281
283
282
fn check_item ( & mut self , cx : & LateContext < ' tcx > , item : & ' tcx hir:: Item < ' _ > ) {
284
- let attr = must_use_attr ( & item. attrs ) ;
283
+ let attrs = cx. tcx . hir ( ) . attrs ( item. hir_id ( ) ) ;
284
+ let attr = must_use_attr ( attrs) ;
285
285
if let hir:: ItemKind :: Fn ( ref sig, ref _generics, ref body_id) = item. kind {
286
286
let is_public = cx. access_levels . is_exported ( item. hir_id ( ) ) ;
287
287
let fn_header_span = item. span . with_hi ( sig. decl . output . span ( ) . hi ( ) ) ;
@@ -292,7 +292,7 @@ impl<'tcx> LateLintPass<'tcx> for Functions {
292
292
check_needless_must_use ( cx, & sig. decl , item. hir_id ( ) , item. span , fn_header_span, attr) ;
293
293
return ;
294
294
}
295
- if is_public && !is_proc_macro ( cx. sess ( ) , & item . attrs ) && attr_by_name ( & item . attrs , "no_mangle" ) . is_none ( ) {
295
+ if is_public && !is_proc_macro ( cx. sess ( ) , attrs) && attr_by_name ( attrs, "no_mangle" ) . is_none ( ) {
296
296
check_must_use_candidate (
297
297
cx,
298
298
& sig. decl ,
@@ -313,12 +313,11 @@ impl<'tcx> LateLintPass<'tcx> for Functions {
313
313
if is_public && trait_ref_of_method ( cx, item. hir_id ( ) ) . is_none ( ) {
314
314
check_result_unit_err ( cx, & sig. decl , item. span , fn_header_span) ;
315
315
}
316
- let attr = must_use_attr ( & item. attrs ) ;
316
+ let attrs = cx. tcx . hir ( ) . attrs ( item. hir_id ( ) ) ;
317
+ let attr = must_use_attr ( attrs) ;
317
318
if let Some ( attr) = attr {
318
319
check_needless_must_use ( cx, & sig. decl , item. hir_id ( ) , item. span , fn_header_span, attr) ;
319
- } else if is_public
320
- && !is_proc_macro ( cx. sess ( ) , & item. attrs )
321
- && trait_ref_of_method ( cx, item. hir_id ( ) ) . is_none ( )
320
+ } else if is_public && !is_proc_macro ( cx. sess ( ) , attrs) && trait_ref_of_method ( cx, item. hir_id ( ) ) . is_none ( )
322
321
{
323
322
check_must_use_candidate (
324
323
cx,
@@ -345,15 +344,16 @@ impl<'tcx> LateLintPass<'tcx> for Functions {
345
344
check_result_unit_err ( cx, & sig. decl , item. span , fn_header_span) ;
346
345
}
347
346
348
- let attr = must_use_attr ( & item. attrs ) ;
347
+ let attrs = cx. tcx . hir ( ) . attrs ( item. hir_id ( ) ) ;
348
+ let attr = must_use_attr ( attrs) ;
349
349
if let Some ( attr) = attr {
350
350
check_needless_must_use ( cx, & sig. decl , item. hir_id ( ) , item. span , fn_header_span, attr) ;
351
351
}
352
352
if let hir:: TraitFn :: Provided ( eid) = * eid {
353
353
let body = cx. tcx . hir ( ) . body ( eid) ;
354
354
Self :: check_raw_ptr ( cx, sig. header . unsafety , & sig. decl , body, item. hir_id ( ) ) ;
355
355
356
- if attr. is_none ( ) && is_public && !is_proc_macro ( cx. sess ( ) , & item . attrs ) {
356
+ if attr. is_none ( ) && is_public && !is_proc_macro ( cx. sess ( ) , attrs) {
357
357
check_must_use_candidate (
358
358
cx,
359
359
& sig. decl ,
0 commit comments