Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent failure in case no space left on device in rustdoc #59734

Merged
merged 1 commit into from
Apr 26, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand All @@ -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 {
Expand Down