1515//! for all lint attributes.
1616
1717use rustc:: hir:: map:: Map ;
18- use rustc:: lint:: LateContext ;
19- use rustc:: lint:: { LateLintPass , LateLintPassObject } ;
18+ use rustc:: lint:: { LateContext , LateLintPass , LateLintPassObject , LintStore } ;
2019use rustc:: ty:: { self , TyCtxt } ;
2120use rustc_data_structures:: sync:: { join, par_iter, ParallelIterator } ;
2221use rustc_hir as hir;
@@ -31,6 +30,12 @@ use syntax::walk_list;
3130use log:: debug;
3231use std:: slice;
3332
33+ /// Extract the `LintStore` from the query context.
34+ /// This function exists because we've erased `LintStore` as `dyn Any` in the context.
35+ crate fn unerased_lint_store < ' tcx > ( tcx : TyCtxt < ' tcx > ) -> & ' tcx LintStore {
36+ tcx. lint_store . downcast_ref ( ) . unwrap ( )
37+ }
38+
3439macro_rules! lint_callback { ( $cx: expr, $f: ident, $( $args: expr) ,* ) => ( {
3540 $cx. pass. $f( & $cx. context, $( $args) ,* ) ;
3641} ) }
@@ -356,7 +361,7 @@ fn late_lint_mod_pass<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>(
356361 tables : & ty:: TypeckTables :: empty ( None ) ,
357362 param_env : ty:: ParamEnv :: empty ( ) ,
358363 access_levels,
359- lint_store : & tcx. lint_store ,
364+ lint_store : unerased_lint_store ( tcx) ,
360365 last_node_with_lint_attrs : tcx. hir ( ) . as_local_hir_id ( module_def_id) . unwrap ( ) ,
361366 generics : None ,
362367 only_module : true ,
@@ -386,7 +391,7 @@ pub fn late_lint_mod<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>(
386391 late_lint_mod_pass ( tcx, module_def_id, builtin_lints) ;
387392
388393 let mut passes: Vec < _ > =
389- tcx. lint_store . late_module_passes . iter ( ) . map ( |pass| ( pass) ( ) ) . collect ( ) ;
394+ unerased_lint_store ( tcx) . late_module_passes . iter ( ) . map ( |pass| ( pass) ( ) ) . collect ( ) ;
390395
391396 if !passes. is_empty ( ) {
392397 late_lint_mod_pass ( tcx, module_def_id, LateLintPassObjects { lints : & mut passes[ ..] } ) ;
@@ -403,7 +408,7 @@ fn late_lint_pass_crate<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>(tcx: TyCtxt<'tc
403408 tables : & ty:: TypeckTables :: empty ( None ) ,
404409 param_env : ty:: ParamEnv :: empty ( ) ,
405410 access_levels,
406- lint_store : & tcx. lint_store ,
411+ lint_store : unerased_lint_store ( tcx) ,
407412 last_node_with_lint_attrs : hir:: CRATE_HIR_ID ,
408413 generics : None ,
409414 only_module : false ,
@@ -424,7 +429,7 @@ fn late_lint_pass_crate<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>(tcx: TyCtxt<'tc
424429}
425430
426431fn late_lint_crate < ' tcx , T : for < ' a > LateLintPass < ' a , ' tcx > > ( tcx : TyCtxt < ' tcx > , builtin_lints : T ) {
427- let mut passes = tcx. lint_store . late_passes . iter ( ) . map ( |p| ( p) ( ) ) . collect :: < Vec < _ > > ( ) ;
432+ let mut passes = unerased_lint_store ( tcx) . late_passes . iter ( ) . map ( |p| ( p) ( ) ) . collect :: < Vec < _ > > ( ) ;
428433
429434 if !tcx. sess . opts . debugging_opts . no_interleave_lints {
430435 if !passes. is_empty ( ) {
@@ -443,7 +448,7 @@ fn late_lint_crate<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>(tcx: TyCtxt<'tcx>, b
443448 }
444449
445450 let mut passes: Vec < _ > =
446- tcx. lint_store . late_module_passes . iter ( ) . map ( |pass| ( pass) ( ) ) . collect ( ) ;
451+ unerased_lint_store ( tcx) . late_module_passes . iter ( ) . map ( |pass| ( pass) ( ) ) . collect ( ) ;
447452
448453 for pass in & mut passes {
449454 tcx. sess
0 commit comments