File tree 2 files changed +42
-11
lines changed
src/cargo/ops/cargo_compile
2 files changed +42
-11
lines changed Original file line number Diff line number Diff line change @@ -370,7 +370,7 @@ pub fn create_bcx<'a, 'cfg>(
370
370
let should_scrape = build_config. mode . is_doc ( ) && config. cli_unstable ( ) . rustdoc_scrape_examples ;
371
371
let mut scrape_units = if should_scrape {
372
372
let scrape_filter = filter. refine_for_docscrape ( & to_builds, has_dev_units) ;
373
- let all_units = generate_targets (
373
+ let mut all_units = generate_targets (
374
374
ws,
375
375
& to_builds,
376
376
& scrape_filter,
@@ -394,16 +394,17 @@ pub fn create_bcx<'a, 'cfg>(
394
394
}
395
395
}
396
396
397
- let valid_units = all_units
398
- . into_iter ( )
399
- . filter ( |unit| {
400
- !matches ! (
401
- unit. target. doc_scrape_examples( ) ,
402
- RustdocScrapeExamples :: Disabled
403
- )
404
- } )
405
- . collect :: < Vec < _ > > ( ) ;
406
- valid_units
397
+ // We further eliminate units for scraping if they are explicitly marked to not be scraped,
398
+ // or if they aren't eligible for scraping (see [`Workspace::unit_needs_doc_scrape`]).
399
+ all_units. retain ( |unit| {
400
+ let not_marked_unscrapable = !matches ! (
401
+ unit. target. doc_scrape_examples( ) ,
402
+ RustdocScrapeExamples :: Disabled
403
+ ) ;
404
+ not_marked_unscrapable && ws. unit_needs_doc_scrape ( unit)
405
+ } ) ;
406
+
407
+ all_units
407
408
} else {
408
409
Vec :: new ( )
409
410
} ;
Original file line number Diff line number Diff line change @@ -281,6 +281,36 @@ fn issue_10545() {
281
281
. run ( ) ;
282
282
}
283
283
284
+ #[ cargo_test( nightly, reason = "rustdoc scrape examples flags are unstable" ) ]
285
+ fn no_scrape_proc_macros_issue_10571 ( ) {
286
+ let p = project ( )
287
+ . file (
288
+ "Cargo.toml" ,
289
+ r#"
290
+ [package]
291
+ name = "foo"
292
+ version = "0.0.1"
293
+ authors = []
294
+
295
+ [lib]
296
+ proc-macro = true
297
+ "# ,
298
+ )
299
+ . file ( "src/lib.rs" , "" )
300
+ . build ( ) ;
301
+
302
+ // proc-macro library should not be scraped
303
+ p. cargo ( "doc -Zunstable-options -Zrustdoc-scrape-examples" )
304
+ . masquerade_as_nightly_cargo ( & [ "rustdoc-scrape-examples" ] )
305
+ . with_stderr (
306
+ "\
307
+ [DOCUMENTING] foo v0.0.1 ([CWD])
308
+ [FINISHED] [..]
309
+ " ,
310
+ )
311
+ . run ( ) ;
312
+ }
313
+
284
314
#[ cargo_test( nightly, reason = "rustdoc scrape examples flags are unstable" ) ]
285
315
fn cache ( ) {
286
316
let p = project ( )
You can’t perform that action at this time.
0 commit comments