File tree 2 files changed +61
-14
lines changed
2 files changed +61
-14
lines changed Original file line number Diff line number Diff line change @@ -431,7 +431,7 @@ fn compute_deps_doc(
431
431
let mut ret = Vec :: new ( ) ;
432
432
for ( id, _deps) in deps {
433
433
let dep = state. get ( id) ;
434
- let lib = match dep. targets ( ) . iter ( ) . find ( |t| t. is_lib ( ) && t . documented ( ) ) {
434
+ let lib = match dep. targets ( ) . iter ( ) . find ( |t| t. is_lib ( ) ) {
435
435
Some ( lib) => lib,
436
436
None => continue ,
437
437
} ;
@@ -449,18 +449,20 @@ fn compute_deps_doc(
449
449
mode,
450
450
) ?;
451
451
ret. push ( lib_unit_dep) ;
452
- if let CompileMode :: Doc { deps : true } = unit. mode {
453
- // Document this lib as well.
454
- let doc_unit_dep = new_unit_dep (
455
- state,
456
- unit,
457
- dep,
458
- lib,
459
- dep_unit_for,
460
- unit. kind . for_target ( lib) ,
461
- unit. mode ,
462
- ) ?;
463
- ret. push ( doc_unit_dep) ;
452
+ if lib. documented ( ) {
453
+ if let CompileMode :: Doc { deps : true } = unit. mode {
454
+ // Document this lib as well.
455
+ let doc_unit_dep = new_unit_dep (
456
+ state,
457
+ unit,
458
+ dep,
459
+ lib,
460
+ dep_unit_for,
461
+ unit. kind . for_target ( lib) ,
462
+ unit. mode ,
463
+ ) ?;
464
+ ret. push ( doc_unit_dep) ;
465
+ }
464
466
}
465
467
}
466
468
Original file line number Diff line number Diff line change @@ -2557,7 +2557,7 @@ fn doc_lib_false() {
2557
2557
bar = {path = "bar"}
2558
2558
"# ,
2559
2559
)
2560
- . file ( "src/lib.rs" , "" )
2560
+ . file ( "src/lib.rs" , "extern crate bar; " )
2561
2561
. file ( "src/bin/some-bin.rs" , "fn main() {}" )
2562
2562
. file (
2563
2563
"bar/Cargo.toml" ,
@@ -2588,3 +2588,48 @@ fn doc_lib_false() {
2588
2588
assert ! ( !p. build_dir( ) . join( "doc/bar" ) . exists( ) ) ;
2589
2589
assert ! ( p. build_dir( ) . join( "doc/some_bin" ) . exists( ) ) ;
2590
2590
}
2591
+
2592
+ #[ cargo_test]
2593
+ fn doc_lib_false_dep ( ) {
2594
+ // doc = false for a dependency
2595
+ // Ensures that the rmeta gets produced
2596
+ let p = project ( )
2597
+ . file (
2598
+ "Cargo.toml" ,
2599
+ r#"
2600
+ [package]
2601
+ name = "foo"
2602
+ version = "0.1.0"
2603
+
2604
+ [dependencies]
2605
+ bar = { path = "bar" }
2606
+ "# ,
2607
+ )
2608
+ . file ( "src/lib.rs" , "extern crate bar;" )
2609
+ . file (
2610
+ "bar/Cargo.toml" ,
2611
+ r#"
2612
+ [package]
2613
+ name = "bar"
2614
+ version = "0.1.0"
2615
+
2616
+ [lib]
2617
+ doc = false
2618
+ "# ,
2619
+ )
2620
+ . file ( "bar/src/lib.rs" , "" )
2621
+ . build ( ) ;
2622
+
2623
+ p. cargo ( "doc" )
2624
+ . with_stderr (
2625
+ "\
2626
+ [CHECKING] bar v0.1.0 [..]
2627
+ [DOCUMENTING] foo v0.1.0 [..]
2628
+ [FINISHED] [..]
2629
+ " ,
2630
+ )
2631
+ . run ( ) ;
2632
+
2633
+ assert ! ( p. build_dir( ) . join( "doc/foo" ) . exists( ) ) ;
2634
+ assert ! ( !p. build_dir( ) . join( "doc/bar" ) . exists( ) ) ;
2635
+ }
You can’t perform that action at this time.
0 commit comments