Skip to content

Commit aafa014

Browse files
authored
Rollup merge of rust-lang#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.
2 parents 445d699 + 79d85da commit aafa014

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/librustc_driver/driver.rs

+7
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,13 @@ pub fn compile_input(trans: Box<TransCrate>,
170170
return Ok(())
171171
}
172172

173+
if let &Some(ref dir) = outdir {
174+
if fs::create_dir_all(dir).is_err() {
175+
sess.err("failed to find or create the directory specified by --out-dir");
176+
return Err(CompileIncomplete::Stopped);
177+
}
178+
}
179+
173180
let arenas = AllArenas::new();
174181

175182
// Construct the HIR map

0 commit comments

Comments
 (0)