Skip to content

Commit 4e0ee75

Browse files
committed
Impl CompilerCalls for CompileController instead of AdHocCompilerCalls
1 parent 4f45b06 commit 4e0ee75

File tree

2 files changed

+57
-24
lines changed

2 files changed

+57
-24
lines changed

src/librustc_driver/driver.rs

+57
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,63 @@ impl<'a> CompileController<'a> {
414414
}
415415
}
416416

417+
impl<'a> ::CompilerCalls<'a> for CompileController<'a> {
418+
fn early_callback(
419+
&mut self,
420+
matches: &::getopts::Matches,
421+
sopts: &config::Options,
422+
cfg: &ast::CrateConfig,
423+
descriptions: &::errors::registry::Registry,
424+
output: ::ErrorOutputType,
425+
) -> Compilation {
426+
::RustcDefaultCalls.early_callback(
427+
matches,
428+
sopts,
429+
cfg,
430+
descriptions,
431+
output,
432+
)
433+
}
434+
fn no_input(
435+
&mut self,
436+
matches: &::getopts::Matches,
437+
sopts: &config::Options,
438+
cfg: &ast::CrateConfig,
439+
odir: &Option<PathBuf>,
440+
ofile: &Option<PathBuf>,
441+
descriptions: &::errors::registry::Registry,
442+
) -> Option<(Input, Option<PathBuf>)> {
443+
::RustcDefaultCalls.no_input(
444+
matches,
445+
sopts,
446+
cfg,
447+
odir,
448+
ofile,
449+
descriptions,
450+
)
451+
}
452+
fn late_callback(
453+
&mut self,
454+
codegen_backend: &::CodegenBackend,
455+
matches: &::getopts::Matches,
456+
sess: &Session,
457+
cstore: &::CrateStore,
458+
input: &Input,
459+
odir: &Option<PathBuf>,
460+
ofile: &Option<PathBuf>,
461+
) -> Compilation {
462+
::RustcDefaultCalls
463+
.late_callback(codegen_backend, matches, sess, cstore, input, odir, ofile)
464+
}
465+
fn build_controller(
466+
self: Box<Self>,
467+
_: &Session,
468+
_: &::getopts::Matches
469+
) -> CompileController<'a> {
470+
*self
471+
}
472+
}
473+
417474
pub struct PhaseController<'a> {
418475
pub stop: Compilation,
419476
// If true then the compiler will try to run the callback even if the phase

src/librustc_driver/lib.rs

-24
Original file line numberDiff line numberDiff line change
@@ -712,30 +712,6 @@ pub trait CompilerCalls<'a> {
712712
#[derive(Copy, Clone)]
713713
pub struct RustcDefaultCalls;
714714

715-
/// CompilerCalls instance for quick access to the result of one compile phase.
716-
pub enum AdHocCalls<'a> {
717-
AfterAnalysis(Compilation, Box<Fn(&mut ::driver::CompileState) + 'a>)
718-
}
719-
720-
impl<'a> CompilerCalls<'a> for AdHocCalls<'a> {
721-
fn build_controller(
722-
self: Box<Self>,
723-
_: &Session,
724-
_: &getopts::Matches
725-
) -> CompileController<'a> {
726-
let mut control = CompileController::basic();
727-
728-
match *self {
729-
AdHocCalls::AfterAnalysis(c, f) => {
730-
control.after_analysis.stop = c;
731-
control.after_analysis.callback = f;
732-
}
733-
}
734-
735-
control
736-
}
737-
}
738-
739715
// FIXME remove these and use winapi 0.3 instead
740716
// Duplicates: bootstrap/compile.rs, librustc_errors/emitter.rs
741717
#[cfg(unix)]

0 commit comments

Comments
 (0)