Skip to content

Commit 76d1c6e

Browse files
committed
Mostly fix it
1 parent 32eed1c commit 76d1c6e

File tree

2 files changed

+28
-11
lines changed

2 files changed

+28
-11
lines changed

src/librustc_driver/driver.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ use rustc_incremental;
3232
use rustc_resolve::{MakeGlobMap, Resolver};
3333
use rustc_metadata::creader::CrateLoader;
3434
use rustc_metadata::cstore::{self, CStore};
35-
use rustc_trans as trans;
3635
use rustc_trans_utils::trans_crate::TransCrate;
3736
use rustc_typeck as typeck;
3837
use rustc_privacy;
@@ -41,7 +40,6 @@ use rustc_plugin as plugin;
4140
use rustc_passes::{self, ast_validation, no_asm, loops, consts, static_recursion, hir_stats};
4241
use rustc_const_eval::{self, check_match};
4342
use super::Compilation;
44-
use ::DefaultTransCrate;
4543

4644
use serialize::json;
4745

@@ -207,7 +205,7 @@ pub fn compile_input<Trans: TransCrate>(sess: &Session,
207205
None
208206
};
209207

210-
phase_3_run_analysis_passes<Trans, _, _>(sess,
208+
phase_3_run_analysis_passes::<Trans, _, _>(sess,
211209
cstore,
212210
hir_map,
213211
analysis,
@@ -387,7 +385,7 @@ impl<'a> PhaseController<'a> {
387385
/// State that is passed to a callback. What state is available depends on when
388386
/// during compilation the callback is made. See the various constructor methods
389387
/// (`state_*`) in the impl to see which data is provided for any given entry point.
390-
pub struct CompileState<'a, 'tcx: 'a> {
388+
pub struct CompileState<'a, 'tcx: 'a, Trans: TransCrate> {
391389
pub input: &'a Input,
392390
pub session: &'tcx Session,
393391
pub krate: Option<ast::Crate>,
@@ -405,10 +403,10 @@ pub struct CompileState<'a, 'tcx: 'a> {
405403
pub resolutions: Option<&'a Resolutions>,
406404
pub analysis: Option<&'a ty::CrateAnalysis>,
407405
pub tcx: Option<TyCtxt<'a, 'tcx, 'tcx>>,
408-
pub trans: Option<&'a trans::CrateTranslation>,
406+
pub trans: Option<&'a <Trans as TransCrate>::TranslatedCrate>,
409407
}
410408

411-
impl<'a, 'tcx> CompileState<'a, 'tcx> {
409+
impl<'a, 'tcx, Trans: TransCrate> CompileState<'a, 'tcx, Trans> {
412410
fn empty(input: &'a Input,
413411
session: &'tcx Session,
414412
out_dir: &'a Option<PathBuf>)
@@ -525,7 +523,7 @@ impl<'a, 'tcx> CompileState<'a, 'tcx> {
525523
session: &'tcx Session,
526524
out_dir: &'a Option<PathBuf>,
527525
out_file: &'a Option<PathBuf>,
528-
trans: &'a trans::CrateTranslation)
526+
trans: &'a <Trans as TransCrate>::TranslatedCrate)
529527
-> Self {
530528
CompileState {
531529
trans: Some(trans),

src/librustc_driver/lib.rs

+23-4
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,9 @@ pub fn run_compiler<'a>(args: &[String],
241241
let plugins = sess.opts.debugging_opts.extra_plugins.clone();
242242
let control = callbacks.build_controller(&sess, &matches);
243243

244-
let trans_name = sess.opts.debugging_opts.trans.unwrap_or_else(||"llvm".to_string());
245-
match *trans_name {
246-
"llvm" => {
244+
let trans_name = sess.opts.debugging_opts.trans.as_ref().map(|s|&**s);
245+
match trans_name {
246+
None => {
247247
let cstore = Rc::new(CStore::new(DefaultTransCrate::metadata_loader()));
248248

249249
do_or_return!(callbacks.late_callback(&matches,
@@ -262,7 +262,26 @@ pub fn run_compiler<'a>(args: &[String],
262262
&control),
263263
Some(sess))
264264
}
265-
_ => sess.fatal(&format!("Invalid trans {}", trans_name)),
265+
Some("llvm") => {
266+
let cstore = Rc::new(CStore::new(rustc_trans::LlvmTransCrate::metadata_loader()));
267+
268+
do_or_return!(callbacks.late_callback(&matches,
269+
&sess,
270+
&*cstore,
271+
&input,
272+
&odir,
273+
&ofile), Some(sess));
274+
275+
(driver::compile_input::<rustc_trans::LlvmTransCrate>(&sess,
276+
&cstore,
277+
&input,
278+
&odir,
279+
&ofile,
280+
Some(plugins),
281+
&control),
282+
Some(sess))
283+
}
284+
Some(trans_name) => sess.fatal(&format!("Invalid trans {}", trans_name)),
266285
}
267286
}
268287

0 commit comments

Comments
 (0)