@@ -251,9 +251,9 @@ impl<'tcx> LateLintPass<'tcx> for Functions {
251251 hir_id : hir:: HirId ,
252252 ) {
253253 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 ,
257257 } ;
258258
259259 // don't warn for implementations, it's not their fault
@@ -267,9 +267,8 @@ impl<'tcx> LateLintPass<'tcx> for Functions {
267267 ..
268268 } ,
269269 _,
270- _,
271270 )
272- | intravisit:: FnKind :: ItemFn ( _, _, hir:: FnHeader { abi : Abi :: Rust , .. } , _, _ ) => {
271+ | intravisit:: FnKind :: ItemFn ( _, _, hir:: FnHeader { abi : Abi :: Rust , .. } , _) => {
273272 self . check_arg_number ( cx, decl, span. with_hi ( decl. output . span ( ) . hi ( ) ) )
274273 } ,
275274 _ => { } ,
@@ -281,7 +280,8 @@ impl<'tcx> LateLintPass<'tcx> for Functions {
281280 }
282281
283282 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) ;
285285 if let hir:: ItemKind :: Fn ( ref sig, ref _generics, ref body_id) = item. kind {
286286 let is_public = cx. access_levels . is_exported ( item. hir_id ( ) ) ;
287287 let fn_header_span = item. span . with_hi ( sig. decl . output . span ( ) . hi ( ) ) ;
@@ -292,7 +292,7 @@ impl<'tcx> LateLintPass<'tcx> for Functions {
292292 check_needless_must_use ( cx, & sig. decl , item. hir_id ( ) , item. span , fn_header_span, attr) ;
293293 return ;
294294 }
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 ( ) {
296296 check_must_use_candidate (
297297 cx,
298298 & sig. decl ,
@@ -313,12 +313,11 @@ impl<'tcx> LateLintPass<'tcx> for Functions {
313313 if is_public && trait_ref_of_method ( cx, item. hir_id ( ) ) . is_none ( ) {
314314 check_result_unit_err ( cx, & sig. decl , item. span , fn_header_span) ;
315315 }
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) ;
317318 if let Some ( attr) = attr {
318319 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 ( )
322321 {
323322 check_must_use_candidate (
324323 cx,
@@ -345,15 +344,16 @@ impl<'tcx> LateLintPass<'tcx> for Functions {
345344 check_result_unit_err ( cx, & sig. decl , item. span , fn_header_span) ;
346345 }
347346
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) ;
349349 if let Some ( attr) = attr {
350350 check_needless_must_use ( cx, & sig. decl , item. hir_id ( ) , item. span , fn_header_span, attr) ;
351351 }
352352 if let hir:: TraitFn :: Provided ( eid) = * eid {
353353 let body = cx. tcx . hir ( ) . body ( eid) ;
354354 Self :: check_raw_ptr ( cx, sig. header . unsafety , & sig. decl , body, item. hir_id ( ) ) ;
355355
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) {
357357 check_must_use_candidate (
358358 cx,
359359 & sig. decl ,
0 commit comments