rollup merge of #21333: stepancheg/trans-write-diag

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 followed by thousands of warnings.
This commit is contained in:
Alex Crichton 2015-01-21 09:13:49 -08:00
commit 5da25386b3

View file

@ -67,11 +67,11 @@ pub fn write_output_file(
output: &Path,
file_type: llvm::FileType) {
unsafe {
let output = CString::from_slice(output.as_vec());
let output_c = CString::from_slice(output.as_vec());
let result = llvm::LLVMRustWriteOutputFile(
target, pm, m, output.as_ptr(), file_type);
target, pm, m, output_c.as_ptr(), file_type);
if !result {
llvm_err(handler, "could not write output".to_string());
llvm_err(handler, format!("could not write output to {}", output.display()));
}
}
}