Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give a hard error if -Zrustdoc-scrape-examples is missing a flag #10043

Merged
merged 1 commit into from
Nov 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/cargo/core/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,15 @@ impl CliUnstable {
"namespaced-features" => self.namespaced_features = parse_empty(k, v)?,
"weak-dep-features" => self.weak_dep_features = parse_empty(k, v)?,
"credential-process" => self.credential_process = parse_empty(k, v)?,
"rustdoc-scrape-examples" => self.rustdoc_scrape_examples = v.map(|s| s.to_string()),
"rustdoc-scrape-examples" => {
if let Some(s) = v {
self.rustdoc_scrape_examples = Some(s.to_string())
} else {
bail!(
r#"-Z rustdoc-scrape-examples must take "all" or "examples" as an argument"#
)
}
}
"skip-rustdoc-fingerprint" => self.skip_rustdoc_fingerprint = parse_empty(k, v)?,
"compile-progress" => stabilized_warn(k, "1.30", STABILIZED_COMPILE_PROGRESS),
"offline" => stabilized_err(k, "1.36", STABILIZED_OFFLINE)?,
Expand Down
25 changes: 25 additions & 0 deletions tests/testsuite/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2326,3 +2326,28 @@ fn scrape_examples_crate_with_dash() {
let doc_html = p.read_file("target/doc/da_sh/fn.foo.html");
assert!(doc_html.contains("Examples found in repository"));
}

#[cargo_test]
fn scrape_examples_missing_flag() {
if !is_nightly() {
return;
}

let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "1.2.4"
authors = []
"#,
)
.file("src/lib.rs", "//! These are the docs!")
.build();
p.cargo("doc -Zrustdoc-scrape-examples")
.masquerade_as_nightly_cargo()
.with_status(101)
.with_stderr("error: -Z rustdoc-scrape-examples must take [..] an argument")
.run();
}