about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-04-26 03:50:11 +0200
committerGitHub <noreply@github.com>2019-04-26 03:50:11 +0200
commit294e89d5fa910deeabfb2298b417decb86bbc1ef (patch)
treef2f9ff8998cebbc6526d387de457750cb66d2866
parent3991285f55a4b7cd92b7ffcdc396a3023076f5cb (diff)
parentfeb5a53266902d9c66bf9e5ef5e28fe1534a01a9 (diff)
downloadrust-294e89d5fa910deeabfb2298b417decb86bbc1ef.tar.gz
rust-294e89d5fa910deeabfb2298b417decb86bbc1ef.zip
Rollup merge of #59734 - GuillaumeGomez:improve-rustdoc-failure, r=ollie27
Prevent failure in case no space left on device in rustdoc

Fixes #59703.

r? @QuietMisdreavus
-rw-r--r--src/librustdoc/html/render.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index 487c57172d9..0bc06ea8b3b 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -1358,7 +1358,8 @@ fn write_minify_replacer<W: Write>(
 /// static HTML tree. Each component in the cleaned path will be passed as an
 /// argument to `f`. The very last component of the path (ie the file name) will
 /// be passed to `f` if `keep_filename` is true, and ignored otherwise.
-fn clean_srcpath<F>(src_root: &Path, p: &Path, keep_filename: bool, mut f: F) where
+fn clean_srcpath<F>(src_root: &Path, p: &Path, keep_filename: bool, mut f: F)
+where
     F: FnMut(&OsStr),
 {
     // make it relative, if possible
@@ -1470,11 +1471,11 @@ impl<'a> SourceCollector<'a> {
         let mut href = String::new();
         clean_srcpath(&self.scx.src_root, &p, false, |component| {
             cur.push(component);
-            fs::create_dir_all(&cur).unwrap();
             root_path.push_str("../");
             href.push_str(&component.to_string_lossy());
             href.push('/');
         });
+        fs::create_dir_all(&cur)?;
         let mut fname = p.file_name()
                          .expect("source has no filename")
                          .to_os_string();
@@ -1483,7 +1484,7 @@ impl<'a> SourceCollector<'a> {
         href.push_str(&fname.to_string_lossy());
 
         let mut w = BufWriter::new(File::create(&cur)?);
-        let title = format!("{} -- source", cur.file_name().unwrap()
+        let title = format!("{} -- source", cur.file_name().expect("failed to get file name")
                                                .to_string_lossy());
         let desc = format!("Source to the Rust file `{}`.", filename);
         let page = layout::Page {