Skip to content

Commit decc3f0

Browse files
committed
Gate fallible Docscrape unit feature behind -Z ignore-scrape-failures
1 parent a3a4e86 commit decc3f0

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

src/cargo/core/features.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,7 @@ unstable_cli_options!(
663663
// TODO(wcrichto): move scrape example configuration into Cargo.toml before stabilization
664664
// See: https://github.com/rust-lang/cargo/pull/9525#discussion_r728470927
665665
rustdoc_scrape_examples: Option<String> = ("Allow rustdoc to scrape examples from reverse-dependencies for documentation"),
666+
ignore_scrape_failures: bool = ("When scraping examples for Rustdoc, don't stop compilation if an example fails"),
666667
skip_rustdoc_fingerprint: bool = (HIDDEN),
667668
);
668669

@@ -936,6 +937,7 @@ impl CliUnstable {
936937
)
937938
}
938939
}
940+
"ignore-scrape-failures" => self.ignore_scrape_failures = parse_empty(k, v)?,
939941
"skip-rustdoc-fingerprint" => self.skip_rustdoc_fingerprint = parse_empty(k, v)?,
940942
"compile-progress" => stabilized_warn(k, "1.30", STABILIZED_COMPILE_PROGRESS),
941943
"offline" => stabilized_err(k, "1.36", STABILIZED_OFFLINE)?,

src/cargo/ops/cargo_compile.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,7 @@ fn generate_targets(
10691069
/*is_std*/ false,
10701070
/*dep_hash*/ 0,
10711071
IsArtifact::No,
1072-
mode.is_doc_scrape(),
1072+
mode.is_doc_scrape() && ws.config().cli_unstable().ignore_scrape_failures,
10731073
);
10741074
units.insert(unit);
10751075
}

tests/testsuite/doc.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2667,10 +2667,12 @@ fn scrape_examples_no_fail_bad_example() {
26672667
.file("src/lib.rs", "pub fn foo(){}")
26682668
.build();
26692669

2670-
p.cargo("doc -v -Zunstable-options -Z rustdoc-scrape-examples=examples")
2671-
.masquerade_as_nightly_cargo()
2672-
.with_stderr_unordered(
2673-
"\
2670+
p.cargo(
2671+
"doc -v -Zunstable-options -Z rustdoc-scrape-examples=examples -Z ignore-scrape-failures",
2672+
)
2673+
.masquerade_as_nightly_cargo()
2674+
.with_stderr_unordered(
2675+
"\
26742676
[CHECKING] foo v0.0.1 ([CWD])
26752677
[RUNNING] `rustc --crate-name foo[..]
26762678
[RUNNING] `rustdoc[..] --crate-name ex1[..]
@@ -2684,8 +2686,8 @@ error: expected one of `!` or `::`, found `NOT`
26842686
[DOCUMENTING] foo v0.0.1 ([CWD])
26852687
[RUNNING] `rustdoc[..] --crate-name foo[..]
26862688
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]",
2687-
)
2688-
.run();
2689+
)
2690+
.run();
26892691

26902692
let doc_html = p.read_file("target/doc/foo/fn.foo.html");
26912693
assert!(doc_html.contains("Examples found in repository"));
@@ -2728,7 +2730,7 @@ fn scrape_examples_no_fail_bad_dependency() {
27282730
.file("dep/src/lib.rs", "DOES NOT COMPILE")
27292731
.build();
27302732

2731-
p.cargo("doc -Zunstable-options -Z rustdoc-scrape-examples=all")
2733+
p.cargo("doc -Zunstable-options -Z rustdoc-scrape-examples=all -Z ignore-scrape-failures")
27322734
.masquerade_as_nightly_cargo()
27332735
.with_stderr_unordered(
27342736
"\

0 commit comments

Comments
 (0)