Skip to content

Commit 79d85da

Browse files
committed
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.
1 parent 6b99ade commit 79d85da

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
@@ -163,6 +163,13 @@ pub fn compile_input(trans: Box<TransCrate>,
163163
return Ok(())
164164
}
165165

166+
if let &Some(ref dir) = outdir {
167+
if fs::create_dir_all(dir).is_err() {
168+
sess.err("failed to find or create the directory specified by --out-dir");
169+
return Err(CompileIncomplete::Stopped);
170+
}
171+
}
172+
166173
let arenas = AllArenas::new();
167174

168175
// Construct the HIR map

0 commit comments

Comments
 (0)