fn mark_required(
    root_pkg: &Package,
    ws: &Workspace,
    rpkgs_by_id: &mut BTreeMap<PackageId, ResolvedPackage>,
) -> Result<()> {
    let spec = PackageIdSpec::from_package_id(root_pkg.package_id());
    let rtd = RustcTargetData::new(&ws, &[CompileKind::Host])?;
    let resolve = resolve_ws_with_opts(
        ws,
        &rtd,
        &[CompileKind::Host],
        &CliFeatures::new_all(true),
        &[spec],
        HasDevUnits::Yes,
        ForceAllTargets::Yes,
    )?;

    let root_pkg_name = root_pkg.name().as_str();
    // Dependencies that are activated, even when no features are activated, must be required.
    for id in resolve.targeted_resolve.iter() {
        let rpkg = rpkgs_by_id.get_mut(&id).unwrap();
        for feature in resolve.targeted_resolve.features(id).iter() {
            rpkg.features
                .get_mut(feature.as_str())
                .unwrap()
                .required_by(root_pkg_name);
        }

        for (dep_id, _) in resolve.targeted_resolve.deps(id) {
            for dep in rpkg.iter_deps_with_id_mut(dep_id) {
                dep.optionality.required_by(root_pkg_name);
            }
        }
    }

    Ok(())
}
/// Traverses the whole dependency graph starting at `pkg` and marks required packages and features.
Traverses the whole dependency graph starting at `pkg` and marks required packages and features.
Traverses the whole dependency graph starting at ` pkg ` and marks required packages and features .
fn mark_required(
    root_pkg: &Package,
    ws: &Workspace,
    rpkgs_by_id: &mut BTreeMap<PackageId, ResolvedPackage>,
) -> Result<()> {
    let spec = PackageIdSpec::from_package_id(root_pkg.package_id());
    let rtd = RustcTargetData::new(&ws, &[CompileKind::Host])?;
    let resolve = resolve_ws_with_opts(
        ws,
        &rtd,
        &[CompileKind::Host],
        &CliFeatures::new_all(true),
        &[spec],
        HasDevUnits::Yes,
        ForceAllTargets::Yes,
    )?;
    let root_pkg_name = root_pkg.name().as_str();
    // Dependencies that are activated, even when no features are activated, must be required.
    for id in resolve.targeted_resolve.iter() {
        let rpkg = rpkgs_by_id.get_mut(&id).unwrap();
        for feature in resolve.targeted_resolve.features(id).iter() {
            rpkg.features
                .get_mut(feature.as_str())
                .unwrap()
                .required_by(root_pkg_name);
        }
        for (dep_id, _) in resolve.targeted_resolve.deps(id) {
            for dep in rpkg.iter_deps_with_id_mut(dep_id) {
                dep.optionality.required_by(root_pkg_name);
            }
        }
    }
    Ok(())
}
fn mark_required ( root_pkg : & Package , ws : & Workspace , rpkgs_by_id : & mut BTreeMap < PackageId , ResolvedPackage > , ) -> Result < ( ) > { let spec = PackageIdSpec :: from_package_id ( root_pkg . package_id ( ) ) ; let rtd = RustcTargetData :: new ( & ws , & [ CompileKind :: Host ] ) ? ; let resolve = resolve_ws_with_opts ( ws , & rtd , & [ CompileKind :: Host ] , & CliFeatures :: new_all ( true ) , & [ spec ] , HasDevUnits :: Yes , ForceAllTargets :: Yes , ) ? ; let root_pkg_name = root_pkg . name ( ) . as_str ( ) ; // Dependencies that are activated, even when no features are activated, must be required. for id in resolve . targeted_resolve . iter ( ) { let rpkg = rpkgs_by_id . get_mut ( & id ) . unwrap ( ) ; for feature in resolve . targeted_resolve . features ( id ) . iter ( ) { rpkg . features . get_mut ( feature . as_str ( ) ) . unwrap ( ) . required_by ( root_pkg_name ) ; } for ( dep_id , _ ) in resolve . targeted_resolve . deps ( id ) { for dep in rpkg . iter_deps_with_id_mut ( dep_id ) { dep . optionality . required_by ( root_pkg_name ) ; } } } Ok ( ( ) ) }
Traverses the whole dependency graph starting at `pkg` and marks required packages and features.
Traverses the whole dependency graph starting at ` pkg ` and marks required packages and features .
root_pkg
&Package
ws
&Workspace
rpkgs_by_id
&mut BTreeMap<PackageId, ResolvedPackage>