Skip to content

Commit

Permalink
Add check to not doc-scrape proc-macro units. Fixes #10571.
Browse files Browse the repository at this point in the history
  • Loading branch information
willcrichton committed Nov 25, 2022
1 parent 79fe757 commit 178f8bf
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/cargo/ops/cargo_compile/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,13 +394,16 @@ pub fn create_bcx<'a, 'cfg>(
}
}

// We further eliminate units for scraping if they are explicitly marked to not be scraped,
// or if they aren't eligible for scraping (see [`Workspace::unit_needs_doc_scrape`]).
let valid_units = all_units
.into_iter()
.filter(|unit| {
!matches!(
unit.target.doc_scrape_examples(),
RustdocScrapeExamples::Disabled
)
ws.unit_needs_doc_scrape(unit)
&& !matches!(
unit.target.doc_scrape_examples(),
RustdocScrapeExamples::Disabled
)
})
.collect::<Vec<_>>();
valid_units
Expand Down
30 changes: 30 additions & 0 deletions tests/testsuite/docscrape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,36 @@ fn issue_10545() {
.run();
}

#[cargo_test(nightly, reason = "rustdoc scrape examples flags are unstable")]
fn no_scrape_proc_macros_issue_10571() {
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.0.1"
authors = []
[lib]
proc-macro = true
"#,
)
.file("src/lib.rs", "")
.build();

// proc-macro library should not be scraped
p.cargo("doc -Zunstable-options -Zrustdoc-scrape-examples")
.masquerade_as_nightly_cargo(&["rustdoc-scrape-examples"])
.with_stderr(
"\
[DOCUMENTING] foo v0.0.1 ([CWD])
[FINISHED] [..]
",
)
.run();
}

#[cargo_test(nightly, reason = "rustdoc scrape examples flags are unstable")]
fn cache() {
let p = project()
Expand Down

0 comments on commit 178f8bf

Please sign in to comment.