@@ -326,7 +326,7 @@ fn compute_deps(
326326 if unit. target . is_lib ( ) && unit. mode != CompileMode :: Doctest {
327327 return Ok ( ret) ;
328328 }
329- ret. extend ( maybe_lib ( unit, state, unit_for, None ) ?) ;
329+ ret. extend ( maybe_lib ( unit, state, unit_for) ?) ;
330330
331331 // If any integration tests/benches are being run, make sure that
332332 // binaries are built as well.
@@ -431,7 +431,7 @@ fn compute_deps_doc(
431431 let mut ret = Vec :: new ( ) ;
432432 for ( id, _deps) in deps {
433433 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 ( ) ) {
435435 Some ( lib) => lib,
436436 None => continue ,
437437 } ;
@@ -470,9 +470,26 @@ fn compute_deps_doc(
470470 // If we document a binary/example, we need the library available.
471471 if unit. target . is_bin ( ) || unit. target . is_example ( ) {
472472 // build the lib
473- ret. extend ( maybe_lib ( unit, state, unit_for, None ) ?) ;
473+ ret. extend ( maybe_lib ( unit, state, unit_for) ?) ;
474474 // 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+ }
476493 }
477494
478495 // Add all units being scraped for examples as a dependency of Doc units.
@@ -500,14 +517,13 @@ fn maybe_lib(
500517 unit : & Unit ,
501518 state : & mut State < ' _ , ' _ > ,
502519 unit_for : UnitFor ,
503- force_mode : Option < CompileMode > ,
504520) -> CargoResult < Option < UnitDep > > {
505521 unit. pkg
506522 . targets ( )
507523 . iter ( )
508524 . find ( |t| t. is_linkable ( ) )
509525 . 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) ;
511527 let dep_unit_for = unit_for. with_dependency ( unit, t) ;
512528 new_unit_dep (
513529 state,
0 commit comments