@@ -35,7 +35,7 @@ use crate::util::common::time;
35
35
use errors:: DiagnosticBuilder ;
36
36
use std:: slice;
37
37
use std:: default:: Default as StdDefault ;
38
- use rustc_data_structures:: sync:: { ParallelIterator , join, par_iter} ;
38
+ use rustc_data_structures:: sync:: { self , ParallelIterator , join, par_iter} ;
39
39
use rustc_serialize:: { Decoder , Decodable , Encoder , Encodable } ;
40
40
use syntax:: ast;
41
41
use syntax:: util:: lev_distance:: find_best_match_for_name;
@@ -57,11 +57,11 @@ pub struct LintStore {
57
57
/// interior mutability, we don't enforce this (and lints should, in theory,
58
58
/// be compatible with being constructed more than once, though not
59
59
/// necessarily in a sane manner. This is safe though.)
60
- pre_expansion_passes : Vec < fn ( ) -> EarlyLintPassObject > ,
61
- early_passes : Vec < fn ( ) -> EarlyLintPassObject > ,
62
- late_passes : Vec < fn ( ) -> LateLintPassObject > ,
60
+ pre_expansion_passes : Vec < Box < dyn Fn ( ) -> EarlyLintPassObject + sync :: Send + sync :: Sync > > ,
61
+ early_passes : Vec < Box < dyn Fn ( ) -> EarlyLintPassObject + sync :: Send + sync :: Sync > > ,
62
+ late_passes : Vec < Box < dyn Fn ( ) -> LateLintPassObject + sync :: Send + sync :: Sync > > ,
63
63
/// This is unique in that we construct them per-module, so not once.
64
- late_module_passes : Vec < fn ( ) -> LateLintPassObject > ,
64
+ late_module_passes : Vec < Box < dyn Fn ( ) -> LateLintPassObject + sync :: Send + sync :: Sync > > ,
65
65
66
66
/// Lints indexed by name.
67
67
by_name : FxHashMap < String , TargetLint > ,
@@ -155,20 +155,24 @@ impl LintStore {
155
155
. collect ( )
156
156
}
157
157
158
- pub fn register_early_pass ( & mut self , pass : fn ( ) -> EarlyLintPassObject ) {
159
- self . early_passes . push ( pass) ;
158
+ pub fn register_early_pass ( & mut self ,
159
+ pass : impl Fn ( ) -> EarlyLintPassObject + ' static + sync:: Send + sync:: Sync ) {
160
+ self . early_passes . push ( Box :: new ( pass) ) ;
160
161
}
161
162
162
- pub fn register_pre_expansion_pass ( & mut self , pass : fn ( ) -> EarlyLintPassObject ) {
163
- self . pre_expansion_passes . push ( pass) ;
163
+ pub fn register_pre_expansion_pass ( & mut self ,
164
+ pass : impl Fn ( ) -> EarlyLintPassObject + ' static + sync:: Send + sync:: Sync ) {
165
+ self . pre_expansion_passes . push ( Box :: new ( pass) ) ;
164
166
}
165
167
166
- pub fn register_late_pass ( & mut self , pass : fn ( ) -> LateLintPassObject ) {
167
- self . late_passes . push ( pass) ;
168
+ pub fn register_late_pass ( & mut self ,
169
+ pass : impl Fn ( ) -> LateLintPassObject + ' static + sync:: Send + sync:: Sync ) {
170
+ self . late_passes . push ( Box :: new ( pass) ) ;
168
171
}
169
172
170
- pub fn register_late_mod_pass ( & mut self , pass : fn ( ) -> LateLintPassObject ) {
171
- self . late_module_passes . push ( pass) ;
173
+ pub fn register_late_mod_pass ( & mut self ,
174
+ pass : impl Fn ( ) -> LateLintPassObject + ' static + sync:: Send + sync:: Sync ) {
175
+ self . late_module_passes . push ( Box :: new ( pass) ) ;
172
176
}
173
177
174
178
// Helper method for register_early/late_pass
0 commit comments