Refactor DocFS to fix error handling bugs

This commit is contained in:
Joseph Ryan
2020-07-29 16:15:31 -05:00
parent cee8023c69
commit 7621a5b635
3 changed files with 34 additions and 55 deletions

View File

@@ -507,9 +507,14 @@ fn main_options(options: config::Options) -> i32 {
) {
Ok(_) => rustc_driver::EXIT_SUCCESS,
Err(e) => {
diag.struct_err(&format!("couldn't generate documentation: {}", e.error))
.note(&format!("failed to create or modify \"{}\"", e.file.display()))
.emit();
let mut msg =
diag.struct_err(&format!("couldn't generate documentation: {}", e.error));
let file = e.file.display().to_string();
if file.is_empty() {
msg.emit()
} else {
msg.note(&format!("failed to create or modify \"{}\"", file)).emit()
}
rustc_driver::EXIT_FAILURE
}
}