@@ -21,7 +21,6 @@ use rustc_data_structures::sync::join;
21
21
use rustc_hir as hir;
22
22
use rustc_hir:: def_id:: { LocalDefId , LocalModDefId } ;
23
23
use rustc_hir:: intravisit as hir_visit;
24
- use rustc_hir:: intravisit:: Visitor ;
25
24
use rustc_middle:: hir:: nested_filter;
26
25
use rustc_middle:: ty:: { self , TyCtxt } ;
27
26
use rustc_session:: lint:: LintPass ;
@@ -61,6 +60,9 @@ impl<'tcx, T: LateLintPass<'tcx>> LateContextAndPass<'tcx, T> {
61
60
self . context . last_node_with_lint_attrs = id;
62
61
debug ! ( "late context: enter_attrs({:?})" , attrs) ;
63
62
lint_callback ! ( self , enter_lint_attrs, attrs) ;
63
+ for attr in attrs {
64
+ lint_callback ! ( self , check_attribute, attr) ;
65
+ }
64
66
f ( self ) ;
65
67
debug ! ( "late context: exit_attrs({:?})" , attrs) ;
66
68
lint_callback ! ( self , exit_lint_attrs, attrs) ;
@@ -377,20 +379,18 @@ fn late_lint_mod_inner<'tcx, T: LateLintPass<'tcx>>(
377
379
378
380
let ( module, _span, hir_id) = tcx. hir ( ) . get_module ( module_def_id) ;
379
381
380
- // There is no module lint that will have the crate itself as an item, so check it here.
381
- if hir_id == hir:: CRATE_HIR_ID {
382
- lint_callback ! ( cx, check_crate, ) ;
383
- }
382
+ cx. with_lint_attrs ( hir_id, |cx| {
383
+ // There is no module lint that will have the crate itself as an item, so check it here.
384
+ if hir_id == hir:: CRATE_HIR_ID {
385
+ lint_callback ! ( cx, check_crate, ) ;
386
+ }
384
387
385
- cx. process_mod ( module, hir_id) ;
388
+ cx. process_mod ( module, hir_id) ;
386
389
387
- // Visit the crate attributes
388
- if hir_id == hir:: CRATE_HIR_ID {
389
- for attr in tcx. hir ( ) . attrs ( hir:: CRATE_HIR_ID ) . iter ( ) {
390
- cx. visit_attribute ( attr)
390
+ if hir_id == hir:: CRATE_HIR_ID {
391
+ lint_callback ! ( cx, check_crate_post, ) ;
391
392
}
392
- lint_callback ! ( cx, check_crate_post, ) ;
393
- }
393
+ } ) ;
394
394
}
395
395
396
396
fn late_lint_crate < ' tcx > ( tcx : TyCtxt < ' tcx > ) {
@@ -431,7 +431,6 @@ fn late_lint_crate_inner<'tcx, T: LateLintPass<'tcx>>(
431
431
// item), warn for it here.
432
432
lint_callback ! ( cx, check_crate, ) ;
433
433
tcx. hir ( ) . walk_toplevel_module ( cx) ;
434
- tcx. hir ( ) . walk_attributes ( cx) ;
435
434
lint_callback ! ( cx, check_crate_post, ) ;
436
435
} )
437
436
}
0 commit comments