File tree 3 files changed +37
-5
lines changed
3 files changed +37
-5
lines changed Original file line number Diff line number Diff line change @@ -711,11 +711,6 @@ fn compute_deps_doc(
711
711
// Add all units being scraped for examples as a dependency of Doc units.
712
712
if state. ws . is_member ( & unit. pkg ) {
713
713
for scrape_unit in state. scrape_units . iter ( ) {
714
- // This needs to match the FeaturesFor used in cargo_compile::generate_targets.
715
- let unit_for = UnitFor :: new_host (
716
- scrape_unit. target . proc_macro ( ) ,
717
- unit_for. root_compile_kind ( ) ,
718
- ) ;
719
714
deps_of ( scrape_unit, state, unit_for) ?;
720
715
ret. push ( new_unit_dep (
721
716
state,
Original file line number Diff line number Diff line change @@ -546,6 +546,10 @@ pub fn create_bcx<'a, 'cfg>(
546
546
& profiles,
547
547
interner,
548
548
) ?
549
+ . into_iter ( )
550
+ // Proc macros should not be scraped for functions, since they only export macros
551
+ . filter ( |unit| !unit. target . proc_macro ( ) )
552
+ . collect :: < Vec < _ > > ( )
549
553
}
550
554
None => Vec :: new ( ) ,
551
555
} ;
Original file line number Diff line number Diff line change @@ -2560,6 +2560,39 @@ fn scrape_examples_missing_flag() {
2560
2560
. run ( ) ;
2561
2561
}
2562
2562
2563
+ #[ cargo_test]
2564
+ fn scrape_examples_configure_profile ( ) {
2565
+ if !is_nightly ( ) {
2566
+ // -Z rustdoc-scrape-examples is unstable
2567
+ return ;
2568
+ }
2569
+
2570
+ let p = project ( )
2571
+ . file (
2572
+ "Cargo.toml" ,
2573
+ r#"
2574
+ [package]
2575
+ name = "foo"
2576
+ version = "0.0.1"
2577
+ authors = []
2578
+
2579
+ [profile.dev]
2580
+ panic = "abort"
2581
+ "# ,
2582
+ )
2583
+ . file ( "examples/ex.rs" , "fn main() { foo::foo(); }" )
2584
+ . file ( "src/lib.rs" , "pub fn foo() {}\n pub fn bar() { foo(); }" )
2585
+ . build ( ) ;
2586
+
2587
+ p. cargo ( "doc -Zunstable-options -Z rustdoc-scrape-examples=all" )
2588
+ . masquerade_as_nightly_cargo ( )
2589
+ . run ( ) ;
2590
+
2591
+ let doc_html = p. read_file ( "target/doc/foo/fn.foo.html" ) ;
2592
+ assert ! ( doc_html. contains( "Examples found in repository" ) ) ;
2593
+ assert ! ( doc_html. contains( "More examples" ) ) ;
2594
+ }
2595
+
2563
2596
#[ cargo_test]
2564
2597
fn lib_before_bin ( ) {
2565
2598
// Checks that the library is documented before the binary.
You can’t perform that action at this time.
0 commit comments