Skip to content

Commit cd507b1

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 b573fc6 + 2050a3b commit cd507b1

File tree

13 files changed

+100
-39
lines changed

13 files changed

+100
-39
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
@@ -866,7 +866,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
866866
}
867867
ImportKind::Glob { .. } => {
868868
// FIXME: Use mutable resolver directly as a hack, this should be an output of
869-
// specualtive resolution.
869+
// speculative resolution.
870870
self.get_mut_unchecked().resolve_glob_import(import);
871871
return 0;
872872
}
@@ -903,7 +903,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
903903
// We need the `target`, `source` can be extracted.
904904
let imported_binding = this.import(binding, import);
905905
// FIXME: Use mutable resolver directly as a hack, this should be an output of
906-
// specualtive resolution.
906+
// speculative resolution.
907907
this.get_mut_unchecked().define_binding_local(
908908
parent,
909909
target,
@@ -917,7 +917,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
917917
if target.name != kw::Underscore {
918918
let key = BindingKey::new(target, ns);
919919
// FIXME: Use mutable resolver directly as a hack, this should be an output of
920-
// specualtive resolution.
920+
// speculative resolution.
921921
this.get_mut_unchecked().update_local_resolution(
922922
parent,
923923
key,

compiler/rustc_resolve/src/late.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4270,7 +4270,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
42704270
if path.len() == 2
42714271
&& let [segment] = prefix_path
42724272
{
4273-
// Delay to check whether methond name is an associated function or not
4273+
// Delay to check whether method name is an associated function or not
42744274
// ```
42754275
// let foo = Foo {};
42764276
// 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

library/std/src/sys/pal/uefi/time.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ pub(crate) mod system_time_internal {
188188
Duration::new(epoch, t.nanosecond)
189189
}
190190

191-
/// This algorithm is a modifed version of the one described in the post:
191+
/// This algorithm is a modified version of the one described in the post:
192192
/// https://howardhinnant.github.io/date_algorithms.html#clive_from_days
193193
///
194194
/// The changes are to use 1900-01-01-00:00:00 with timezone -1440 as anchor instead of UNIX
@@ -197,7 +197,7 @@ pub(crate) mod system_time_internal {
197197
// Check timzone validity
198198
assert!(timezone <= 1440 && timezone >= -1440);
199199

200-
// FIXME(#126043): use checked_sub_signed once stablized
200+
// FIXME(#126043): use checked_sub_signed once stabilized
201201
let secs =
202202
dur.as_secs().checked_add_signed((-timezone as i64) * SECS_IN_MINUTE as i64).unwrap();
203203

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/tools/tidy/src/extra_checks/mod.rs

Lines changed: 20 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,25 @@ 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+
match Command::new(bin_path).current_dir(src_root).args(args).status() {
591+
Ok(status) => {
592+
if status.success() {
593+
Ok(())
594+
} else {
595+
Err(Error::FailedCheck("typos"))
592596
}
593597
}
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()),
598+
Err(err) => Err(Error::Generic(format!("failed to run typos tool: {err:?}"))),
603599
}
604-
605-
let status = Command::new("typos").args(args).status()?;
606-
if status.success() { Ok(()) } else { Err(Error::FailedCheck("typos")) }
607600
}
608601

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

0 commit comments

Comments
 (0)