Skip to content

Commit 92007a5

Browse files
committed
doc(unit_dependencies): polish
1 parent e691e18 commit 92007a5

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/cargo/core/compiler/unit_dependencies.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
//! Constructs the dependency graph for compilation.
1+
//! # Constructs the dependency graph for compilation
22
//!
33
//! Rust code is typically organized as a set of Cargo packages. The
44
//! dependencies between the packages themselves are stored in the
5-
//! `Resolve` struct. However, we can't use that information as is for
5+
//! [`Resolve`] struct. However, we can't use that information as is for
66
//! compilation! A package typically contains several targets, or crates,
77
//! and these targets has inter-dependencies. For example, you need to
88
//! compile the `lib` target before the `bin` one, and you need to compile
@@ -13,7 +13,7 @@
1313
//! is exactly what this module is doing! Well, almost exactly: another
1414
//! complication is that we might want to compile the same target several times
1515
//! (for example, with and without tests), so we actually build a dependency
16-
//! graph of `Unit`s, which capture these properties.
16+
//! graph of [`Unit`]s, which capture these properties.
1717
1818
use std::collections::{HashMap, HashSet};
1919

@@ -35,23 +35,27 @@ use crate::CargoResult;
3535

3636
const IS_NO_ARTIFACT_DEP: Option<&'static Artifact> = None;
3737

38-
/// Collection of stuff used while creating the `UnitGraph`.
38+
/// Collection of stuff used while creating the [`UnitGraph`].
3939
struct State<'a, 'cfg> {
4040
ws: &'a Workspace<'cfg>,
4141
config: &'cfg Config,
42+
/// Stores the result of building the [`UnitGraph`].
4243
unit_dependencies: UnitGraph,
4344
package_set: &'a PackageSet<'cfg>,
4445
usr_resolve: &'a Resolve,
4546
usr_features: &'a ResolvedFeatures,
47+
/// Like `usr_resolve` but for building standard library (`-Zbuild-std`).
4648
std_resolve: Option<&'a Resolve>,
49+
/// Like `usr_features` but for building standard library (`-Zbuild-std`).
4750
std_features: Option<&'a ResolvedFeatures>,
48-
/// This flag is `true` while generating the dependencies for the standard
49-
/// library.
51+
/// `true` while generating the dependencies for the standard library.
5052
is_std: bool,
53+
/// The mode we are compiling in. Used for preventing from building lib thrice.
5154
global_mode: CompileMode,
5255
target_data: &'a RustcTargetData<'cfg>,
5356
profiles: &'a Profiles,
5457
interner: &'a UnitInterner,
58+
// Units for `-Zrustdoc-scrape-examples`.
5559
scrape_units: &'a [Unit],
5660

5761
/// A set of edges in `unit_dependencies` where (a, b) means that the
@@ -73,6 +77,9 @@ impl IsArtifact {
7377
}
7478
}
7579

80+
/// Then entry point for building a dependency graph of compilation units.
81+
///
82+
/// You can find some information for arguments from doc of [`State`].
7683
pub fn build_unit_dependencies<'a, 'cfg>(
7784
ws: &'a Workspace<'cfg>,
7885
package_set: &'a PackageSet<'cfg>,
@@ -1015,6 +1022,7 @@ fn connect_run_custom_build_deps(state: &mut State<'_, '_>) {
10151022
}
10161023

10171024
impl<'a, 'cfg> State<'a, 'cfg> {
1025+
/// Gets `std_resolve` during building std, otherwise `usr_resolve`.
10181026
fn resolve(&self) -> &'a Resolve {
10191027
if self.is_std {
10201028
self.std_resolve.unwrap()
@@ -1023,6 +1031,7 @@ impl<'a, 'cfg> State<'a, 'cfg> {
10231031
}
10241032
}
10251033

1034+
/// Gets `std_features` during building std, otherwise `usr_features`.
10261035
fn features(&self) -> &'a ResolvedFeatures {
10271036
if self.is_std {
10281037
self.std_features.unwrap()

0 commit comments

Comments
 (0)