Skip to content

Commit feb5a53

Browse files
committedApr 24, 2019
Prevent failure in case no space left on device in rustdoc
1 parent 4eff852 commit feb5a53

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed
 

‎src/librustdoc/html/render.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1358,7 +1358,8 @@ fn write_minify_replacer<W: Write>(
13581358
/// static HTML tree. Each component in the cleaned path will be passed as an
13591359
/// argument to `f`. The very last component of the path (ie the file name) will
13601360
/// be passed to `f` if `keep_filename` is true, and ignored otherwise.
1361-
fn clean_srcpath<F>(src_root: &Path, p: &Path, keep_filename: bool, mut f: F) where
1361+
fn clean_srcpath<F>(src_root: &Path, p: &Path, keep_filename: bool, mut f: F)
1362+
where
13621363
F: FnMut(&OsStr),
13631364
{
13641365
// make it relative, if possible
@@ -1470,11 +1471,11 @@ impl<'a> SourceCollector<'a> {
14701471
let mut href = String::new();
14711472
clean_srcpath(&self.scx.src_root, &p, false, |component| {
14721473
cur.push(component);
1473-
fs::create_dir_all(&cur).unwrap();
14741474
root_path.push_str("../");
14751475
href.push_str(&component.to_string_lossy());
14761476
href.push('/');
14771477
});
1478+
fs::create_dir_all(&cur)?;
14781479
let mut fname = p.file_name()
14791480
.expect("source has no filename")
14801481
.to_os_string();
@@ -1483,7 +1484,7 @@ impl<'a> SourceCollector<'a> {
14831484
href.push_str(&fname.to_string_lossy());
14841485

14851486
let mut w = BufWriter::new(File::create(&cur)?);
1486-
let title = format!("{} -- source", cur.file_name().unwrap()
1487+
let title = format!("{} -- source", cur.file_name().expect("failed to get file name")
14871488
.to_string_lossy());
14881489
let desc = format!("Source to the Rust file `{}`.", filename);
14891490
let page = layout::Page {

0 commit comments

Comments
 (0)
Please sign in to comment.