Rollup merge of #47854 - varkor:create-out-dir, r=pnkfelix

Create a directory for --out-dir if it does not already exist

Currently if `--out-dir` is set to a non-existent directory, the compiler will throw unfriendly messages like `error: could not write output to subdir/example.crate.allocator.rcgu.o: No such file or
directory`, which, while not completely unreadable, isn’t very user-friendly either. This change creates the directory automatically if it does not yet exist.
This commit is contained in:
kennytm 2018-02-10 14:23:56 +08:00 committed by GitHub
commit 262703cbbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 0 deletions

View File

@ -170,6 +170,13 @@ pub fn compile_input(trans: Box<TransCrate>,
return Ok(())
}
if let &Some(ref dir) = outdir {
if fs::create_dir_all(dir).is_err() {
sess.err("failed to find or create the directory specified by --out-dir");
return Err(CompileIncomplete::Stopped);
}
}
let arenas = AllArenas::new();
// Construct the HIR map