15
15
//! for all lint attributes.
16
16
17
17
use rustc:: hir:: map:: Map ;
18
- use rustc:: lint:: LateContext ;
19
- use rustc:: lint:: { LateLintPass , LateLintPassObject } ;
18
+ use rustc:: lint:: { LateContext , LateLintPass , LateLintPassObject , LintStore } ;
20
19
use rustc:: ty:: { self , TyCtxt } ;
21
20
use rustc_data_structures:: sync:: { join, par_iter, ParallelIterator } ;
22
21
use rustc_hir as hir;
@@ -31,6 +30,12 @@ use syntax::walk_list;
31
30
use log:: debug;
32
31
use std:: slice;
33
32
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
+
34
39
macro_rules! lint_callback { ( $cx: expr, $f: ident, $( $args: expr) ,* ) => ( {
35
40
$cx. pass. $f( & $cx. context, $( $args) ,* ) ;
36
41
} ) }
@@ -356,7 +361,7 @@ fn late_lint_mod_pass<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>(
356
361
tables : & ty:: TypeckTables :: empty ( None ) ,
357
362
param_env : ty:: ParamEnv :: empty ( ) ,
358
363
access_levels,
359
- lint_store : & tcx. lint_store ,
364
+ lint_store : unerased_lint_store ( tcx) ,
360
365
last_node_with_lint_attrs : tcx. hir ( ) . as_local_hir_id ( module_def_id) . unwrap ( ) ,
361
366
generics : None ,
362
367
only_module : true ,
@@ -386,7 +391,7 @@ pub fn late_lint_mod<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>(
386
391
late_lint_mod_pass ( tcx, module_def_id, builtin_lints) ;
387
392
388
393
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 ( ) ;
390
395
391
396
if !passes. is_empty ( ) {
392
397
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
403
408
tables : & ty:: TypeckTables :: empty ( None ) ,
404
409
param_env : ty:: ParamEnv :: empty ( ) ,
405
410
access_levels,
406
- lint_store : & tcx. lint_store ,
411
+ lint_store : unerased_lint_store ( tcx) ,
407
412
last_node_with_lint_attrs : hir:: CRATE_HIR_ID ,
408
413
generics : None ,
409
414
only_module : false ,
@@ -424,7 +429,7 @@ fn late_lint_pass_crate<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>(tcx: TyCtxt<'tc
424
429
}
425
430
426
431
fn 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 < _ > > ( ) ;
428
433
429
434
if !tcx. sess . opts . debugging_opts . no_interleave_lints {
430
435
if !passes. is_empty ( ) {
@@ -443,7 +448,7 @@ fn late_lint_crate<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>(tcx: TyCtxt<'tcx>, b
443
448
}
444
449
445
450
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 ( ) ;
447
452
448
453
for pass in & mut passes {
449
454
tcx. sess
0 commit comments