Skip to content

Commit 1c4065c

Browse files
committed
Simplify code and output of skipped_examples warning
1 parent 6b9a28e commit 1c4065c

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/cargo/ops/cargo_compile/unit_generator.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ impl<'a> UnitGenerator<'a, '_> {
459459
.map(|u| &u.pkg)
460460
.collect::<HashSet<_>>();
461461

462-
let skipped_examples: RefCell<Vec<Target>> = RefCell::new(Vec::new());
462+
let skipped_examples = RefCell::new(Vec::new());
463463
let can_scrape = |target: &Target| {
464464
match (target.doc_scrape_examples(), target.is_example()) {
465465
// Targets configured by the user to not be scraped should never be scraped
@@ -470,7 +470,9 @@ impl<'a> UnitGenerator<'a, '_> {
470470
// it's guaranteed not to break the build
471471
(RustdocScrapeExamples::Unset, true) => {
472472
if !safe_to_scrape_example_targets {
473-
skipped_examples.borrow_mut().push(target.clone());
473+
skipped_examples
474+
.borrow_mut()
475+
.push(target.name().to_string());
474476
}
475477
safe_to_scrape_example_targets
476478
}
@@ -485,11 +487,7 @@ impl<'a> UnitGenerator<'a, '_> {
485487
let skipped_examples = skipped_examples.into_inner();
486488
if !skipped_examples.is_empty() {
487489
let mut shell = self.ws.config().shell();
488-
let example_str = skipped_examples
489-
.into_iter()
490-
.map(|t| t.description_named())
491-
.collect::<Vec<_>>()
492-
.join(", ");
490+
let example_str = skipped_examples.join(", ");
493491
shell.warn(format!(
494492
"\
495493
Rustdoc did not scrape the following examples because they require dev-dependencies: {example_str}

tests/testsuite/docscrape.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ fn no_scrape_with_dev_deps() {
464464
.masquerade_as_nightly_cargo(&["rustdoc-scrape-examples"])
465465
.with_stderr(
466466
"\
467-
warning: Rustdoc did not scrape the following examples because they require dev-dependencies: example \"ex\"
467+
warning: Rustdoc did not scrape the following examples because they require dev-dependencies: ex
468468
If you want Rustdoc to scrape these examples, then add `doc-scrape-examples = true`
469469
to the [[example]] target configuration of at least one example.
470470
[DOCUMENTING] foo v0.0.1 ([CWD])

0 commit comments

Comments
 (0)