Skip to content

Commit a8f7db2

Browse files
authored
docs: Clean up doc comments (#14823)
### What does this PR try to resolve? I'm experimenting with API changes in Cargo and wanted to make it easier to find doc comments that need updating. I didn't see a lint to help with this but I did go ahead and apply the result of other documentation lints. ### How should we test and review this PR? I've not turned these lints on more generally - `clippy::doc_markdown` has some false positives we'd need to record in our config (`SemVer` and `SQLite`) - `clippy::too_long_first_doc_paragraph` pointed out a doc comment that, at a quick glance, I didn't see what summary to provide I also didn't wanted to get this in without making a policy decision of what lints are enabled. ### Additional information
2 parents c54a8e8 + e306556 commit a8f7db2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+162
-145
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

benches/benchsuite/src/bin/capture-last-use.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Utility for capturing a global cache last-use database based on the files
22
//! on a real-world system.
33
//!
4-
//! This will look in the CARGO_HOME of the current system and record last-use
4+
//! This will look in the `CARGO_HOME` of the current system and record last-use
55
//! data for all files in the cache. This is intended to provide a real-world
66
//! example for a benchmark that should be close to what a real set of data
77
//! should look like.

crates/cargo-test-support/src/compare.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ macro_rules! impl_from_tuple_for_inmemorydir {
621621
};
622622
}
623623

