Skip to content

Commit 825b480

Browse files
committed
doc: enhancements of mods under compiler
1 parent d221824 commit 825b480

File tree

5 files changed

+26
-2
lines changed

5 files changed

+26
-2
lines changed

src/cargo/core/compiler/compilation.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Type definitions for the result of a compilation.
2+
13
use std::collections::{BTreeSet, HashMap};
24
use std::env;
35
use std::ffi::{OsStr, OsString};

src/cargo/core/compiler/compile_kind.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Type definitions for cross-compilation.
2+
13
use crate::core::Target;
24
use crate::util::errors::CargoResult;
35
use crate::util::interning::InternedString;

src/cargo/core/compiler/timings.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ use std::io::{BufWriter, Write};
1616
use std::thread::available_parallelism;
1717
use std::time::{Duration, Instant, SystemTime};
1818

19+
/// Tracking information for the entire build.
20+
///
21+
/// Methods on this structure are generally called from the main thread of a
22+
/// running [`JobQueue`] instance (`DrainState` in specific) when the queue
23+
/// receives messages from spawned off threads.
24+
///
25+
/// [`JobQueue`]: super::JobQueue
1926
pub struct Timings<'cfg> {
2027
config: &'cfg Config,
2128
/// Whether or not timings should be captured.
@@ -253,12 +260,12 @@ impl<'cfg> Timings<'cfg> {
253260
self.concurrency.push(c);
254261
}
255262

256-
/// Mark that a fresh unit was encountered.
263+
/// Mark that a fresh unit was encountered. (No re-compile needed)
257264
pub fn add_fresh(&mut self) {
258265
self.total_fresh += 1;
259266
}
260267

261-
/// Mark that a dirty unit was encountered.
268+
/// Mark that a dirty unit was encountered. (Re-compile needed)
262269
pub fn add_dirty(&mut self) {
263270
self.total_dirty += 1;
264271
}
@@ -456,6 +463,8 @@ impl<'cfg> Timings<'cfg> {
456463
Ok(())
457464
}
458465

466+
/// Write timing data in JavaScript. Primarily for `timings.js` to put data
467+
/// in a `<script>` HTML element to draw graphs.
459468
fn write_js_data(&self, f: &mut impl Write) -> CargoResult<()> {
460469
// Create a map to link indices of unlocked units.
461470
let unit_map: HashMap<Unit, usize> = self

src/cargo/core/compiler/unit.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Types and impls for [`Unit`].
2+
13
use crate::core::compiler::unit_dependencies::IsArtifact;
24
use crate::core::compiler::{CompileKind, CompileMode, CompileTarget, CrateType};
35
use crate::core::manifest::{Target, TargetKind};
@@ -108,6 +110,9 @@ impl UnitInner {
108110
}
109111

110112
impl Unit {
113+
/// Gets the unique key for [`-Zbuild-plan`].
114+
///
115+
/// [`-Zbuild-plan`]: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#build-plan
111116
pub fn buildkey(&self) -> String {
112117
format!("{}-{}", self.pkg.name(), short_hash(self))
113118
}

src/cargo/core/compiler/unit_graph.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
//! Serialization of [`UnitGraph`] for unstable option [`--unit-graph`].
2+
//!
3+
//! [`--unit-graph`]: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#unit-graph
4+
15
use crate::core::compiler::Unit;
26
use crate::core::compiler::{CompileKind, CompileMode};
37
use crate::core::profiles::{Profile, UnitFor};
@@ -69,6 +73,8 @@ struct SerializedUnitDep {
6973
// internal detail that is mostly used for building the graph.
7074
}
7175

76+
/// Outputs a JSON serialization of [`UnitGraph`] for given `root_units`
77+
/// to the standard output.
7278
pub fn emit_serialized_unit_graph(
7379
root_units: &[Unit],
7480
unit_graph: &UnitGraph,

0 commit comments

Comments
 (0)