File tree Expand file tree Collapse file tree 3 files changed +34
-14
lines changed Expand file tree Collapse file tree 3 files changed +34
-14
lines changed Original file line number Diff line number Diff line change @@ -1515,7 +1515,7 @@ impl<'cfg> Workspace<'cfg> {
1515
1515
// (not documented) or proc macros (have no scrape-able exports). Additionally,
1516
1516
// naively passing a proc macro's unit_for to new_unit_dep will currently cause
1517
1517
// Cargo to panic, see issue #10545.
1518
- self . is_member ( & unit. pkg ) && !unit. target . for_host ( )
1518
+ self . is_member ( & unit. pkg ) && !( unit. target . for_host ( ) || unit . pkg . proc_macro ( ) )
1519
1519
}
1520
1520
}
1521
1521
Original file line number Diff line number Diff line change @@ -375,19 +375,15 @@ pub fn create_bcx<'a, 'cfg>(
375
375
mode : CompileMode :: Docscrape ,
376
376
..generator
377
377
} ;
378
- let all_units = scrape_generator. generate_root_units ( ) ?;
379
-
380
- let valid_units = all_units
381
- . into_iter ( )
382
- . filter ( |unit| {
383
- ws. unit_needs_doc_scrape ( unit)
384
- && !matches ! (
385
- unit. target. doc_scrape_examples( ) ,
386
- RustdocScrapeExamples :: Disabled
387
- )
388
- } )
389
- . collect :: < Vec < _ > > ( ) ;
390
- valid_units
378
+ let mut scrape_units = scrape_generator. generate_root_units ( ) ?;
379
+ scrape_units. retain ( |unit| {
380
+ ws. unit_needs_doc_scrape ( unit)
381
+ && !matches ! (
382
+ unit. target. doc_scrape_examples( ) ,
383
+ RustdocScrapeExamples :: Disabled
384
+ )
385
+ } ) ;
386
+ scrape_units
391
387
} else {
392
388
Vec :: new ( )
393
389
} ;
Original file line number Diff line number Diff line change @@ -595,3 +595,27 @@ fn only_scrape_documented_targets() {
595
595
// be scraped.
596
596
run_with_config ( "doc = false\n doc-scrape-examples = true" , true ) ;
597
597
}
598
+
599
+ #[ cargo_test( nightly, reason = "rustdoc scrape examples flags are unstable" ) ]
600
+ fn issue_11496 ( ) {
601
+ let p = project ( )
602
+ . file (
603
+ "Cargo.toml" ,
604
+ r#"
605
+ [package]
606
+ name = "repro"
607
+ version = "0.1.0"
608
+ edition = "2021"
609
+
610
+ [lib]
611
+ proc-macro = true
612
+ "# ,
613
+ )
614
+ . file ( "src/lib.rs" , "" )
615
+ . file ( "examples/ex.rs" , "fn main(){}" )
616
+ . build ( ) ;
617
+
618
+ p. cargo ( "doc -Zunstable-options -Zrustdoc-scrape-examples" )
619
+ . masquerade_as_nightly_cargo ( & [ "rustdoc-scrape-examples" ] )
620
+ . run ( ) ;
621
+ }
You can’t perform that action at this time.
0 commit comments