624-
/// Extend `impl_from_tuple_for_inmemorydir`` to generate for the specified tuple and all smaller
624+
/// Extend `impl_from_tuple_for_inmemorydir` to generate for the specified tuple and all smaller
625625
/// tuples
626626
macro_rules! impl_from_tuples_for_inmemorydir {
627627
($var1:ident $path1:ident $data1:ident, $($var:ident $path:ident $data:ident),+) => {

crates/cargo-test-support/src/containers.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//! with the running container.
66
//!
77
//! Tests using containers must use `#[cargo_test(container_test)]` to disable
8-
//! them unless the CARGO_CONTAINER_TESTS environment variable is set.
8+
//! them unless the `CARGO_CONTAINER_TESTS` environment variable is set.
99
1010
use cargo_util::ProcessBuilder;
1111
use std::collections::HashMap;
@@ -36,7 +36,7 @@ pub struct ContainerHandle {
3636
/// This can only be used on Linux. macOS and Windows docker doesn't allow
3737
/// direct connection to the container.
3838
pub ip_address: String,
39-
/// Port mappings of container_port to host_port for ports exposed via EXPOSE.
39+
/// Port mappings of `container_port` to `host_port` for ports exposed via EXPOSE.
4040
pub port_mappings: HashMap<u16, u16>,
4141
}
4242

crates/cargo-test-support/src/cross_compile.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//! Note that cross-testing is very limited. You need to install the
44
//! "alternate" target to the host (32-bit for 64-bit hosts or vice-versa).
55
//!
6-
//! Set CFG_DISABLE_CROSS_TESTS=1 environment variable to disable these tests
6+
//! Set `CFG_DISABLE_CROSS_TESTS=1` environment variable to disable these tests
77
//! if you are unable to use the alternate target. Unfortunately 32-bit
88
//! support on macOS is going away, so macOS users are out of luck.
99
//!

crates/cargo-test-support/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,7 @@ impl Execs {
890890
///
891891
/// Prefer [`Execs::with_stdout_data`] where possible.
892892
/// - `with` cannot be snapshotted
893-
/// - The absence of `without`` can either mean success or that the string being looked for
893+
/// - The absence of `without` can either mean success or that the string being looked for
894894
/// changed.
895895
///
896896
/// </div>
@@ -1565,9 +1565,10 @@ pub fn is_coarse_mtime() -> bool {
15651565
cfg!(target_os = "macos") && is_ci()
15661566
}
15671567

1568+
/// A way for to increase the cut off for all the time based test.
1569+
///
15681570
/// Some CI setups are much slower then the equipment used by Cargo itself.
15691571
/// Architectures that do not have a modern processor, hardware emulation, etc.
1570-
/// This provides a way for those setups to increase the cut off for all the time based test.
15711572
pub fn slow_cpu_multiplier(main: u64) -> Duration {
15721573
static SLOW_CPU_MULTIPLIER: OnceLock<u64> = OnceLock::new();
15731574
let slow_cpu_multiplier = SLOW_CPU_MULTIPLIER.get_or_init(|| {

crates/cargo-test-support/src/paths.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ static CARGO_INTEGRATION_TEST_DIR: &str = "cit";
1717
static GLOBAL_ROOT: OnceLock<Mutex<Option<PathBuf>>> = OnceLock::new();
1818

1919
/// This is used when running cargo is pre-CARGO_TARGET_TMPDIR
20-
/// TODO: Remove when CARGO_TARGET_TMPDIR grows old enough.
20+
/// TODO: Remove when `CARGO_TARGET_TMPDIR` grows old enough.
2121
fn global_root_legacy() -> PathBuf {
2222
let mut path = t!(env::current_exe());
2323
path.pop(); // chop off exe name

crates/cargo-test-support/src/publish.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ fn read_new_post(new_path: &Path) -> (Vec<u8>, Vec<u8>) {
166166
///
167167
/// - `expected_crate_name` should be something like `foo-0.0.1.crate`.
168168
/// - `expected_files` should be a complete list of files in the crate
169-
/// (relative to expected_crate_name).
169+
/// (relative to `expected_crate_name`).
170170
/// - `expected_contents` should be a list of `(file_name, contents)` tuples
171171
/// to validate the contents of the given file. Only the listed files will
172172
/// be checked (others will be ignored).

crates/cargo-util-schemas/src/manifest/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1680,7 +1680,7 @@ impl<'de> de::Deserialize<'de> for InvalidCargoFeatures {
16801680
}
16811681
}
16821682

1683-
/// A StringOrVec can be parsed from either a TOML string or array,
1683+
/// This can be parsed from either a TOML string or array,
16841684
/// but is always stored as a vector.
16851685
#[derive(Clone, Debug, Serialize, Eq, PartialEq, PartialOrd, Ord)]
16861686
#[cfg_attr(feature = "unstable-schema", derive(schemars::JsonSchema))]

crates/cargo-util/src/paths.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ pub fn write<P: AsRef<Path>, C: AsRef<[u8]>>(path: P, contents: C) -> Result<()>
189189

190190
/// Writes a file to disk atomically.
191191
///
192-
/// write_atomic uses tempfile::persist to accomplish atomic writes.
192+
/// This uses `tempfile::persist` to accomplish atomic writes.
193193
pub fn write_atomic<P: AsRef<Path>, C: AsRef<[u8]>>(path: P, contents: C) -> Result<()> {
194194
let path = path.as_ref();
195195

crates/home/src/env.rs

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ use std::{
1010
/// in-process unit testing by rustup.
1111
pub trait Env {
1212
/// Return the path to the users home dir, or None if any error occurs:
13-
/// see home_inner.
13+
/// see `home_inner`.
1414
fn home_dir(&self) -> Option<PathBuf>;
1515
/// Return the current working directory.
1616
fn current_dir(&self) -> io::Result<PathBuf>;
17-
/// Get an environment variable, as per std::env::var_os.
17+
/// Get an environment variable, as per `std::env::var_os`.
1818
fn var_os(&self, key: &str) -> Option<OsString>;
1919
}
2020

@@ -47,7 +47,9 @@ pub fn home_dir_with_env(env: &dyn Env) -> Option<PathBuf> {
4747
env.home_dir()
4848
}
4949

50-
/// Variant of cargo_home where the environment source is parameterized. This is
50+
/// Variant of `cargo_home` where the environment source is parameterized.
51+
///
52+
/// This is
5153
/// specifically to support in-process testing scenarios as environment
5254
/// variables and user home metadata are normally process global state. See the
5355
/// [`Env`] trait.
@@ -56,10 +58,12 @@ pub fn cargo_home_with_env(env: &dyn Env) -> io::Result<PathBuf> {
5658
cargo_home_with_cwd_env(env, &cwd)
5759
}
5860

59-
/// Variant of cargo_home_with_cwd where the environment source is
60-
/// parameterized. This is specifically to support in-process testing scenarios
61+
/// Variant of `cargo_home_with_cwd` where the environment source is
62+
/// parameterized.
63+
///
64+
/// This is specifically to support in-process testing scenarios
6165
/// as environment variables and user home metadata are normally process global
62-
/// state. See the OsEnv trait.
66+
/// state. See the `OsEnv` trait.
6367
pub fn cargo_home_with_cwd_env(env: &dyn Env, cwd: &Path) -> io::Result<PathBuf> {
6468
match env.var_os("CARGO_HOME").filter(|h| !h.is_empty()) {
6569
Some(home) => {
@@ -76,19 +80,23 @@ pub fn cargo_home_with_cwd_env(env: &dyn Env, cwd: &Path) -> io::Result<PathBuf>
7680
}
7781
}
7882

79-
/// Variant of cargo_home_with_cwd where the environment source is
80-
/// parameterized. This is specifically to support in-process testing scenarios
83+
/// Variant of `cargo_home_with_cwd` where the environment source is
84+
/// parameterized.
85+
///
86+
/// This is specifically to support in-process testing scenarios
8187
/// as environment variables and user home metadata are normally process global
82-
/// state. See the OsEnv trait.
88+
/// state. See the `OsEnv` trait.
8389
pub fn rustup_home_with_env(env: &dyn Env) -> io::Result<PathBuf> {
8490
let cwd = env.current_dir()?;
8591
rustup_home_with_cwd_env(env, &cwd)
8692
}
8793

88-
/// Variant of cargo_home_with_cwd where the environment source is
89-
/// parameterized. This is specifically to support in-process testing scenarios
94+
/// Variant of `cargo_home_with_cwd` where the environment source is
95+
/// parameterized.
96+
///
97+
/// This is specifically to support in-process testing scenarios
9098
/// as environment variables and user home metadata are normally process global
91-
/// state. See the OsEnv trait.
99+
/// state. See the `OsEnv` trait.
92100
pub fn rustup_home_with_cwd_env(env: &dyn Env, cwd: &Path) -> io::Result<PathBuf> {
93101
match env.var_os("RUSTUP_HOME").filter(|h| !h.is_empty()) {
94102
Some(home) => {

crates/mdman/src/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub fn parse_name_and_section(text: &str) -> Result<(&str, u8), Error> {
2424
Ok((name, section))
2525
}
2626

27-
/// Extracts the text from a header after Tag::Heading has been received.
27+
/// Extracts the text from a header after `Tag::Heading` has been received.
2828
pub fn header_text<'e>(parser: &mut EventIter<'e>) -> Result<CowStr<'e>, Error> {
2929
let text = match parser.next() {
3030
Some((Event::Text(t), _range)) => t,

crates/resolver-tests/src/sat.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ fn log_bits(x: usize) -> usize {
2020
(num_bits::<usize>() as u32 - x.leading_zeros()) as usize
2121
}
2222

23-
// At this point is possible to select every version of every package.
24-
// So we need to mark certain versions as incompatible with each other.
25-
// We could add a clause not A, not B for all A and B that are incompatible,
23+
/// At this point is possible to select every version of every package.
24+
///
25+
/// So we need to mark certain versions as incompatible with each other.
26+
/// We could add a clause not A, not B for all A and B that are incompatible,
2627
fn sat_at_most_one(solver: &mut varisat::Solver<'_>, vars: &[varisat::Var]) {
2728
if vars.len() <= 1 {
2829
return;
@@ -327,7 +328,9 @@ fn process_compatible_dep_summaries(
327328
}
328329
}
329330

330-
/// Resolution can be reduced to the SAT problem. So this is an alternative implementation
331+
/// Resolution can be reduced to the SAT problem.
332+
///
333+
/// So this is an alternative implementation
331334
/// of the resolver that uses a SAT library for the hard work. This is intended to be easy to read,
332335
/// as compared to the real resolver.
333336
///

crates/rustfix/src/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub struct DiagnosticSpan {
3636
/// Is this a "primary" span -- meaning the point, or one of the points,
3737
/// where the error occurred?
3838
pub is_primary: bool,
39-
/// Source text from the start of line_start to the end of line_end.
39+
/// Source text from the start of `line_start` to the end of `line_end`.
4040
pub text: Vec<DiagnosticSpanLine>,
4141
/// Label that should be placed at this location (if any)
4242
label: Option<String>,

credential/cargo-credential/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cargo-credential"
3-
version = "0.4.7"
3+
version = "0.4.8"
44
rust-version.workspace = true
55
edition.workspace = true
66
license.workspace = true

credential/cargo-credential/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,9 @@ pub enum CacheControl {
211211
Unknown,
212212
}
213213

214-
/// Credential process JSON protocol version. If the protocol needs to make
214+
/// Credential process JSON protocol version.
215+
///
216+
/// If the protocol needs to make
215217
/// a breaking change, a new protocol version should be defined (`PROTOCOL_VERSION_2`).
216218
/// This library should offer support for both protocols if possible, by signaling
217219
/// in the `CredentialHello` message. Cargo will then choose which protocol to use,

src/cargo/core/compiler/build_config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ pub enum MessageFormat {
154154
}
155155

156156
/// The general "mode" for what to do.
157+
///
157158
/// This is used for two purposes. The commands themselves pass this in to
158159
/// `compile_ws` to tell it the general execution strategy. This influences
159160
/// the default targets selected. The other use is in the `Unit` struct

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@ impl<'a, 'gctx> BuildContext<'a, 'gctx> {
121121

122122
/// Gets the host architecture triple.
123123
///
124-
/// For example, x86_64-unknown-linux-gnu, would be
125-
/// - machine: x86_64,
126-
/// - hardware-platform: unknown,
127-
/// - operating system: linux-gnu.
124+
/// For example, `x86_64-unknown-linux-gnu`, would be
125+
/// - machine: `x86_64`,
126+
/// - hardware-platform: `unknown`,
127+
/// - operating system: `linux-gnu`.
128128
pub fn host_triple(&self) -> InternedString {
129129
self.target_data.rustc.host
130130
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ pub struct FileType {
9393
}
9494

9595
impl FileType {
96-
/// The filename for this FileType crated by rustc.
96+
/// The filename for this `FileType` crated by rustc.
9797
pub fn output_filename(&self, target: &Target, metadata: Option<&str>) -> String {
9898
match metadata {
9999
Some(metadata) => format!(
@@ -107,7 +107,7 @@ impl FileType {
107107
}
108108
}
109109

110-
/// The filename for this FileType that Cargo should use when "uplifting"
110+
/// The filename for this `FileType` that Cargo should use when "uplifting"
111111
/// it to the destination directory.
112112
pub fn uplift_filename(&self, target: &Target) -> String {
113113
let name = match target.binary_filename() {
@@ -513,10 +513,10 @@ impl TargetInfo {
513513
parse_crate_type(crate_type, &process, output, error, &mut output.lines())
514514
}
515515

516-
/// Returns all the file types generated by rustc for the given mode/target_kind.
516+
/// Returns all the file types generated by rustc for the given `mode`/`target_kind`.
517517
///
518518
/// The first value is a Vec of file types generated, the second value is
519-
/// a list of CrateTypes that are not supported by the given target.
519+
/// a list of `CrateTypes` that are not supported by the given target.
520520
pub fn rustc_outputs(
521521
&self,
522522
mode: CompileMode,

src/cargo/core/compiler/build_plan.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//! A graph-like structure used to represent the rustc commands to build the package and the
22
//! interdependencies between them.
33
//!
4-
//! The BuildPlan structure is used to store the dependency graph of a dry run so that it can be
5-
//! shared with an external build system. Each Invocation in the BuildPlan comprises a single
4+
//! The `BuildPlan` structure is used to store the dependency graph of a dry run so that it can be
5+
//! shared with an external build system. Each Invocation in the `BuildPlan` comprises a single
66
//! subprocess and defines the build environment, the outputs produced by the subprocess, and the
77
//! dependencies on other Invocations.
88

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ impl<'a, 'gctx: 'a> CompilationFiles<'a, 'gctx> {
175175
///
176176
/// See [`Metadata`] and [`fingerprint`] module for more.
177177
///
178-
/// [`fingerprint`]: ../../fingerprint/index.html#fingerprints-and-metadata
178+
/// [`fingerprint`]: super::super::fingerprint#fingerprints-and-metadata
179179
pub fn metadata(&self, unit: &Unit) -> Metadata {
180180
self.metas[unit].meta_hash
181181
}
@@ -328,7 +328,7 @@ impl<'a, 'gctx: 'a> CompilationFiles<'a, 'gctx> {
328328
self.layout(unit.kind).build().join(dir)
329329
}
330330

331-
/// Returns the "OUT_DIR" directory for running a build script.
331+
/// Returns the "`OUT_DIR`" directory for running a build script.
332332
/// `/path/to/target/{debug,release}/build/PKG-HASH/out`
333333
pub fn build_script_out_dir(&self, unit: &Unit) -> PathBuf {
334334
self.build_script_run_dir(unit).join("out")
@@ -375,7 +375,7 @@ impl<'a, 'gctx: 'a> CompilationFiles<'a, 'gctx> {
375375
.map(Arc::clone)
376376
}
377377

378-
/// Returns the path where the output for the given unit and FileType
378+
/// Returns the path where the output for the given unit and `FileType`
379379
/// should be uplifted to.
380380
///
381381
/// Returns `None` if the unit shouldn't be uplifted (for example, a

src/cargo/core/compiler/build_runner/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ pub struct BuildRunner<'a, 'gctx> {
8080
pub lto: HashMap<Unit, Lto>,
8181

8282
/// Map of Doc/Docscrape units to metadata for their -Cmetadata flag.
83-
/// See Context::find_metadata_units for more details.
83+
/// See `Context::find_metadata_units` for more details.
8484
pub metadata_for_doc_units: HashMap<Unit, Metadata>,
8585

8686
/// Set of metadata of Docscrape units that fail before completion, e.g.
@@ -155,7 +155,7 @@ impl<'a, 'gctx> BuildRunner<'a, 'gctx> {
155155
///
156156
/// See [`ops::cargo_compile`] for a higher-level view of the compile process.
157157
///
158-
/// [`ops::cargo_compile`]: ../../../ops/cargo_compile/index.html
158+
/// [`ops::cargo_compile`]: crate::ops::cargo_compile
159159
#[tracing::instrument(skip_all)]
160160
pub fn compile(mut self, exec: &Arc<dyn Executor>) -> CargoResult<Compilation<'gctx>> {
161161
// A shared lock is held during the duration of the build since rustc
@@ -415,7 +415,7 @@ impl<'a, 'gctx> BuildRunner<'a, 'gctx> {
415415
&self.bcx.unit_graph[unit]
416416
}
417417

418-
/// Returns the RunCustomBuild Unit associated with the given Unit.
418+
/// Returns the `RunCustomBuild` Unit associated with the given Unit.
419419
///
420420
/// If the package does not have a build script, this returns None.
421421
pub fn find_build_script_unit(&self, unit: &Unit) -> Option<Unit> {
@@ -431,7 +431,7 @@ impl<'a, 'gctx> BuildRunner<'a, 'gctx> {
431431
.map(|unit_dep| unit_dep.unit.clone())
432432
}
433433

434-
/// Returns the metadata hash for the RunCustomBuild Unit associated with
434+
/// Returns the metadata hash for the `RunCustomBuild` Unit associated with
435435
/// the given unit.
436436
///
437437
/// If the package does not have a build script, this returns None.
@@ -440,7 +440,7 @@ impl<'a, 'gctx> BuildRunner<'a, 'gctx> {
440440
Some(self.get_run_build_script_metadata(&script_unit))
441441
}
442442

443-
/// Returns the metadata hash for a RunCustomBuild unit.
443+
/// Returns the metadata hash for a `RunCustomBuild` unit.
444444
pub fn get_run_build_script_metadata(&self, unit: &Unit) -> Metadata {
445445
assert!(unit.mode.is_run_custom_build());
446446
self.files().metadata(unit)

0 commit comments

Comments
 (0)