Skip to content

Commit d59b8f1

Browse files
authored
Rollup merge of rust-lang#145025 - lolbinarycat:ci-tidy-spellcheck, r=Kobzol
run spellcheck as a tidy extra check in ci This is probably how it should've been done from the start. r? `@Kobzol`
2 parents e024688 + 184e8bd commit d59b8f1

File tree

12 files changed

+99
-38
lines changed

12 files changed

+99
-38
lines changed

compiler/rustc_next_trait_solver/src/canonicalizer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ enum CanonicalizeInputKind {
2727
ParamEnv,
2828
/// When canonicalizing predicates, we don't keep `'static`. If we're
2929
/// currently outside of the trait solver and canonicalize the root goal
30-
/// during HIR typeck, we replace each occurance of a region with a
30+
/// during HIR typeck, we replace each occurrence of a region with a
3131
/// unique region variable. See the comment on `InferCtxt::in_hir_typeck`
3232
/// for more details.
3333
Predicate { is_hir_typeck_root_goal: bool },

compiler/rustc_resolve/src/imports.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
870870
}
871871
ImportKind::Glob { .. } => {
872872
// FIXME: Use mutable resolver directly as a hack, this should be an output of
873-
// specualtive resolution.
873+
// speculative resolution.
874874
self.get_mut_unchecked().resolve_glob_import(import);
875875
return 0;
876876
}
@@ -907,7 +907,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
907907
// We need the `target`, `source` can be extracted.
908908
let imported_binding = this.import(binding, import);
909909
// FIXME: Use mutable resolver directly as a hack, this should be an output of
910-
// specualtive resolution.
910+
// speculative resolution.
911911
this.get_mut_unchecked().define_binding_local(
912912
parent,
913913
target,
@@ -921,7 +921,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
921921
if target.name != kw::Underscore {
922922
let key = BindingKey::new(target, ns);
923923
// FIXME: Use mutable resolver directly as a hack, this should be an output of
924-
// specualtive resolution.
924+
// speculative resolution.
925925
this.get_mut_unchecked().update_local_resolution(
926926
parent,
927927
key,

compiler/rustc_resolve/src/late.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4277,7 +4277,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
42774277
if path.len() == 2
42784278
&& let [segment] = prefix_path
42794279
{
4280-
// Delay to check whether methond name is an associated function or not
4280+
// Delay to check whether method name is an associated function or not
42814281
// ```
42824282
// let foo = Foo {};
42834283
// foo::bar(); // possibly suggest to foo.bar();

library/std/src/sync/nonpoison/mutex.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ pub struct MutexGuard<'a, T: ?Sized + 'a> {
100100
lock: &'a Mutex<T>,
101101
}
102102

103-
/// A [`MutexGuard`] is not `Send` to maximize platform portablity.
103+
/// A [`MutexGuard`] is not `Send` to maximize platform portability.
104104
///
105105
/// On platforms that use POSIX threads (commonly referred to as pthreads) there is a requirement to
106106
/// release mutex locks on the same thread they were acquired.

library/std/src/sync/poison/mutex.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ pub struct MutexGuard<'a, T: ?Sized + 'a> {
279279
poison: poison::Guard,
280280
}
281281

282-
/// A [`MutexGuard`] is not `Send` to maximize platform portablity.
282+
/// A [`MutexGuard`] is not `Send` to maximize platform portability.
283283
///
284284
/// On platforms that use POSIX threads (commonly referred to as pthreads) there is a requirement to
285285
/// release mutex locks on the same thread they were acquired.

library/std/src/sys/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![allow(unsafe_op_in_unsafe_fn)]
22

33
/// The configure builtins provides runtime support compiler-builtin features
4-
/// which require dynamic intialization to work as expected, e.g. aarch64
4+
/// which require dynamic initialization to work as expected, e.g. aarch64
55
/// outline-atomics.
66
mod configure_builtins;
77

src/ci/docker/host-x86_64/tidy/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ RUN bash -c 'npm install -g eslint@$(cat /tmp/eslint.version)'
4545
# NOTE: intentionally uses python2 for x.py so we can test it still works.
4646
# validate-toolstate only runs in our CI, so it's ok for it to only support python3.
4747
ENV SCRIPT TIDY_PRINT_DIFF=1 python2.7 ../x.py test --stage 0 \
48-
src/tools/tidy tidyselftest --extra-checks=py,cpp,js
48+
src/tools/tidy tidyselftest --extra-checks=py,cpp,js,spellcheck

src/librustdoc/html/static/js/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1529,7 +1529,7 @@ function preLoadCss(cssUrl) {
15291529
["&#9166;", "Go to active search result"],
15301530
["+", "Expand all sections"],
15311531
["-", "Collapse all sections"],
1532-
// for the sake of brevity, we don't say "inherint impl blocks",
1532+
// for the sake of brevity, we don't say "inherit impl blocks",
15331533
// although that would be more correct,
15341534
// since trait impl blocks are collapsed by -
15351535
["_", "Collapse all sections, including impl blocks"],

src/librustdoc/html/static/js/search.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3333,7 +3333,7 @@ class DocSearch {
33333333
}
33343334

33353335
// sort unstable items later
3336-
// FIXME: there is some doubt if this is the most effecient way to implement this.
3336+
// FIXME: there is some doubt if this is the most efficient way to implement this.
33373337
// alternative options include:
33383338
// * put is_unstable on each item when the index is built.
33393339
// increases memory usage but avoids a hashmap lookup.

src/tools/tidy/src/extra_checks/mod.rs

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ const RUFF_CONFIG_PATH: &[&str] = &["src", "tools", "tidy", "config", "ruff.toml
4141
const RUFF_CACHE_PATH: &[&str] = &["cache", "ruff_cache"];
4242
const PIP_REQ_PATH: &[&str] = &["src", "tools", "tidy", "config", "requirements.txt"];
4343

44-
// this must be kept in sync with with .github/workflows/spellcheck.yml
4544
const SPELLCHECK_DIRS: &[&str] = &["compiler", "library", "src/bootstrap", "src/librustdoc"];
4645

4746
pub fn check(
@@ -51,6 +50,7 @@ pub fn check(
5150
librustdoc_path: &Path,
5251
tools_path: &Path,
5352
npm: &Path,
53+
cargo: &Path,
5454
bless: bool,
5555
extra_checks: Option<&str>,
5656
pos_args: &[String],
@@ -63,6 +63,7 @@ pub fn check(
6363
librustdoc_path,
6464
tools_path,
6565
npm,
66+
cargo,
6667
bless,
6768
extra_checks,
6869
pos_args,
@@ -78,6 +79,7 @@ fn check_impl(
7879
librustdoc_path: &Path,
7980
tools_path: &Path,
8081
npm: &Path,
82+
cargo: &Path,
8183
bless: bool,
8284
extra_checks: Option<&str>,
8385
pos_args: &[String],
@@ -293,7 +295,7 @@ fn check_impl(
293295
} else {
294296
eprintln!("spellcheck files");
295297
}
296-
spellcheck_runner(&args)?;
298+
spellcheck_runner(root_path, &outdir, &cargo, &args)?;
297299
}
298300

299301
if js_lint || js_typecheck {
@@ -576,34 +578,26 @@ fn shellcheck_runner(args: &[&OsStr]) -> Result<(), Error> {
576578
if status.success() { Ok(()) } else { Err(Error::FailedCheck("shellcheck")) }
577579
}
578580

579-
/// Check that spellchecker is installed then run it at the given path
580-
fn spellcheck_runner(args: &[&str]) -> Result<(), Error> {
581-
// sync version with .github/workflows/spellcheck.yml
582-
let expected_version = "typos-cli 1.34.0";
583-
match Command::new("typos").arg("--version").output() {
584-
Ok(o) => {
585-
let stdout = String::from_utf8_lossy(&o.stdout);
586-
if stdout.trim() != expected_version {
587-
return Err(Error::Version {
588-
program: "typos",
589-
required: expected_version,
590-
installed: stdout.trim().to_string(),
591-
});
581+
/// Ensure that spellchecker is installed then run it at the given path
582+
fn spellcheck_runner(
583+
src_root: &Path,
584+
outdir: &Path,
585+
cargo: &Path,
586+
args: &[&str],
587+
) -> Result<(), Error> {
588+
let bin_path =
589+
crate::ensure_version_or_cargo_install(outdir, cargo, "typos-cli", "typos", "1.34.0")?;
590+
591+
match Command::new(bin_path).current_dir(src_root).args(args).status() {
592+
Ok(status) => {
593+
if status.success() {
594+
Ok(())
595+
} else {
596+
Err(Error::FailedCheck("typos"))
592597
}
593598
}
594-
Err(e) if e.kind() == io::ErrorKind::NotFound => {
595-
return Err(Error::MissingReq(
596-
"typos",
597-
"spellcheck file checks",
598-
// sync version with .github/workflows/spellcheck.yml
599-
Some("install tool via `cargo install [email protected]`".to_owned()),
600-
));
601-
}
602-
Err(e) => return Err(e.into()),
599+
Err(err) => Err(Error::Generic(format!("failed to run typos tool: {err:?}"))),
603600
}
604-
605-
let status = Command::new("typos").args(args).status()?;
606-
if status.success() { Ok(()) } else { Err(Error::FailedCheck("typos")) }
607601
}
608602

609603
/// Check git for tracked files matching an extension

0 commit comments

Comments
 (0)