File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1515,7 +1515,7 @@ impl<'cfg> Workspace<'cfg> {
15151515 // (not documented) or proc macros (have no scrape-able exports). Additionally,
15161516 // naively passing a proc macro's unit_for to new_unit_dep will currently cause
15171517 // 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 ( ) )
15191519 }
15201520}
15211521
Original file line number Diff line number Diff line change @@ -375,19 +375,15 @@ pub fn create_bcx<'a, 'cfg>(
375375 mode : CompileMode :: Docscrape ,
376376 ..generator
377377 } ;
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
391387 } else {
392388 Vec :: new ( )
393389 } ;
Original file line number Diff line number Diff line change @@ -595,3 +595,27 @@ fn only_scrape_documented_targets() {
595595 // be scraped.
596596 run_with_config ( "doc = false\n doc-scrape-examples = true" , true ) ;
597597}
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