diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index ab72f4a3f502c..509c4253f0f76 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -1003,8 +1003,10 @@ impl Tester for Collector { let outdir = if let Some(mut path) = rustdoc_options.persist_doctests.clone() { path.push(&test_id); - std::fs::create_dir_all(&path) - .expect("Couldn't create directory for doctest executables"); + if let Err(err) = std::fs::create_dir_all(&path) { + eprintln!("Couldn't create directory for doctest executables: {}", err); + panic::resume_unwind(box ()); + } DirState::Perm(path) } else { diff --git a/src/test/rustdoc-ui/issue-98690.rs b/src/test/rustdoc-ui/issue-98690.rs new file mode 100644 index 0000000000000..fe9bd87ab28e6 --- /dev/null +++ b/src/test/rustdoc-ui/issue-98690.rs @@ -0,0 +1,10 @@ +// compile-flags: --test --persist-doctests /../../ -Z unstable-options +// failure-status: 101 +// only-linux + +#![crate_name = "foo"] + +//! ```rust +//! use foo::dummy; +//! dummy(); +//! ``` diff --git a/src/test/rustdoc-ui/issue-98690.stderr b/src/test/rustdoc-ui/issue-98690.stderr new file mode 100644 index 0000000000000..47d94f99a4563 --- /dev/null +++ b/src/test/rustdoc-ui/issue-98690.stderr @@ -0,0 +1 @@ +Couldn't create directory for doctest executables: Permission denied (os error 13)