diff --git a/.github/workflows/spelling.yml b/.github/workflows/spelling.yml new file mode 100644 index 00000000000..b8008efb37c --- /dev/null +++ b/.github/workflows/spelling.yml @@ -0,0 +1,25 @@ +name: Spelling + +permissions: + contents: read + +on: [pull_request] + +env: + RUST_BACKTRACE: 1 + CARGO_TERM_COLOR: always + CLICOLOR: 1 + +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + +jobs: + spelling: + 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/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/src/cargo/core/compiler/build_runner/compilation_files.rs b/src/cargo/core/compiler/build_runner/compilation_files.rs index 34d4660c5be..9b2646ab3ae 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 88cdba2f540..17d142dc58f 100644 --- a/src/cargo/core/compiler/fingerprint/mod.rs +++ b/src/cargo/core/compiler/fingerprint/mod.rs @@ -1031,18 +1031,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 { @@ -1051,48 +1051,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 adeae259af7..59874a5203d 100644 --- a/src/cargo/core/compiler/mod.rs +++ b/src/cargo/core/compiler/mod.rs @@ -1675,7 +1675,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 999c1305815..503ae8bdab9 100644 --- a/src/cargo/core/compiler/timings.rs +++ b/src/cargo/core/compiler/timings.rs @@ -618,7 +618,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/shell.rs b/src/cargo/core/shell.rs index 6a5077dd1b5..d67246abd8c 100644 --- a/src/cargo/core/shell.rs +++ b/src/cargo/core/shell.rs @@ -364,7 +364,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/util/context/de.rs b/src/cargo/util/context/de.rs index 71af17c0516..6010348075d 100644 --- a/src/cargo/util/context/de.rs +++ b/src/cargo/util/context/de.rs @@ -198,7 +198,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/toml/mod.rs b/src/cargo/util/toml/mod.rs index 0b9d8ba2c03..56f93a8a282 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -1308,7 +1308,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/src/CHANGELOG.md b/src/doc/src/CHANGELOG.md index c4beb61415d..6cd9668d116 100644 --- a/src/doc/src/CHANGELOG.md +++ b/src/doc/src/CHANGELOG.md @@ -3077,7 +3077,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 eea8cc82307..c83c3ddfd79 100644 --- a/tests/testsuite/bad_config.rs +++ b/tests/testsuite/bad_config.rs @@ -834,14 +834,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 @@ -884,7 +884,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")) @@ -892,7 +892,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/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/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 ef86132897e..30dc70463d3 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"