Skip to content

Commit

Permalink
Rollup merge of rust-lang#47854 - varkor:create-out-dir, r=pnkfelix
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kennytm authored Feb 8, 2018
2 parents 445d699 + 79d85da commit aafa014
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/librustc_driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit aafa014

Please sign in to comment.