Skip to content

Commit a2b1714

Browse files
Add regression test for rustdoc scrape-examples feature crash (#144752)
1 parent 768f977 commit a2b1714

File tree

5 files changed

+35
-0
lines changed

5 files changed

+35
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[package]
2+
name = "foo"
3+
version = "0.0.1"
4+
edition = "2024"
5+
6+
[[example]]
7+
name = "complex"
8+
doc-scrape-examples = true
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
let mut x = foo::X::new();
3+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// This file MUST exist to trigger the original bug.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
pub struct X;
2+
3+
impl X {
4+
pub fn new() -> Self {
5+
X
6+
}
7+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//! Test to ensure that the rustdoc `scrape-examples` feature is not panicking.
2+
//! Regression test for <https://github.com/rust-lang/rust/issues/144752>.
3+
4+
use run_make_support::{cargo, path, rfs};
5+
6+
fn main() {
7+
// We copy the crate to be documented "outside" to prevent documenting
8+
// the whole compiler.
9+
let tmp = std::env::temp_dir();
10+
let test_crate = tmp.join("foo");
11+
rfs::copy_dir_all(path("foo"), &test_crate);
12+
13+
// The `scrape-examples` feature is also implemented in `cargo` so instead of reproducing
14+
// what `cargo` does, better to just let `cargo` do it.
15+
cargo().current_dir(&test_crate).args(["doc", "-p", "foo", "-Zrustdoc-scrape-examples"]).run();
16+
}

0 commit comments

Comments
 (0)