Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1148,9 +1148,18 @@ pub fn diagnostics_registry() -> errors::registry::Registry {
Registry::new(&all_errors)
}

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() {
env_logger::init().unwrap();
let result = run(|| run_compiler(&env::args().collect::<Vec<_>>(),
let result = run(|| run_compiler(&get_args(),
&mut RustcDefaultCalls,
None,
None));
Expand Down
11 changes: 9 additions & 2 deletions src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,19 @@ pub fn main() {
const STACK_SIZE: usize = 32_000_000; // 32MB
env_logger::init().unwrap();
let res = std::thread::Builder::new().stack_size(STACK_SIZE).spawn(move || {
let s = env::args().collect::<Vec<_>>();
main_args(&s)
get_args().map(|args| main_args(&args)).unwrap_or(1)
}).unwrap().join().unwrap_or(101);
process::exit(res as i32);
}

fn get_args() -> Option<Vec<String>> {
env::args_os().enumerate()
.map(|(i, arg)| arg.into_string().map_err(|arg| {
print_error(format!("Argument {} is not valid Unicode: {:?}", i, arg));
}).ok())
.collect()
}

fn stable(g: getopts::OptGroup) -> RustcOptGroup { RustcOptGroup::stable(g) }
fn unstable(g: getopts::OptGroup) -> RustcOptGroup { RustcOptGroup::unstable(g) }

Expand Down