X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibrustdoc%2Fdocfs.rs;h=9c9a00295c3fa2026c6e5b29672d9380cf838103;hb=c717721c1b9e076739b4fbf44a83cc9c77008853;hp=2a107e828f75ffafb9cc63bfc4b316a5c2e5eb38;hpb=07effe18b01bfe559c6bcdc07ab7f004292bc8cc;p=rust.git diff --git a/src/librustdoc/docfs.rs b/src/librustdoc/docfs.rs index 2a107e828f7..9c9a00295c3 100644 --- a/src/librustdoc/docfs.rs +++ b/src/librustdoc/docfs.rs @@ -9,8 +9,6 @@ //! needs to read-after-write from a file, then it would be added to this //! abstraction. -use errors; - use std::fs; use std::io; use std::path::Path; @@ -42,7 +40,7 @@ pub fn new() -> ErrorStorage { } /// Prints all stored errors. Returns the number of printed errors. - pub fn write_errors(&mut self, diag: &errors::Handler) -> usize { + pub fn write_errors(&mut self, diag: &rustc_errors::Handler) -> usize { let mut printed = 0; // In order to drop the sender part of the channel. self.sender = None; @@ -92,14 +90,14 @@ pub fn write(&self, path: P, contents: C) -> Result<(), E> let sender = self.errors.sender.clone().unwrap(); rayon::spawn(move || match fs::write(&path, &contents) { Ok(_) => { - sender - .send(None) - .expect(&format!("failed to send error on \"{}\"", path.display())); + sender.send(None).unwrap_or_else(|_| { + panic!("failed to send error on \"{}\"", path.display()) + }); } Err(e) => { - sender - .send(Some(format!("\"{}\": {}", path.display(), e))) - .expect(&format!("failed to send non-error on \"{}\"", path.display())); + sender.send(Some(format!("\"{}\": {}", path.display(), e))).unwrap_or_else( + |_| panic!("failed to send non-error on \"{}\"", path.display()), + ); } }); Ok(())