From 05ef20f92203b273d5019cce5ed7907a87420c6a Mon Sep 17 00:00:00 2001 From: Oliver Middleton Date: Sat, 23 Nov 2019 02:08:10 +0000 Subject: [PATCH] rustdoc: Don't panic when failing to write .lock file It can be treated like any other unexpected IO error. --- src/librustc_data_structures/flock.rs | 12 ------------ src/librustdoc/html/render.rs | 3 ++- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/librustc_data_structures/flock.rs b/src/librustc_data_structures/flock.rs index b0bd137f2cc4a..01f25a054f0a7 100644 --- a/src/librustc_data_structures/flock.rs +++ b/src/librustc_data_structures/flock.rs @@ -298,15 +298,3 @@ cfg_if! { } } } - -impl Lock { - pub fn panicking_new(p: &Path, - wait: bool, - create: bool, - exclusive: bool) - -> Lock { - Lock::new(p, wait, create, exclusive).unwrap_or_else(|err| { - panic!("could not lock `{}`: {}", p.display(), err); - }) - } -} diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index bd2a6602e16be..4bfcbc52ba1f3 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -546,7 +546,8 @@ fn write_shared( // Write out the shared files. Note that these are shared among all rustdoc // docs placed in the output directory, so this needs to be a synchronized // operation with respect to all other rustdocs running around. - let _lock = flock::Lock::panicking_new(&cx.dst.join(".lock"), true, true, true); + let lock_file = cx.dst.join(".lock"); + let _lock = try_err!(flock::Lock::new(&lock_file, true, true, true), &lock_file); // Add all the static files. These may already exist, but we just // overwrite them anyway to make sure that they're fresh and up-to-date.