Skip to content

Commit c22380d

Browse files
committed
Auto merge of #7800 - ehuss:random-doc-comments, r=Eh2406
Add and update some doc comments. Just some random things that I felt could use clarification.
2 parents cb9de44 + c622bea commit c22380d

File tree

2 files changed

+30
-10
lines changed

2 files changed

+30
-10
lines changed

src/cargo/core/compiler/build_context/target_info.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,14 @@ impl TargetInfo {
196196
})
197197
}
198198

199+
/// All the target `cfg` settings.
199200
pub fn cfg(&self) -> &[Cfg] {
200201
&self.cfg
201202
}
202203

204+
/// Returns the list of file types generated by the given crate type.
205+
///
206+
/// Returns `None` if the target does not support the given crate type.
203207
pub fn file_types(
204208
&self,
205209
crate_type: &str,
@@ -310,9 +314,9 @@ impl TargetInfo {
310314
///
311315
/// The caller needs to ensure that the lines object is at the correct line for the given crate
312316
/// type: this is not checked.
313-
//
314-
// This function can not handle more than one file per type (with wasm32-unknown-emscripten, there
315-
// are two files for bin (`.wasm` and `.js`)).
317+
///
318+
/// This function can not handle more than one file per type (with wasm32-unknown-emscripten, there
319+
/// are two files for bin (`.wasm` and `.js`)).
316320
fn parse_crate_type(
317321
crate_type: &str,
318322
cmd: &ProcessBuilder,

src/cargo/core/compiler/context/compilation_files.rs

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ pub struct CompilationFiles<'a, 'cfg> {
6363
/// include dependencies).
6464
roots: Vec<Unit<'a>>,
6565
ws: &'a Workspace<'cfg>,
66+
/// Metadata hash to use for each unit.
67+
///
68+
/// `None` if the unit should not use a metadata data hash (like rustdoc,
69+
/// or some dylibs).
6670
metas: HashMap<Unit<'a>, Option<Metadata>>,
6771
/// For each Unit, a list all files produced.
6872
outputs: HashMap<Unit<'a>, LazyCell<Arc<Vec<OutputFile>>>>,
@@ -133,12 +137,15 @@ impl<'a, 'cfg: 'a> CompilationFiles<'a, 'cfg> {
133137
/// We build to the path `"{filename}-{target_metadata}"`.
134138
/// We use a linking step to link/copy to a predictable filename
135139
/// like `target/debug/libfoo.{a,so,rlib}` and such.
140+
///
141+
/// Returns `None` if the unit should not use a metadata data hash (like
142+
/// rustdoc, or some dylibs).
136143
pub fn metadata(&self, unit: &Unit<'a>) -> Option<Metadata> {
137144
self.metas[unit].clone()
138145
}
139146

140147
/// Gets the short hash based only on the `PackageId`.
141-
/// Used for the metadata when `target_metadata` returns `None`.
148+
/// Used for the metadata when `metadata` returns `None`.
142149
pub fn target_short_hash(&self, unit: &Unit<'_>) -> String {
143150
let hashable = unit.pkg.package_id().stable_hash(self.ws.root());
144151
util::short_hash(&hashable)
@@ -160,10 +167,12 @@ impl<'a, 'cfg: 'a> CompilationFiles<'a, 'cfg> {
160167
}
161168
}
162169

170+
/// Additional export directory from `--out-dir`.
163171
pub fn export_dir(&self) -> Option<PathBuf> {
164172
self.export_dir.clone()
165173
}
166174

175+
/// Directory name to use for a package in the form `NAME-HASH`.
167176
pub fn pkg_dir(&self, unit: &Unit<'a>) -> String {
168177
let name = unit.pkg.package_id().name();
169178
match self.metas[unit] {
@@ -177,6 +186,7 @@ impl<'a, 'cfg: 'a> CompilationFiles<'a, 'cfg> {
177186
self.host.dest()
178187
}
179188

189+
/// Returns the host `deps` directory path.
180190
pub fn host_deps(&self) -> &Path {
181191
self.host.deps()
182192
}
@@ -187,6 +197,7 @@ impl<'a, 'cfg: 'a> CompilationFiles<'a, 'cfg> {
187197
self.layout(unit.kind).deps()
188198
}
189199

200+
/// Directory where the fingerprint for the given unit should go.
190201
pub fn fingerprint_dir(&self, unit: &Unit<'a>) -> PathBuf {
191202
let dir = self.pkg_dir(unit);
192203
self.layout(unit.kind).fingerprint().join(dir)
@@ -241,7 +252,7 @@ impl<'a, 'cfg: 'a> CompilationFiles<'a, 'cfg> {
241252
.map(Arc::clone)
242253
}
243254

244-
/// Returns the bin stem for a given target (without metadata).
255+
/// Returns the bin filename for a given target, without extension and metadata.
245256
fn bin_stem(&self, unit: &Unit<'_>) -> String {
246257
if unit.target.allows_underscores() {
247258
unit.target.name().to_string()
@@ -250,11 +261,16 @@ impl<'a, 'cfg: 'a> CompilationFiles<'a, 'cfg> {
250261
}
251262
}
252263

253-
/// Returns a tuple with the directory and name of the hard link we expect
254-
/// our target to be copied to. Eg, file_stem may be out_dir/deps/foo-abcdef
255-
/// and link_stem would be out_dir/foo
256-
/// This function returns it in two parts so the caller can add prefix/suffix
257-
/// to filename separately.
264+
/// Returns a tuple `(hard_link_dir, filename_stem)` for the primary
265+
/// output file for the given unit.
266+
///
267+
/// `hard_link_dir` is the directory where the file should be hard-linked
268+
/// ("uplifted") to. For example, `/path/to/project/target`.
269+
///
270+
/// `filename_stem` is the base filename without an extension.
271+
///
272+
/// This function returns it in two parts so the caller can add
273+
/// prefix/suffix to filename separately.
258274
///
259275
/// Returns an `Option` because in some cases we don't want to link
260276
/// (eg a dependent lib).

0 commit comments

Comments
 (0)