Skip to content

Commit c3fabce

Browse files
committed
Inline some rustc_driver function
1 parent fdc18b3 commit c3fabce

File tree

2 files changed

+22
-39
lines changed

2 files changed

+22
-39
lines changed

src/librustc_driver/driver.rs

+9-21
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,12 @@ use std::iter;
5151
use std::path::{Path, PathBuf};
5252
use std::rc::Rc;
5353
use std::sync::mpsc;
54-
use syntax::{ast, diagnostics, visit};
55-
use syntax::attr;
54+
use syntax::{self, ast, attr, diagnostics, visit};
5655
use syntax::ext::base::ExtCtxt;
5756
use syntax::fold::Folder;
5857
use syntax::parse::{self, PResult};
5958
use syntax::util::node_count::NodeCounter;
6059
use syntax_pos::FileName;
61-
use syntax;
6260
use syntax_ext;
6361

6462
use derive_registrar;
@@ -274,10 +272,6 @@ pub fn compile_input(trans: Box<TransCrate>,
274272
Ok(())
275273
}
276274

277-
fn keep_hygiene_data(sess: &Session) -> bool {
278-
sess.opts.debugging_opts.keep_hygiene_data
279-
}
280-
281275
pub fn source_name(input: &Input) -> FileName {
282276
match *input {
283277
Input::File(ref ifile) => ifile.clone().into(),
@@ -851,7 +845,7 @@ pub fn phase_2_configure_and_expand<F>(sess: &Session,
851845
|| lint::check_ast_crate(sess, &krate));
852846

853847
// Discard hygiene data, which isn't required after lowering to HIR.
854-
if !keep_hygiene_data(sess) {
848+
if !sess.opts.debugging_opts.keep_hygiene_data {
855849
syntax::ext::hygiene::clear_markings();
856850
}
857851

@@ -915,18 +909,6 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(trans: &TransCrate,
915909
mpsc::Receiver<Box<Any + Send>>,
916910
CompileResult) -> R
917911
{
918-
macro_rules! try_with_f {
919-
($e: expr, ($($t:tt)*)) => {
920-
match $e {
921-
Ok(x) => x,
922-
Err(x) => {
923-
f($($t)*, Err(x));
924-
return Err(x);
925-
}
926-
}
927-
}
928-
}
929-
930912
let time_passes = sess.time_passes();
931913

932914
let query_result_on_disk_cache = time(time_passes,
@@ -987,7 +969,13 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(trans: &TransCrate,
987969
|| stability::check_unstable_api_usage(tcx));
988970

989971
// passes are timed inside typeck
990-
try_with_f!(typeck::check_crate(tcx), (tcx, analysis, rx));
972+
match typeck::check_crate(tcx) {
973+
Ok(x) => x,
974+
Err(x) => {
975+
f(tcx, analysis, rx, Err(x));
976+
return Err(x);
977+
}
978+
}
991979

992980
time(time_passes,
993981
"const checking",

src/librustc_driver/lib.rs

+13-18
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
669669
control.after_hir_lowering.stop = Compilation::Stop;
670670
}
671671

672-
if save_analysis(sess) {
672+
if sess.opts.debugging_opts.save_analysis {
673673
enable_save_analysis(&mut control);
674674
}
675675

@@ -704,10 +704,6 @@ pub fn enable_save_analysis(control: &mut CompileController) {
704704
control.make_glob_map = resolve::MakeGlobMap::Yes;
705705
}
706706

707-
fn save_analysis(sess: &Session) -> bool {
708-
sess.opts.debugging_opts.save_analysis
709-
}
710-
711707
impl RustcDefaultCalls {
712708
pub fn list_metadata(sess: &Session,
713709
cstore: &CrateStore,
@@ -1329,20 +1325,19 @@ pub fn diagnostics_registry() -> errors::registry::Registry {
13291325
Registry::new(&all_errors)
13301326
}
13311327

1332-
pub fn get_args() -> Vec<String> {
1333-
env::args_os().enumerate()
1334-
.map(|(i, arg)| arg.into_string().unwrap_or_else(|arg| {
1335-
early_error(ErrorOutputType::default(),
1336-
&format!("Argument {} is not valid Unicode: {:?}", i, arg))
1337-
}))
1338-
.collect()
1339-
}
1340-
13411328
pub fn main() {
13421329
env_logger::init().unwrap();
1343-
let result = run(|| run_compiler(&get_args(),
1344-
&mut RustcDefaultCalls,
1345-
None,
1346-
None));
1330+
let result = run(|| {
1331+
let args = env::args_os().enumerate()
1332+
.map(|(i, arg)| arg.into_string().unwrap_or_else(|arg| {
1333+
early_error(ErrorOutputType::default(),
1334+
&format!("Argument {} is not valid Unicode: {:?}", i, arg))
1335+
}))
1336+
.collect::<Vec<_>>();
1337+
run_compiler(&args,
1338+
&mut RustcDefaultCalls,
1339+
None,
1340+
None)
1341+
});
13471342
process::exit(result as i32);
13481343
}

0 commit comments

Comments
 (0)