@@ -35,7 +35,7 @@ use crate::util::common::time;
3535use errors:: DiagnosticBuilder ;
3636use std:: slice;
3737use 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} ;
3939use rustc_serialize:: { Decoder , Decodable , Encoder , Encodable } ;
4040use syntax:: ast;
4141use syntax:: util:: lev_distance:: find_best_match_for_name;
@@ -57,11 +57,11 @@ pub struct LintStore {
5757 /// interior mutability, we don't enforce this (and lints should, in theory,
5858 /// be compatible with being constructed more than once, though not
5959 /// 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 > > ,
6363 /// 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 > > ,
6565
6666 /// Lints indexed by name.
6767 by_name : FxHashMap < String , TargetLint > ,
@@ -155,20 +155,24 @@ impl LintStore {
155155 . collect ( )
156156 }
157157
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) ) ;
160161 }
161162
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) ) ;
164166 }
165167
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) ) ;
168171 }
169172
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) ) ;
172176 }
173177
174178 // Helper method for register_early/late_pass
0 commit comments