Skip to content

Commit

Permalink
Create a directory for --out-dir if it does not already exist
Browse files Browse the repository at this point in the history
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
varkor committed Jan 29, 2018
1 parent 6b99ade commit 79d85da
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 @@ -163,6 +163,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 79d85da

Please sign in to comment.