Rollup merge of #47661 - bjorn3:refactor_driver, r=michaelwoerister
Inline some rustc_driver function
This commit is contained in:
commit
6dcaa0af20
2 changed files with 22 additions and 39 deletions
|
@ -51,14 +51,12 @@ use std::iter;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::mpsc;
|
use std::sync::mpsc;
|
||||||
use syntax::{ast, diagnostics, visit};
|
use syntax::{self, ast, attr, diagnostics, visit};
|
||||||
use syntax::attr;
|
|
||||||
use syntax::ext::base::ExtCtxt;
|
use syntax::ext::base::ExtCtxt;
|
||||||
use syntax::fold::Folder;
|
use syntax::fold::Folder;
|
||||||
use syntax::parse::{self, PResult};
|
use syntax::parse::{self, PResult};
|
||||||
use syntax::util::node_count::NodeCounter;
|
use syntax::util::node_count::NodeCounter;
|
||||||
use syntax_pos::FileName;
|
use syntax_pos::FileName;
|
||||||
use syntax;
|
|
||||||
use syntax_ext;
|
use syntax_ext;
|
||||||
|
|
||||||
use derive_registrar;
|
use derive_registrar;
|
||||||
|
@ -274,10 +272,6 @@ pub fn compile_input(trans: Box<TransCrate>,
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn keep_hygiene_data(sess: &Session) -> bool {
|
|
||||||
sess.opts.debugging_opts.keep_hygiene_data
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn source_name(input: &Input) -> FileName {
|
pub fn source_name(input: &Input) -> FileName {
|
||||||
match *input {
|
match *input {
|
||||||
Input::File(ref ifile) => ifile.clone().into(),
|
Input::File(ref ifile) => ifile.clone().into(),
|
||||||
|
@ -851,7 +845,7 @@ pub fn phase_2_configure_and_expand<F>(sess: &Session,
|
||||||
|| lint::check_ast_crate(sess, &krate));
|
|| lint::check_ast_crate(sess, &krate));
|
||||||
|
|
||||||
// Discard hygiene data, which isn't required after lowering to HIR.
|
// Discard hygiene data, which isn't required after lowering to HIR.
|
||||||
if !keep_hygiene_data(sess) {
|
if !sess.opts.debugging_opts.keep_hygiene_data {
|
||||||
syntax::ext::hygiene::clear_markings();
|
syntax::ext::hygiene::clear_markings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -915,18 +909,6 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(trans: &TransCrate,
|
||||||
mpsc::Receiver<Box<Any + Send>>,
|
mpsc::Receiver<Box<Any + Send>>,
|
||||||
CompileResult) -> R
|
CompileResult) -> R
|
||||||
{
|
{
|
||||||
macro_rules! try_with_f {
|
|
||||||
($e: expr, ($($t:tt)*)) => {
|
|
||||||
match $e {
|
|
||||||
Ok(x) => x,
|
|
||||||
Err(x) => {
|
|
||||||
f($($t)*, Err(x));
|
|
||||||
return Err(x);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let time_passes = sess.time_passes();
|
let time_passes = sess.time_passes();
|
||||||
|
|
||||||
let query_result_on_disk_cache = time(time_passes,
|
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,
|
||||||
|| stability::check_unstable_api_usage(tcx));
|
|| stability::check_unstable_api_usage(tcx));
|
||||||
|
|
||||||
// passes are timed inside typeck
|
// passes are timed inside typeck
|
||||||
try_with_f!(typeck::check_crate(tcx), (tcx, analysis, rx));
|
match typeck::check_crate(tcx) {
|
||||||
|
Ok(x) => x,
|
||||||
|
Err(x) => {
|
||||||
|
f(tcx, analysis, rx, Err(x));
|
||||||
|
return Err(x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
time(time_passes,
|
time(time_passes,
|
||||||
"const checking",
|
"const checking",
|
||||||
|
|
|
@ -670,7 +670,7 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
|
||||||
control.after_hir_lowering.stop = Compilation::Stop;
|
control.after_hir_lowering.stop = Compilation::Stop;
|
||||||
}
|
}
|
||||||
|
|
||||||
if save_analysis(sess) {
|
if sess.opts.debugging_opts.save_analysis {
|
||||||
enable_save_analysis(&mut control);
|
enable_save_analysis(&mut control);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -705,10 +705,6 @@ pub fn enable_save_analysis(control: &mut CompileController) {
|
||||||
control.make_glob_map = resolve::MakeGlobMap::Yes;
|
control.make_glob_map = resolve::MakeGlobMap::Yes;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn save_analysis(sess: &Session) -> bool {
|
|
||||||
sess.opts.debugging_opts.save_analysis
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RustcDefaultCalls {
|
impl RustcDefaultCalls {
|
||||||
pub fn list_metadata(sess: &Session,
|
pub fn list_metadata(sess: &Session,
|
||||||
cstore: &CrateStore,
|
cstore: &CrateStore,
|
||||||
|
@ -1330,20 +1326,19 @@ pub fn diagnostics_registry() -> errors::registry::Registry {
|
||||||
Registry::new(&all_errors)
|
Registry::new(&all_errors)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_args() -> Vec<String> {
|
|
||||||
env::args_os().enumerate()
|
|
||||||
.map(|(i, arg)| arg.into_string().unwrap_or_else(|arg| {
|
|
||||||
early_error(ErrorOutputType::default(),
|
|
||||||
&format!("Argument {} is not valid Unicode: {:?}", i, arg))
|
|
||||||
}))
|
|
||||||
.collect()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
env_logger::init().unwrap();
|
env_logger::init().unwrap();
|
||||||
let result = run(|| run_compiler(&get_args(),
|
let result = run(|| {
|
||||||
&mut RustcDefaultCalls,
|
let args = env::args_os().enumerate()
|
||||||
None,
|
.map(|(i, arg)| arg.into_string().unwrap_or_else(|arg| {
|
||||||
None));
|
early_error(ErrorOutputType::default(),
|
||||||
|
&format!("Argument {} is not valid Unicode: {:?}", i, arg))
|
||||||
|
}))
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
run_compiler(&args,
|
||||||
|
&mut RustcDefaultCalls,
|
||||||
|
None,
|
||||||
|
None)
|
||||||
|
});
|
||||||
process::exit(result as i32);
|
process::exit(result as i32);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue