Skip to content

Commit fa01251

Browse files
committed
rustc: print filename if file cannot be written
File cannot be written, for example, if directory does not exist. Before this commit: ``` % rustc -o nonexistent/program program.rs error: could not write output: No such file or directory ``` With this commit: ``` % rustc -o nonexistent/program program.rs error: could not write output to nonexistent/program.0.o: No such file or directory ``` This is useful when full rust command is not displayed, or when last error is preceded by thousands of warnings.
1 parent 89c4e37 commit fa01251

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/librustc_trans/back/write.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ pub fn write_output_file(
6767
output: &Path,
6868
file_type: llvm::FileType) {
6969
unsafe {
70-
let output = CString::from_slice(output.as_vec());
70+
let output_c = CString::from_slice(output.as_vec());
7171
let result = llvm::LLVMRustWriteOutputFile(
72-
target, pm, m, output.as_ptr(), file_type);
72+
target, pm, m, output_c.as_ptr(), file_type);
7373
if !result {
74-
llvm_err(handler, "could not write output".to_string());
74+
llvm_err(handler, format!("could not write output to {}", output.display()));
7575
}
7676
}
7777
}

0 commit comments

Comments
 (0)