// Compute dependencies for the standard library.
state.is_std = true;
for roots in std_roots.values() {
- deps_of_roots(roots, &mut state)?;
+ deps_of_roots(roots, state)?;
}
state.is_std = false;
Ok(Some(std::mem::take(&mut state.unit_dependencies)))
/// Compute all the dependencies of the given root units.
/// The result is stored in state.unit_dependencies.
-fn deps_of_roots(roots: &[Unit], mut state: &mut State<'_, '_>) -> CargoResult<()> {
+fn deps_of_roots(roots: &[Unit], state: &mut State<'_, '_>) -> CargoResult<()> {
for unit in roots.iter() {
// Dependencies of tests/benches should not have `panic` set.
// We check the global test mode to see if we are running in `cargo
} else {
UnitFor::new_normal()
};
- deps_of(unit, &mut state, unit_for)?;
+ deps_of(unit, state, unit_for)?;
}
Ok(())
if unit.target.is_lib() && unit.mode != CompileMode::Doctest {
return Ok(ret);
}
- ret.extend(maybe_lib(unit, state, unit_for)?);
+ ret.extend(maybe_lib(unit, state, unit_for, None)?);
// If any integration tests/benches are being run, make sure that
// binaries are built as well.
// If we document a binary/example, we need the library available.
if unit.target.is_bin() || unit.target.is_example() {
- ret.extend(maybe_lib(unit, state, unit_for)?);
+ // build the lib
+ ret.extend(maybe_lib(unit, state, unit_for, None)?);
+ // and also the lib docs for intra-doc links
+ ret.extend(maybe_lib(unit, state, unit_for, Some(unit.mode))?);
}
// Add all units being scraped for examples as a dependency of Doc units.
unit: &Unit,
state: &mut State<'_, '_>,
unit_for: UnitFor,
+ force_mode: Option<CompileMode>,
) -> CargoResult<Option<UnitDep>> {
unit.pkg
.targets()
.iter()
.find(|t| t.is_linkable())
.map(|t| {
- let mode = check_or_build_mode(unit.mode, t);
+ let mode = force_mode.unwrap_or_else(|| check_or_build_mode(unit.mode, t));
let dep_unit_for = unit_for.with_dependency(unit, t);
new_unit_dep(
state,