diff --git a/.cargo/config.toml b/.cargo/config.toml index f1a26708418..93811313577 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -3,6 +3,7 @@ build-man = "run --package xtask-build-man --" stale-label = "run --package xtask-stale-label --" bump-check = "run --package xtask-bump-check --" lint-docs = "run --package xtask-lint-docs --" +spellcheck = "run --package xtask-spellcheck --" [env] # HACK: Until this is stabilized, `snapbox`s polyfill could get confused diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a000e573c83..77eb9cd39d6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,6 +28,7 @@ jobs: - resolver - rustfmt - schema + - spellcheck - test - test_gitoxide permissions: @@ -304,3 +305,12 @@ jobs: - uses: actions/checkout@v5 - uses: taiki-e/install-action@cargo-hack - run: cargo hack check --all-targets --rust-version --workspace --ignore-private --locked + + spellcheck: + name: Spell Check with Typos + runs-on: ubuntu-latest + steps: + - name: Checkout Actions Repository + uses: actions/checkout@v5 + - name: Spell Check Repo + uses: crate-ci/typos@v1.38.1 diff --git a/Cargo.lock b/Cargo.lock index 48d2759b693..9ab1742bfbe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -514,9 +514,9 @@ dependencies = [ [[package]] name = "cargo_metadata" -version = "0.23.0" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "981a6f317983eec002839b90fae7411a85621410ae591a9cab2ecf5cb5744873" +checksum = "ef987d17b0a113becdd19d3d0022d04d7ef41f9efe4f3fb63ac44ba61df3ade9" dependencies = [ "camino", "cargo-platform 0.3.1", @@ -5211,6 +5211,17 @@ dependencies = [ "itertools 0.14.0", ] +[[package]] +name = "xtask-spellcheck" +version = "0.0.0" +dependencies = [ + "anyhow", + "cargo-util", + "cargo_metadata", + "clap", + "semver", +] + [[package]] name = "xtask-stale-label" version = "0.0.0" diff --git a/Cargo.toml b/Cargo.toml index 9ea76a6e1c1..0f807a3d3c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,7 +35,7 @@ cargo-test-macro = { version = "0.4.8", path = "crates/cargo-test-macro" } cargo-test-support = { version = "0.9.1", path = "crates/cargo-test-support" } cargo-util = { version = "0.2.26", path = "crates/cargo-util" } cargo-util-schemas = { version = "0.10.3", path = "crates/cargo-util-schemas" } -cargo_metadata = "0.23.0" +cargo_metadata = "0.23.1" clap = "4.5.51" clap_complete = { version = "4.5.60", features = ["unstable-dynamic"] } color-print = "0.3.7" diff --git a/crates/cargo-test-support/src/paths.rs b/crates/cargo-test-support/src/paths.rs index 742c9b1a9d5..9c08afa9020 100644 --- a/crates/cargo-test-support/src/paths.rs +++ b/crates/cargo-test-support/src/paths.rs @@ -357,7 +357,7 @@ fn build_dir_ignored_path_patterns() -> Vec { // Ignore MacOS debug symbols as there are many files/directories that would clutter up // tests few not a lot of benefit. "[..].dSYM/[..]", - // Ignore Windows debub symbols files (.pdb) + // Ignore Windows debug symbols files (.pdb) "[..].pdb", ] .into_iter() diff --git a/crates/cargo-util-schemas/src/lockfile.rs b/crates/cargo-util-schemas/src/lockfile.rs index 9400d3eede1..d4c004068c7 100644 --- a/crates/cargo-util-schemas/src/lockfile.rs +++ b/crates/cargo-util-schemas/src/lockfile.rs @@ -110,7 +110,7 @@ impl TomlLockfileSourceId { .ok_or_else(|| TomlLockfileSourceIdErrorKind::InvalidSource(source.clone()))?; // Sparse URLs store the kind prefix (sparse+) in the URL. Therefore, for sparse kinds, we - // want to use the raw `source` instead of the splitted `url`. + // want to use the raw `source` instead of the split `url`. let url = Url::parse(if kind == "sparse" { &source } else { url }).map_err(|msg| { TomlLockfileSourceIdErrorKind::InvalidUrl { url: url.to_string(), diff --git a/crates/xtask-spellcheck/Cargo.toml b/crates/xtask-spellcheck/Cargo.toml new file mode 100644 index 00000000000..d082b358a79 --- /dev/null +++ b/crates/xtask-spellcheck/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "xtask-spellcheck" +version = "0.0.0" +edition.workspace = true +publish = false + +[dependencies] +anyhow.workspace = true +cargo_metadata.workspace = true +cargo-util.workspace = true +clap.workspace = true +semver.workspace = true + +[lints] +workspace = true diff --git a/crates/xtask-spellcheck/src/main.rs b/crates/xtask-spellcheck/src/main.rs new file mode 100644 index 00000000000..4afb97ca096 --- /dev/null +++ b/crates/xtask-spellcheck/src/main.rs @@ -0,0 +1,202 @@ +#![allow(clippy::disallowed_methods)] +#![allow(clippy::print_stderr)] +#![allow(clippy::print_stdout)] + +use anyhow::Result; +use cargo_metadata::{Metadata, MetadataCommand}; +use clap::{Arg, ArgAction}; +use semver::Version; +use std::{ + env, io, + path::{Path, PathBuf}, + process::Command, +}; + +const BIN_NAME: &str = "typos"; +const PKG_NAME: &str = "typos-cli"; +const TYPOS_STEP_PREFIX: &str = " uses: crate-ci/typos@v"; + +fn main() -> anyhow::Result<()> { + let cli = cli(); + exec(&cli.get_matches())?; + Ok(()) +} + +pub fn cli() -> clap::Command { + clap::Command::new("xtask-spellcheck") + .arg( + Arg::new("color") + .long("color") + .help("Coloring: auto, always, never") + .action(ArgAction::Set) + .value_name("WHEN") + .global(true), + ) + .arg( + Arg::new("quiet") + .long("quiet") + .short('q') + .help("Do not print cargo log messages") + .action(ArgAction::SetTrue) + .global(true), + ) + .arg( + Arg::new("verbose") + .long("verbose") + .short('v') + .help("Use verbose output (-vv very verbose/build.rs output)") + .action(ArgAction::Count) + .global(true), + ) + .arg( + Arg::new("write-changes") + .long("write-changes") + .short('w') + .help("Write fixes out") + .action(ArgAction::SetTrue) + .global(true), + ) +} + +pub fn exec(matches: &clap::ArgMatches) -> Result<()> { + let mut args = vec![]; + + match matches.get_one::("color") { + Some(c) if matches!(c.as_str(), "auto" | "always" | "never") => { + args.push("--color"); + args.push(c); + } + Some(c) => { + anyhow::bail!( + "argument for --color must be auto, always, or \ + never, but found `{}`", + c + ); + } + _ => {} + } + + if matches.get_flag("quiet") { + args.push("--quiet"); + } + + let verbose_count = matches.get_count("verbose"); + + for _ in 0..verbose_count { + args.push("--verbose"); + } + if matches.get_flag("write-changes") { + args.push("--write-changes"); + } + + let metadata = MetadataCommand::new() + .exec() + .expect("cargo_metadata failed"); + + let required_version = extract_workflow_typos_version(&metadata)?; + + let outdir = metadata + .build_directory + .unwrap_or_else(|| metadata.target_directory) + .as_std_path() + .join("tmp"); + let workspace_root = metadata.workspace_root.as_path().as_std_path(); + let bin_path = crate::ensure_version_or_cargo_install(&outdir, required_version)?; + + eprintln!("running {BIN_NAME}"); + Command::new(bin_path) + .current_dir(workspace_root) + .args(args) + .status()?; + + Ok(()) +} + +fn extract_workflow_typos_version(metadata: &Metadata) -> anyhow::Result { + let ws_root = metadata.workspace_root.as_path().as_std_path(); + let workflow_path = ws_root.join(".github").join("workflows").join("main.yml"); + let file_content = std::fs::read_to_string(workflow_path)?; + + if let Some(line) = file_content + .lines() + .find(|line| line.contains(TYPOS_STEP_PREFIX)) + && let Some(stripped) = line.strip_prefix(TYPOS_STEP_PREFIX) + && let Ok(v) = Version::parse(stripped) + { + Ok(v) + } else { + Err(anyhow::anyhow!("Could not find typos version in workflow")) + } +} + +/// If the given executable is installed with the given version, use that, +/// otherwise install via cargo. +pub fn ensure_version_or_cargo_install( + build_dir: &Path, + required_version: Version, +) -> io::Result { + // Check if the user has a sufficient version already installed + let bin_path = PathBuf::from(BIN_NAME).with_extension(env::consts::EXE_EXTENSION); + if let Some(user_version) = get_typos_version(&bin_path) { + if user_version >= required_version { + return Ok(bin_path); + } + } + + let tool_root_dir = build_dir.join("misc-tools"); + let tool_bin_dir = tool_root_dir.join("bin"); + let bin_path = tool_bin_dir + .join(BIN_NAME) + .with_extension(env::consts::EXE_EXTENSION); + + // Check if we have already installed sufficient version + if let Some(misc_tools_version) = get_typos_version(&bin_path) { + if misc_tools_version >= required_version { + return Ok(bin_path); + } + } + + eprintln!("required `typos` version ({required_version}) not found, building from source"); + + let mut cmd = Command::new("cargo"); + // use --force to ensure that if the required version is bumped, we update it. + cmd.args(["install", "--locked", "--force", "--quiet"]) + .arg("--root") + .arg(&tool_root_dir) + // use --target-dir to ensure we have a build cache so repeated invocations aren't slow. + .arg("--target-dir") + .arg(tool_root_dir.join("target")) + .arg(format!("{PKG_NAME}@{required_version}")) + // modify PATH so that cargo doesn't print a warning telling the user to modify the path. + .env( + "PATH", + env::join_paths( + env::split_paths(&env::var("PATH").unwrap()) + .chain(std::iter::once(tool_bin_dir.clone())), + ) + .expect("build dir contains invalid char"), + ); + + let cargo_exit_code = cmd.spawn()?.wait()?; + if !cargo_exit_code.success() { + return Err(io::Error::other("cargo install failed")); + } + assert!( + matches!(bin_path.try_exists(), Ok(true)), + "cargo install did not produce the expected binary" + ); + eprintln!("finished {BIN_NAME}"); + Ok(bin_path) +} + +fn get_typos_version(bin: &PathBuf) -> Option { + // ignore the process exit code here and instead just let the version number check fail + if let Ok(output) = Command::new(&bin).arg("--version").output() + && let Ok(s) = String::from_utf8(output.stdout) + && let Some(version_str) = s.trim().split_whitespace().last() + { + Version::parse(version_str).ok() + } else { + None + } +} diff --git a/src/cargo/core/compiler/build_runner/compilation_files.rs b/src/cargo/core/compiler/build_runner/compilation_files.rs index 964a80acdc4..8ad9328b3ee 100644 --- a/src/cargo/core/compiler/build_runner/compilation_files.rs +++ b/src/cargo/core/compiler/build_runner/compilation_files.rs @@ -235,16 +235,16 @@ impl<'a, 'gctx: 'a> CompilationFiles<'a, 'gctx> { /// Note that some units may share the same directory, so care should be /// taken in those cases! fn pkg_dir(&self, unit: &Unit) -> String { - let seperator = match self.ws.gctx().cli_unstable().build_dir_new_layout { + let separator = match self.ws.gctx().cli_unstable().build_dir_new_layout { true => "/", false => "-", }; let name = unit.pkg.package_id().name(); let meta = self.metas[unit]; if let Some(c_extra_filename) = meta.c_extra_filename() { - format!("{}{}{}", name, seperator, c_extra_filename) + format!("{}{}{}", name, separator, c_extra_filename) } else { - format!("{}{}{}", name, seperator, self.target_short_hash(unit)) + format!("{}{}{}", name, separator, self.target_short_hash(unit)) } } diff --git a/src/cargo/core/compiler/fingerprint/mod.rs b/src/cargo/core/compiler/fingerprint/mod.rs index 39574a365b6..e5bf19f4a3b 100644 --- a/src/cargo/core/compiler/fingerprint/mod.rs +++ b/src/cargo/core/compiler/fingerprint/mod.rs @@ -1069,18 +1069,18 @@ impl Fingerprint { } ( LocalFingerprint::CheckDepInfo { - dep_info: adep, + dep_info: a_dep, checksum: checksum_a, }, LocalFingerprint::CheckDepInfo { - dep_info: bdep, + dep_info: b_dep, checksum: checksum_b, }, ) => { - if adep != bdep { + if a_dep != b_dep { return DirtyReason::DepInfoOutputChanged { - old: bdep.clone(), - new: adep.clone(), + old: b_dep.clone(), + new: a_dep.clone(), }; } if checksum_a != checksum_b { @@ -1089,48 +1089,48 @@ impl Fingerprint { } ( LocalFingerprint::RerunIfChanged { - output: aout, - paths: apaths, + output: a_out, + paths: a_paths, }, LocalFingerprint::RerunIfChanged { - output: bout, - paths: bpaths, + output: b_out, + paths: b_paths, }, ) => { - if aout != bout { + if a_out != b_out { return DirtyReason::RerunIfChangedOutputFileChanged { - old: bout.clone(), - new: aout.clone(), + old: b_out.clone(), + new: a_out.clone(), }; } - if apaths != bpaths { + if a_paths != b_paths { return DirtyReason::RerunIfChangedOutputPathsChanged { - old: bpaths.clone(), - new: apaths.clone(), + old: b_paths.clone(), + new: a_paths.clone(), }; } } ( LocalFingerprint::RerunIfEnvChanged { - var: akey, - val: avalue, + var: a_key, + val: a_value, }, LocalFingerprint::RerunIfEnvChanged { - var: bkey, - val: bvalue, + var: b_key, + val: b_value, }, ) => { - if *akey != *bkey { + if *a_key != *b_key { return DirtyReason::EnvVarsChanged { - old: bkey.clone(), - new: akey.clone(), + old: b_key.clone(), + new: a_key.clone(), }; } - if *avalue != *bvalue { + if *a_value != *b_value { return DirtyReason::EnvVarChanged { - name: akey.clone(), - old_value: bvalue.clone(), - new_value: avalue.clone(), + name: a_key.clone(), + old_value: b_value.clone(), + new_value: a_value.clone(), }; } } diff --git a/src/cargo/core/compiler/mod.rs b/src/cargo/core/compiler/mod.rs index 02349a20849..a9b588c016c 100644 --- a/src/cargo/core/compiler/mod.rs +++ b/src/cargo/core/compiler/mod.rs @@ -1656,7 +1656,7 @@ fn build_deps_args( if build_runner.bcx.gctx.cli_unstable().build_dir_new_layout { let mut map = BTreeMap::new(); - // Recursively add all depenendency args to rustc process + // Recursively add all dependency args to rustc process add_dep_arg(&mut map, build_runner, unit); let paths = map.into_iter().map(|(_, path)| path).sorted_unstable(); diff --git a/src/cargo/core/compiler/timings.rs b/src/cargo/core/compiler/timings.rs index 4eb7f3831a7..ce22048abe0 100644 --- a/src/cargo/core/compiler/timings.rs +++ b/src/cargo/core/compiler/timings.rs @@ -634,7 +634,7 @@ impl<'gctx> Timings<'gctx> { AggregatedSections::Sections(mut sections) => { // We draw the sections in the pipeline graph in a way where the frontend // section has the "default" build color, and then additional sections - // (codegen, link) are overlayed on top with a different color. + // (codegen, link) are overlaid on top with a different color. // However, there might be some time after the final (usually link) section, // which definitely shouldn't be classified as "Frontend". We thus try to // detect this situation and add a final "Other" section. diff --git a/src/cargo/core/resolver/dep_cache.rs b/src/cargo/core/resolver/dep_cache.rs index 59997503329..54bde19dd35 100644 --- a/src/cargo/core/resolver/dep_cache.rs +++ b/src/cargo/core/resolver/dep_cache.rs @@ -573,7 +573,7 @@ syntax so it does not have an implicit feature with that name{}", None => ActivateError::Fatal(anyhow::format_err!( "package `{}` does not have feature `{}` -help: a depednency with that name exists but it is required dependency and only optional dependencies can be used as features.", +help: a dependency with that name exists but it is required dependency and only optional dependencies can be used as features.", summary.package_id(), feat, )), diff --git a/src/cargo/core/shell.rs b/src/cargo/core/shell.rs index be622ef1e7c..2a8ff9c8e14 100644 --- a/src/cargo/core/shell.rs +++ b/src/cargo/core/shell.rs @@ -366,7 +366,7 @@ impl Shell { fn file_hyperlink(&mut self, path: &std::path::Path) -> Option { let mut url = url::Url::from_file_path(path).ok()?; // Do a best-effort of setting the host in the URL to avoid issues with opening a link - // scoped to the computer you've SSHed into + // scoped to the computer you've SSH'ed into let hostname = if cfg!(windows) { // Not supported correctly on windows None diff --git a/src/cargo/core/workspace.rs b/src/cargo/core/workspace.rs index 566dde9ff01..2a609163d6e 100644 --- a/src/cargo/core/workspace.rs +++ b/src/cargo/core/workspace.rs @@ -1327,7 +1327,7 @@ impl<'gctx> Workspace<'gctx> { // This is a short term hack to allow `blanket_hint_mostly_unused` // to run without requiring `-Zcargo-lints`, which should hopefully - // improve the testing expierience while we are collecting feedback + // improve the testing experience while we are collecting feedback if self.gctx.cli_unstable().profile_hint_mostly_unused { blanket_hint_mostly_unused( self.root_maybe(), diff --git a/src/cargo/ops/cargo_compile/compile_filter.rs b/src/cargo/ops/cargo_compile/compile_filter.rs index cddcd56b87d..bbf13f9db76 100644 --- a/src/cargo/ops/cargo_compile/compile_filter.rs +++ b/src/cargo/ops/cargo_compile/compile_filter.rs @@ -102,12 +102,12 @@ impl CompileFilter { lib_only: bool, bins: Vec, all_bins: bool, - tsts: Vec, - all_tsts: bool, - exms: Vec, - all_exms: bool, - bens: Vec, - all_bens: bool, + tests: Vec, + all_tests: bool, + examples: Vec, + all_examples: bool, + benches: Vec, + all_benches: bool, all_targets: bool, ) -> CompileFilter { if all_targets { @@ -119,34 +119,34 @@ impl CompileFilter { LibRule::False }; let rule_bins = FilterRule::new(bins, all_bins); - let rule_tsts = FilterRule::new(tsts, all_tsts); - let rule_exms = FilterRule::new(exms, all_exms); - let rule_bens = FilterRule::new(bens, all_bens); + let rule_tests = FilterRule::new(tests, all_tests); + let rule_examples = FilterRule::new(examples, all_examples); + let rule_benches = FilterRule::new(benches, all_benches); - CompileFilter::new(rule_lib, rule_bins, rule_tsts, rule_exms, rule_bens) + CompileFilter::new(rule_lib, rule_bins, rule_tests, rule_examples, rule_benches) } /// Constructs a filter from underlying primitives. pub fn new( rule_lib: LibRule, rule_bins: FilterRule, - rule_tsts: FilterRule, - rule_exms: FilterRule, - rule_bens: FilterRule, + rule_tests: FilterRule, + rule_examples: FilterRule, + rule_benches: FilterRule, ) -> CompileFilter { if rule_lib == LibRule::True || rule_bins.is_specific() - || rule_tsts.is_specific() - || rule_exms.is_specific() - || rule_bens.is_specific() + || rule_tests.is_specific() + || rule_examples.is_specific() + || rule_benches.is_specific() { CompileFilter::Only { all_targets: false, lib: rule_lib, bins: rule_bins, - examples: rule_exms, - benches: rule_bens, - tests: rule_tsts, + examples: rule_examples, + benches: rule_benches, + tests: rule_tests, } } else { CompileFilter::Default { diff --git a/src/cargo/ops/cargo_package/mod.rs b/src/cargo/ops/cargo_package/mod.rs index 0321b5601ad..3294db4c8b1 100644 --- a/src/cargo/ops/cargo_package/mod.rs +++ b/src/cargo/ops/cargo_package/mod.rs @@ -919,7 +919,7 @@ fn tar( header.set_size(contents.len() as u64); // We need to have the same DETERMINISTIC_TIMESTAMP for generated files // https://github.com/alexcrichton/tar-rs/blob/d0261f1f6cc959ba0758e7236b3fd81e90dd1dc6/src/header.rs#L18-L24 - // Unfortunately tar-rs doesn't expose that so we harcode the timestamp here. + // Unfortunately tar-rs doesn't expose that so we hardcode the timestamp here. // Hardcoded value be removed once alexcrichton/tar-rs#420 is merged and released. // See also rust-lang/cargo#16237 header.set_mtime(1153704088); diff --git a/src/cargo/ops/vendor.rs b/src/cargo/ops/vendor.rs index 2e0ee770f33..2479abe9b07 100644 --- a/src/cargo/ops/vendor.rs +++ b/src/cargo/ops/vendor.rs @@ -308,7 +308,7 @@ fn sync( // This fallback is worked for sometimes `fs::rename` failed in a specific situation, such as: // - In Windows 10 versions earlier than 1607, the destination of `fs::rename` can't be a directory in older versions. // - `from` and `to` are on separate filesystems. - // - AntiVirus or our system indexer are doing stuf simutaneously. + // - AntiVirus or our system indexer are doing stuf simultaneously. // - Any other reasons documented in std::fs::rename. tracing::warn!("failed to `mv {unpacked_src:?} {dst:?}`: {e}"); let paths: Vec<_> = walkdir(&unpacked_src).map(|e| e.into_path()).collect(); diff --git a/src/cargo/util/context/de.rs b/src/cargo/util/context/de.rs index a3567ff2271..b894a9f5e6c 100644 --- a/src/cargo/util/context/de.rs +++ b/src/cargo/util/context/de.rs @@ -200,7 +200,7 @@ impl<'de, 'gctx> de::Deserializer<'de> for Deserializer<'gctx> { let vals: Vec = res .into_iter() .map(|val| match val { - CV::String(s, _defintion) => Ok(s), + CV::String(s, _definition) => Ok(s), other => Err(ConfigError::expected(&self.key, "string", &other)), }) .collect::>()?; diff --git a/src/cargo/util/context/key.rs b/src/cargo/util/context/key.rs index b4418394c89..a898b6374c9 100644 --- a/src/cargo/util/context/key.rs +++ b/src/cargo/util/context/key.rs @@ -118,7 +118,7 @@ pub enum KeyOrIdx { Idx(usize), } -/// Tracks the key path to an item in an array for detailed errro context. +/// Tracks the key path to an item in an array for detailed error context. #[derive(Debug, Clone)] pub struct ArrayItemKeyPath { base: ConfigKey, diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index facd5873362..fd81b5ae0ca 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -1310,7 +1310,7 @@ pub fn to_real_manifest( let edition_msrv = RustVersion::try_from(edition_msrv).unwrap(); if !edition_msrv.is_compatible_with(pkg_msrv.as_partial()) { bail!( - "rust-version {} is imcompatible with the version ({}) required by \ + "rust-version {} is incompatible with the version ({}) required by \ the specified edition ({})", pkg_msrv, edition_msrv, diff --git a/src/doc/contrib/src/process/working-on-cargo.md b/src/doc/contrib/src/process/working-on-cargo.md index d3069702e6b..f5e50f8848c 100644 --- a/src/doc/contrib/src/process/working-on-cargo.md +++ b/src/doc/contrib/src/process/working-on-cargo.md @@ -99,6 +99,11 @@ Some guidelines on working on a change: * Include tests that cover all non-trivial code. See the [Testing chapter] for more about writing and running tests. * All code should be warning-free. This is checked during tests. +* All changes should be free of typos. Cargo's CI has a job that runs [`typos`] + to enforce this. You can use `cargo spellcheck` to run this check locally, + and `cargo spellcheck --write-changes` to fix most typos automatically. + +[`typos`]: https://github.com/crate-ci/typos ## Submitting a Pull Request diff --git a/src/doc/src/CHANGELOG.md b/src/doc/src/CHANGELOG.md index c73efbc2d39..4d1e49389b5 100644 --- a/src/doc/src/CHANGELOG.md +++ b/src/doc/src/CHANGELOG.md @@ -3206,7 +3206,7 @@ Some notable changes: - Renamed `credential-process` to `credential-provider` in Cargo configurations. - New JSON protocol for communicating with external credential providers via stdin/stdout. - - The GNOME Secert provider now dynamically loads `libsecert`. + - The GNOME Secret provider now dynamically loads `libsecert`. - The 1password provider is no longer built-in. - Changed the unstable key for asymmetric tokens from `registry-auth` to `credential-process`. - ❗️ Removed `--keep-going` flag support from `cargo test` and `cargo bench`. diff --git a/src/doc/src/guide/build-performance.md b/src/doc/src/guide/build-performance.md index afd1e91db67..8d7ac5481b2 100644 --- a/src/doc/src/guide/build-performance.md +++ b/src/doc/src/guide/build-performance.md @@ -132,7 +132,7 @@ When invoking `cargo`, However, when contributing to an application, you may need to build and test various packages within the application, which can cause extraneous rebuilds because different sets of features may be activated for common dependencies. -With [`feauture-unification`][feature-unification], +With [`feature-unification`][feature-unification], you can reuse more dependency builds by ensuring the same set of dependency features are activated, independent of which package you are currently building and testing. diff --git a/src/doc/src/reference/build-script-examples.md b/src/doc/src/reference/build-script-examples.md index 69d34159e10..1e4d230dd8d 100644 --- a/src/doc/src/reference/build-script-examples.md +++ b/src/doc/src/reference/build-script-examples.md @@ -383,7 +383,7 @@ Here's an example: # Cargo.toml [package] -name = "zuser" +name = "z_user" version = "0.1.0" edition = "2024" @@ -403,12 +403,12 @@ script: fn main() { let mut cfg = cc::Build::new(); - cfg.file("src/zuser.c"); + cfg.file("src/z_user.c"); if let Some(include) = std::env::var_os("DEP_Z_INCLUDE") { cfg.include(include); } - cfg.compile("zuser"); - println!("cargo::rerun-if-changed=src/zuser.c"); + cfg.compile("z_user"); + println!("cargo::rerun-if-changed=src/z_user.c"); } ``` @@ -417,7 +417,7 @@ the zlib header, and it should find the header, even on systems where it isn't already installed. ```c -// src/zuser.c +// src/z_user.c #include "zlib.h" diff --git a/tests/testsuite/bad_config.rs b/tests/testsuite/bad_config.rs index ab254b5d3c8..8bd1b0c4e20 100644 --- a/tests/testsuite/bad_config.rs +++ b/tests/testsuite/bad_config.rs @@ -804,14 +804,14 @@ fn unused_keys() { version = "0.5.0" edition = "2015" authors = ["wycats@example.com"] - bulid = "foo" + unused = "foo" "#, ) .file("src/lib.rs", "pub fn foo() {}") .build(); p.cargo("check") .with_stderr_data(str![[r#" -[WARNING] unused manifest key: package.bulid +[WARNING] unused manifest key: package.unused [CHECKING] foo v0.5.0 ([ROOT]/foo) [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s @@ -854,7 +854,7 @@ fn unused_keys_in_virtual_manifest() { r#" [workspace] members = ["bar"] - bulid = "foo" + unused = "foo" "#, ) .file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) @@ -862,7 +862,7 @@ fn unused_keys_in_virtual_manifest() { .build(); p.cargo("check --workspace") .with_stderr_data(str![[r#" -[WARNING] [ROOT]/foo/Cargo.toml: unused manifest key: workspace.bulid +[WARNING] [ROOT]/foo/Cargo.toml: unused manifest key: workspace.unused [CHECKING] bar v0.0.1 ([ROOT]/foo/bar) [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s diff --git a/tests/testsuite/features.rs b/tests/testsuite/features.rs index c13ec92b961..0f1f89c5fa5 100644 --- a/tests/testsuite/features.rs +++ b/tests/testsuite/features.rs @@ -448,7 +448,7 @@ fn cli_activates_required_dependency() { [LOCKING] 1 package to latest compatible version [ERROR] package `foo v0.0.1 ([ROOT]/foo)` does not have feature `bar` -[HELP] a depednency with that name exists but it is required dependency and only optional dependencies can be used as features. +[HELP] a dependency with that name exists but it is required dependency and only optional dependencies can be used as features. "#]]) .with_status(101) diff --git a/tests/testsuite/freshness.rs b/tests/testsuite/freshness.rs index 837b03d42df..0cf673e4f7a 100644 --- a/tests/testsuite/freshness.rs +++ b/tests/testsuite/freshness.rs @@ -1459,16 +1459,16 @@ fn fingerprint_cleaner(mut dir: PathBuf, timestamp: filetime::FileTime) { // effecting any builds that happened since that time stamp. let mut cleaned = false; dir.push(".fingerprint"); - for fing in fs::read_dir(&dir).unwrap() { - let fing = fing.unwrap(); + for fingerprint in fs::read_dir(&dir).unwrap() { + let fingerprint = fingerprint.unwrap(); let outdated = |f: io::Result| { filetime::FileTime::from_last_modification_time(&f.unwrap().metadata().unwrap()) <= timestamp }; - if fs::read_dir(fing.path()).unwrap().all(outdated) { - fs::remove_dir_all(fing.path()).unwrap(); - println!("remove: {:?}", fing.path()); + if fs::read_dir(fingerprint.path()).unwrap().all(outdated) { + fs::remove_dir_all(fingerprint.path()).unwrap(); + println!("remove: {:?}", fingerprint.path()); // a real cleaner would remove the big files in deps and build as well // but fingerprint is sufficient for our tests cleaned = true; diff --git a/tests/testsuite/git.rs b/tests/testsuite/git.rs index 68774acbaa1..502a709d530 100644 --- a/tests/testsuite/git.rs +++ b/tests/testsuite/git.rs @@ -2990,7 +2990,7 @@ fn templatedir_doesnt_cause_problems() { &format!( r#" [package] - name = "fo" + name = "foo" version = "0.5.0" edition = "2015" authors = [] diff --git a/tests/testsuite/git_shallow.rs b/tests/testsuite/git_shallow.rs index 49fbb60e1dd..1558a4acd3b 100644 --- a/tests/testsuite/git_shallow.rs +++ b/tests/testsuite/git_shallow.rs @@ -445,7 +445,7 @@ fn fetch_index_then_fetch( .run(); let repo = gix::open_opts(find_remote_index(mode_1st), gix::open::Options::isolated())?; - let complete_depth = 2; // initial commmit, bar@1.0.0 + let complete_depth = 2; // initial commit, bar@1.0.0 mode_1st.assert_index(&repo, 1, complete_depth); Package::new("bar", "1.1.0").publish(); @@ -459,7 +459,7 @@ fn fetch_index_then_fetch( .run(); let repo = gix::open_opts(find_remote_index(mode_2nd), gix::open::Options::isolated())?; - let complete_depth = 3; // initial commmit, bar@1.0.0, and bar@1.1.0 + let complete_depth = 3; // initial commit, bar@1.0.0, and bar@1.1.0 mode_2nd.assert_index(&repo, 1, complete_depth); Ok(()) diff --git a/tests/testsuite/local_registry.rs b/tests/testsuite/local_registry.rs index 8b9fe1daa2b..b2d11049042 100644 --- a/tests/testsuite/local_registry.rs +++ b/tests/testsuite/local_registry.rs @@ -74,7 +74,7 @@ fn simple() { fn not_found() { setup(); // Publish a package so that the directory hierarchy is created. - // Note, however, that we declare a dependency on baZ. + // Note, however, that we declare a dependency on baz. Package::new("bar", "0.0.1").local(true).publish(); let p = project() diff --git a/tests/testsuite/rust_version.rs b/tests/testsuite/rust_version.rs index 23363f6592c..fc0bd84cc01 100644 --- a/tests/testsuite/rust_version.rs +++ b/tests/testsuite/rust_version.rs @@ -82,7 +82,7 @@ fn rust_version_older_than_edition() { [ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` Caused by: - rust-version 1.1 is imcompatible with the version (1.31.0) required by the specified edition (2018) + rust-version 1.1 is incompatible with the version (1.31.0) required by the specified edition (2018) "#]]) .run(); diff --git a/tests/testsuite/script/cargo.rs b/tests/testsuite/script/cargo.rs index 68c7cb28e5a..6cc590c7c17 100644 --- a/tests/testsuite/script/cargo.rs +++ b/tests/testsuite/script/cargo.rs @@ -239,7 +239,7 @@ fn requires_z_flag() { #[cargo_test(nightly, reason = "-Zscript is unstable")] fn manifest_parse_error() { - // Exagerate the newlines to make it more obvious if the error's line number is off + // Exaggerate the newlines to make it more obvious if the error's line number is off let script = r#"#!/usr/bin/env cargo diff --git a/typos.toml b/typos.toml new file mode 100755 index 00000000000..17120b92f61 --- /dev/null +++ b/typos.toml @@ -0,0 +1,45 @@ +[files] +extend-exclude = [ + "crates/resolver-tests/*", + "LICENSE-THIRD-PARTY", + "tests/testsuite/script/rustc_fixtures", +] + +[default] +extend-ignore-re = [ + # Handles ssh keys + "AAAA[0-9A-Za-z+/]+[=]{0,3}", + + # Handles paseto from login tests + "k3[.](secret|public)[.][a-zA-Z0-9_-]+", +] +extend-ignore-identifiers-re = [ + # Handles git short SHA-1 hashes + "[a-f0-9]{8,9}", +] +extend-ignore-words-re = [ + # words with length <= 4 chars is likely noise + "^[a-zA-Z]{1,4}$", +] + +[default.extend-identifiers] +# This comes from `windows_sys` +ERROR_FILENAME_EXCED_RANGE = "ERROR_FILENAME_EXCED_RANGE" + +# Name of a dependency +flate2 = "flate2" + +[default.extend-words] +filetimes = "filetimes" + +[type.cargo_command] +extend-glob = ["cargo_command.rs"] + +[type.cargo_command.extend-words] +biuld = "biuld" + +[type.random-sample] +extend-glob = ["random-sample"] + +[type.random-sample.extend-words] +objekt = "objekt"