@@ -454,7 +454,7 @@ fn get_codegen_sysroot(backend_name: &str) -> fn() -> Box<CodegenBackend> {
454
454
// See comments on CompilerCalls below for details about the callbacks argument.
455
455
// The FileLoader provides a way to load files from sources other than the file system.
456
456
pub fn run_compiler < ' a > ( args : & [ String ] ,
457
- callbacks : & mut ( CompilerCalls < ' a > + sync:: Send ) ,
457
+ callbacks : Box < CompilerCalls < ' a > + sync:: Send + ' a > ,
458
458
file_loader : Option < Box < FileLoader + Send + Sync + ' static > > ,
459
459
emitter_dest : Option < Box < Write + Send > > )
460
460
-> ( CompileResult , Option < Session > )
@@ -478,7 +478,7 @@ fn run_compiler_with_pool<'a>(
478
478
matches : getopts:: Matches ,
479
479
sopts : config:: Options ,
480
480
cfg : ast:: CrateConfig ,
481
- callbacks : & mut ( CompilerCalls < ' a > + sync:: Send ) ,
481
+ mut callbacks : Box < CompilerCalls < ' a > + sync:: Send + ' a > ,
482
482
file_loader : Option < Box < FileLoader + Send + Sync + ' static > > ,
483
483
emitter_dest : Option < Box < Write + Send > >
484
484
) -> ( CompileResult , Option < Session > ) {
@@ -642,12 +642,12 @@ impl Compilation {
642
642
}
643
643
}
644
644
645
- // A trait for customising the compilation process. Offers a number of hooks for
646
- // executing custom code or customising input.
645
+ /// A trait for customising the compilation process. Offers a number of hooks for
646
+ /// executing custom code or customising input.
647
647
pub trait CompilerCalls < ' a > {
648
- // Hook for a callback early in the process of handling arguments. This will
649
- // be called straight after options have been parsed but before anything
650
- // else (e.g., selecting input and output).
648
+ /// Hook for a callback early in the process of handling arguments. This will
649
+ /// be called straight after options have been parsed but before anything
650
+ /// else (e.g., selecting input and output).
651
651
fn early_callback ( & mut self ,
652
652
_: & getopts:: Matches ,
653
653
_: & config:: Options ,
@@ -658,9 +658,9 @@ pub trait CompilerCalls<'a> {
658
658
Compilation :: Continue
659
659
}
660
660
661
- // Hook for a callback late in the process of handling arguments. This will
662
- // be called just before actual compilation starts (and before build_controller
663
- // is called), after all arguments etc. have been completely handled.
661
+ /// Hook for a callback late in the process of handling arguments. This will
662
+ /// be called just before actual compilation starts (and before build_controller
663
+ /// is called), after all arguments etc. have been completely handled.
664
664
fn late_callback ( & mut self ,
665
665
_: & CodegenBackend ,
666
666
_: & getopts:: Matches ,
@@ -673,21 +673,21 @@ pub trait CompilerCalls<'a> {
673
673
Compilation :: Continue
674
674
}
675
675
676
- // Called after we extract the input from the arguments. Gives the implementer
677
- // an opportunity to change the inputs or to add some custom input handling.
678
- // The default behaviour is to simply pass through the inputs.
676
+ /// Called after we extract the input from the arguments. Gives the implementer
677
+ /// an opportunity to change the inputs or to add some custom input handling.
678
+ /// The default behaviour is to simply pass through the inputs.
679
679
fn some_input ( & mut self ,
680
680
input : Input ,
681
681
input_path : Option < PathBuf > )
682
682
-> ( Input , Option < PathBuf > ) {
683
683
( input, input_path)
684
684
}
685
685
686
- // Called after we extract the input from the arguments if there is no valid
687
- // input. Gives the implementer an opportunity to supply alternate input (by
688
- // returning a Some value) or to add custom behaviour for this error such as
689
- // emitting error messages. Returning None will cause compilation to stop
690
- // at this point.
686
+ /// Called after we extract the input from the arguments if there is no valid
687
+ /// input. Gives the implementer an opportunity to supply alternate input (by
688
+ /// returning a Some value) or to add custom behaviour for this error such as
689
+ /// emitting error messages. Returning None will cause compilation to stop
690
+ /// at this point.
691
691
fn no_input ( & mut self ,
692
692
_: & getopts:: Matches ,
693
693
_: & config:: Options ,
@@ -701,10 +701,14 @@ pub trait CompilerCalls<'a> {
701
701
702
702
// Create a CompilController struct for controlling the behaviour of
703
703
// compilation.
704
- fn build_controller ( & mut self , _: & Session , _: & getopts:: Matches ) -> CompileController < ' a > ;
704
+ fn build_controller (
705
+ self : Box < Self > ,
706
+ _: & Session ,
707
+ _: & getopts:: Matches
708
+ ) -> CompileController < ' a > ;
705
709
}
706
710
707
- // CompilerCalls instance for a regular rustc build.
711
+ /// CompilerCalls instance for a regular rustc build.
708
712
#[ derive( Copy , Clone ) ]
709
713
pub struct RustcDefaultCalls ;
710
714
@@ -878,7 +882,7 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
878
882
. and_then ( || RustcDefaultCalls :: list_metadata ( sess, cstore, matches, input) )
879
883
}
880
884
881
- fn build_controller ( & mut self ,
885
+ fn build_controller ( self : Box < Self > ,
882
886
sess : & Session ,
883
887
matches : & getopts:: Matches )
884
888
-> CompileController < ' a > {
@@ -1693,7 +1697,7 @@ pub fn main() {
1693
1697
} ) )
1694
1698
. collect :: < Vec < _ > > ( ) ;
1695
1699
run_compiler ( & args,
1696
- & mut RustcDefaultCalls ,
1700
+ Box :: new ( RustcDefaultCalls ) ,
1697
1701
None ,
1698
1702
None )
1699
1703
} ) ;
0 commit comments