Skip to content

Commit 00d68a7

Browse files
Rollup merge of rust-lang#98708 - pinkforest:rustdoc-fix-98690, r=GuillaumeGomez
rustdoc: fix 98690 Panic if invalid path for -Z persist-doctests Closes rust-lang#98690 for rustdoc panic I changed this to do eprintln and orderly panic instead of unwrap doing unhandled panic ~/gg/rust/build/x86_64-unknown-linux-gnu/stage2/bin/rustdoc --test -Z unstable-options --persist-doctests /tmp/foobar main.rs Couldn't create directory for doctest executables: Permission denied (os error 13)
2 parents b0935b1 + 6565509 commit 00d68a7

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

src/librustdoc/doctest.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1003,8 +1003,10 @@ impl Tester for Collector {
10031003
let outdir = if let Some(mut path) = rustdoc_options.persist_doctests.clone() {
10041004
path.push(&test_id);
10051005

1006-
std::fs::create_dir_all(&path)
1007-
.expect("Couldn't create directory for doctest executables");
1006+
if let Err(err) = std::fs::create_dir_all(&path) {
1007+
eprintln!("Couldn't create directory for doctest executables: {}", err);
1008+
panic::resume_unwind(box ());
1009+
}
10081010

10091011
DirState::Perm(path)
10101012
} else {

src/test/rustdoc-ui/issue-98690.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// compile-flags: --test --persist-doctests /../../ -Z unstable-options
2+
// failure-status: 101
3+
// only-linux
4+
5+
#![crate_name = "foo"]
6+
7+
//! ```rust
8+
//! use foo::dummy;
9+
//! dummy();
10+
//! ```
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Couldn't create directory for doctest executables: Permission denied (os error 13)

0 commit comments

Comments
 (0)