@@ -326,7 +326,7 @@ fn compute_deps(
326
326
if unit. target . is_lib ( ) && unit. mode != CompileMode :: Doctest {
327
327
return Ok ( ret) ;
328
328
}
329
- ret. extend ( maybe_lib ( unit, state, unit_for, None ) ?) ;
329
+ ret. extend ( maybe_lib ( unit, state, unit_for) ?) ;
330
330
331
331
// If any integration tests/benches are being run, make sure that
332
332
// binaries are built as well.
@@ -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 ( ) ) {
434
+ let lib = match dep. targets ( ) . iter ( ) . find ( |t| t. is_lib ( ) && t . documented ( ) ) {
435
435
Some ( lib) => lib,
436
436
None => continue ,
437
437
} ;
@@ -470,9 +470,26 @@ fn compute_deps_doc(
470
470
// If we document a binary/example, we need the library available.
471
471
if unit. target . is_bin ( ) || unit. target . is_example ( ) {
472
472
// build the lib
473
- ret. extend ( maybe_lib ( unit, state, unit_for, None ) ?) ;
473
+ ret. extend ( maybe_lib ( unit, state, unit_for) ?) ;
474
474
// and also the lib docs for intra-doc links
475
- ret. extend ( maybe_lib ( unit, state, unit_for, Some ( unit. mode ) ) ?) ;
475
+ if let Some ( lib) = unit
476
+ . pkg
477
+ . targets ( )
478
+ . iter ( )
479
+ . find ( |t| t. is_linkable ( ) && t. documented ( ) )
480
+ {
481
+ let dep_unit_for = unit_for. with_dependency ( unit, lib) ;
482
+ let lib_doc_unit = new_unit_dep (
483
+ state,
484
+ unit,
485
+ & unit. pkg ,
486
+ lib,
487
+ dep_unit_for,
488
+ unit. kind . for_target ( lib) ,
489
+ unit. mode ,
490
+ ) ?;
491
+ ret. push ( lib_doc_unit) ;
492
+ }
476
493
}
477
494
478
495
// Add all units being scraped for examples as a dependency of Doc units.
@@ -500,14 +517,13 @@ fn maybe_lib(
500
517
unit : & Unit ,
501
518
state : & mut State < ' _ , ' _ > ,
502
519
unit_for : UnitFor ,
503
- force_mode : Option < CompileMode > ,
504
520
) -> CargoResult < Option < UnitDep > > {
505
521
unit. pkg
506
522
. targets ( )
507
523
. iter ( )
508
524
. find ( |t| t. is_linkable ( ) )
509
525
. map ( |t| {
510
- let mode = force_mode . unwrap_or_else ( || check_or_build_mode ( unit. mode , t) ) ;
526
+ let mode = check_or_build_mode ( unit. mode , t) ;
511
527
let dep_unit_for = unit_for. with_dependency ( unit, t) ;
512
528
new_unit_dep (
513
529
state,
0 commit comments