Skip to content

Commit 8f6a728

Browse files
committed
Auto merge of rust-lang#16469 - Young-Flash:ci_typos, r=lnicola
internal: add typos check CI (part 2) follow up rust-lang/rust-analyzer#16448
2 parents 980d348 + a52a4d9 commit 8f6a728

File tree

22 files changed

+450
-208
lines changed

22 files changed

+450
-208
lines changed

.github/workflows/ci.yaml

+16-2
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,25 @@ jobs:
207207
working-directory: ./editors/code
208208
if: needs.changes.outputs.typescript == 'true'
209209

210+
typo-check:
211+
name: Typo Check
212+
runs-on: ubuntu-latest
213+
timeout-minutes: 10
214+
env:
215+
FORCE_COLOR: 1
216+
TYPOS_VERSION: v1.18.0
217+
steps:
218+
- name: download typos
219+
run: curl -LsSf https://github.com/crate-ci/typos/releases/download/$TYPOS_VERSION/typos-$TYPOS_VERSION-x86_64-unknown-linux-musl.tar.gz | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin
220+
221+
- name: check for typos
222+
run: typos
223+
210224
end-success:
211225
name: bors build finished
212226
if: github.event.pusher.name == 'bors' && success()
213227
runs-on: ubuntu-latest
214-
needs: [rust, rust-cross, typescript]
228+
needs: [rust, rust-cross, typescript, typo-check]
215229
steps:
216230
- name: Mark the job as successful
217231
run: exit 0
@@ -220,7 +234,7 @@ jobs:
220234
name: bors build finished
221235
if: github.event.pusher.name == 'bors' && !success()
222236
runs-on: ubuntu-latest
223-
needs: [rust, rust-cross, typescript]
237+
needs: [rust, rust-cross, typescript, typo-check]
224238
steps:
225239
- name: Mark the job as a failure
226240
run: exit 1

.typos.toml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[default.extend-identifiers]
2+
AnserStyle = "AnserStyle"
3+
datas = "datas"
4+
impl_froms = "impl_froms"
5+
selfs = "selfs"
6+
7+
[default.extend-words]
8+
anser = "anser"
9+
ba = "ba"
10+
fo = "fo"
11+
ket = "ket"
12+
makro = "makro"
13+
raison = "raison"
14+
trivias = "trivias"
15+
TOOD = "TOOD"
16+
17+
[default]
18+
extend-ignore-re = [
19+
# ignore string which contains $x (x is a num), which use widely in test
20+
".*\\$\\d.*",
21+
# ignore generated content like `boxed....nner()`, `Defaul...efault`
22+
"\\w*\\.{3,4}\\w*",
23+
]
24+
25+
[files]
26+
extend-exclude = [
27+
"*.json",
28+
"*.rast",
29+
"crates/parser/test_data/lexer/err/*",
30+
"bench_data/*",
31+
]

crates/hir-def/src/find_path.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::{
1313
item_scope::ItemInNs,
1414
nameres::DefMap,
1515
path::{ModPath, PathKind},
16-
visibility::{Visibility, VisibilityExplicity},
16+
visibility::{Visibility, VisibilityExplicitness},
1717
CrateRootModuleId, ModuleDefId, ModuleId,
1818
};
1919

@@ -544,11 +544,11 @@ fn find_local_import_locations(
544544
if let Some((name, vis, declared)) = data.scope.name_of(item) {
545545
if vis.is_visible_from(db, from) {
546546
let is_pub_or_explicit = match vis {
547-
Visibility::Module(_, VisibilityExplicity::Explicit) => {
547+
Visibility::Module(_, VisibilityExplicitness::Explicit) => {
548548
cov_mark::hit!(explicit_private_imports);
549549
true
550550
}
551-
Visibility::Module(_, VisibilityExplicity::Implicit) => {
551+
Visibility::Module(_, VisibilityExplicitness::Implicit) => {
552552
cov_mark::hit!(discount_private_imports);
553553
false
554554
}

crates/hir-def/src/item_scope.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use syntax::ast;
1717
use crate::{
1818
db::DefDatabase,
1919
per_ns::PerNs,
20-
visibility::{Visibility, VisibilityExplicity},
20+
visibility::{Visibility, VisibilityExplicitness},
2121
AdtId, BuiltinType, ConstId, ExternCrateId, HasModule, ImplId, LocalModuleId, Lookup, MacroId,
2222
ModuleDefId, ModuleId, TraitId, UseId,
2323
};
@@ -653,14 +653,16 @@ impl ItemScope {
653653
.map(|(_, vis, _)| vis)
654654
.chain(self.values.values_mut().map(|(_, vis, _)| vis))
655655
.chain(self.unnamed_trait_imports.values_mut().map(|(vis, _)| vis))
656-
.for_each(|vis| *vis = Visibility::Module(this_module, VisibilityExplicity::Implicit));
656+
.for_each(|vis| {
657+
*vis = Visibility::Module(this_module, VisibilityExplicitness::Implicit)
658+
});
657659

658660
for (mac, vis, import) in self.macros.values_mut() {
659661
if matches!(mac, MacroId::ProcMacroId(_) if import.is_none()) {
660662
continue;
661663
}
662664

663-
*vis = Visibility::Module(this_module, VisibilityExplicity::Implicit);
665+
*vis = Visibility::Module(this_module, VisibilityExplicitness::Implicit);
664666
}
665667
}
666668

crates/hir-def/src/item_tree.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ use crate::{
6969
generics::{GenericParams, LifetimeParamData, TypeOrConstParamData},
7070
path::{path, AssociatedTypeBinding, GenericArgs, ImportAlias, ModPath, Path, PathKind},
7171
type_ref::{Mutability, TraitRef, TypeBound, TypeRef},
72-
visibility::{RawVisibility, VisibilityExplicity},
72+
visibility::{RawVisibility, VisibilityExplicitness},
7373
BlockId, Lookup,
7474
};
7575

@@ -253,10 +253,10 @@ impl ItemVisibilities {
253253
RawVisibility::Public => RawVisibilityId::PUB,
254254
RawVisibility::Module(path, explicitiy) if path.segments().is_empty() => {
255255
match (&path.kind, explicitiy) {
256-
(PathKind::Super(0), VisibilityExplicity::Explicit) => {
256+
(PathKind::Super(0), VisibilityExplicitness::Explicit) => {
257257
RawVisibilityId::PRIV_EXPLICIT
258258
}
259-
(PathKind::Super(0), VisibilityExplicity::Implicit) => {
259+
(PathKind::Super(0), VisibilityExplicitness::Implicit) => {
260260
RawVisibilityId::PRIV_IMPLICIT
261261
}
262262
(PathKind::Crate, _) => RawVisibilityId::PUB_CRATE,
@@ -270,11 +270,11 @@ impl ItemVisibilities {
270270

271271
static VIS_PUB: RawVisibility = RawVisibility::Public;
272272
static VIS_PRIV_IMPLICIT: RawVisibility =
273-
RawVisibility::Module(ModPath::from_kind(PathKind::Super(0)), VisibilityExplicity::Implicit);
273+
RawVisibility::Module(ModPath::from_kind(PathKind::Super(0)), VisibilityExplicitness::Implicit);
274274
static VIS_PRIV_EXPLICIT: RawVisibility =
275-
RawVisibility::Module(ModPath::from_kind(PathKind::Super(0)), VisibilityExplicity::Explicit);
275+
RawVisibility::Module(ModPath::from_kind(PathKind::Super(0)), VisibilityExplicitness::Explicit);
276276
static VIS_PUB_CRATE: RawVisibility =
277-
RawVisibility::Module(ModPath::from_kind(PathKind::Crate), VisibilityExplicity::Explicit);
277+
RawVisibility::Module(ModPath::from_kind(PathKind::Crate), VisibilityExplicitness::Explicit);
278278

279279
#[derive(Default, Debug, Eq, PartialEq)]
280280
struct ItemTreeData {

crates/hir-def/src/macro_expansion_tests/builtin_fn_macro.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -460,13 +460,13 @@ fn test_concat_expand() {
460460
#[rustc_builtin_macro]
461461
macro_rules! concat {}
462462
463-
fn main() { concat!("foo", "r", 0, r#"bar"#, "\n", false, '"', '\0'); }
463+
fn main() { concat!("fo", "o", 0, r#"bar"#, "\n", false, '"', '\0'); }
464464
"##,
465465
expect![[r##"
466466
#[rustc_builtin_macro]
467467
macro_rules! concat {}
468468
469-
fn main() { "foor0bar\nfalse\"\u{0}"; }
469+
fn main() { "foo0bar\nfalse\"\u{0}"; }
470470
"##]],
471471
);
472472
}

crates/hir-def/src/macro_expansion_tests/mbe/regression.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -544,11 +544,11 @@ fn test_proptest_arbitrary() {
544544
check(
545545
r#"
546546
macro_rules! arbitrary {
547-
([$($bounds : tt)*] $typ: ty, $strat: ty, $params: ty;
547+
([$($bounds : tt)*] $typ: ty, $strategy: ty, $params: ty;
548548
$args: ident => $logic: expr) => {
549549
impl<$($bounds)*> $crate::arbitrary::Arbitrary for $typ {
550550
type Parameters = $params;
551-
type Strategy = $strat;
551+
type Strategy = $strategy;
552552
fn arbitrary_with($args: Self::Parameters) -> Self::Strategy {
553553
$logic
554554
}
@@ -569,11 +569,11 @@ arbitrary!(
569569
"#,
570570
expect![[r#"
571571
macro_rules! arbitrary {
572-
([$($bounds : tt)*] $typ: ty, $strat: ty, $params: ty;
572+
([$($bounds : tt)*] $typ: ty, $strategy: ty, $params: ty;
573573
$args: ident => $logic: expr) => {
574574
impl<$($bounds)*> $crate::arbitrary::Arbitrary for $typ {
575575
type Parameters = $params;
576-
type Strategy = $strat;
576+
type Strategy = $strategy;
577577
fn arbitrary_with($args: Self::Parameters) -> Self::Strategy {
578578
$logic
579579
}

crates/hir-def/src/nameres.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ use crate::{
7979
nameres::{diagnostics::DefDiagnostic, path_resolution::ResolveMode},
8080
path::ModPath,
8181
per_ns::PerNs,
82-
visibility::{Visibility, VisibilityExplicity},
82+
visibility::{Visibility, VisibilityExplicitness},
8383
AstId, BlockId, BlockLoc, CrateRootModuleId, EnumId, EnumVariantId, ExternCrateId, FunctionId,
8484
LocalModuleId, Lookup, MacroExpander, MacroId, ModuleId, ProcMacroId, UseId,
8585
};
@@ -336,7 +336,7 @@ impl DefMap {
336336
// this visibility for anything outside IDE, so that's probably OK.
337337
let visibility = Visibility::Module(
338338
ModuleId { krate, local_id, block: None },
339-
VisibilityExplicity::Implicit,
339+
VisibilityExplicitness::Implicit,
340340
);
341341
let module_data = ModuleData::new(
342342
ModuleOrigin::BlockExpr { block: block.ast_id, id: block_id },

crates/hir-def/src/nameres/path_resolution.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,15 @@ impl DefMap {
8787
within_impl: bool,
8888
) -> Option<Visibility> {
8989
let mut vis = match visibility {
90-
RawVisibility::Module(path, explicity) => {
90+
RawVisibility::Module(path, explicitness) => {
9191
let (result, remaining) =
9292
self.resolve_path(db, original_module, path, BuiltinShadowMode::Module, None);
9393
if remaining.is_some() {
9494
return None;
9595
}
9696
let types = result.take_types()?;
9797
match types {
98-
ModuleDefId::ModuleId(m) => Visibility::Module(m, *explicity),
98+
ModuleDefId::ModuleId(m) => Visibility::Module(m, *explicitness),
9999
// error: visibility needs to refer to module
100100
_ => {
101101
return None;

crates/hir-def/src/visibility.rs

+12-9
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,17 @@ use crate::{
2020
pub enum RawVisibility {
2121
/// `pub(in module)`, `pub(crate)` or `pub(super)`. Also private, which is
2222
/// equivalent to `pub(self)`.
23-
Module(ModPath, VisibilityExplicity),
23+
Module(ModPath, VisibilityExplicitness),
2424
/// `pub`.
2525
Public,
2626
}
2727

2828
impl RawVisibility {
2929
pub(crate) const fn private() -> RawVisibility {
30-
RawVisibility::Module(ModPath::from_kind(PathKind::Super(0)), VisibilityExplicity::Implicit)
30+
RawVisibility::Module(
31+
ModPath::from_kind(PathKind::Super(0)),
32+
VisibilityExplicitness::Implicit,
33+
)
3134
}
3235

3336
pub(crate) fn from_ast(
@@ -53,19 +56,19 @@ impl RawVisibility {
5356
None => return RawVisibility::private(),
5457
Some(path) => path,
5558
};
56-
RawVisibility::Module(path, VisibilityExplicity::Explicit)
59+
RawVisibility::Module(path, VisibilityExplicitness::Explicit)
5760
}
5861
ast::VisibilityKind::PubCrate => {
5962
let path = ModPath::from_kind(PathKind::Crate);
60-
RawVisibility::Module(path, VisibilityExplicity::Explicit)
63+
RawVisibility::Module(path, VisibilityExplicitness::Explicit)
6164
}
6265
ast::VisibilityKind::PubSuper => {
6366
let path = ModPath::from_kind(PathKind::Super(1));
64-
RawVisibility::Module(path, VisibilityExplicity::Explicit)
67+
RawVisibility::Module(path, VisibilityExplicitness::Explicit)
6568
}
6669
ast::VisibilityKind::PubSelf => {
6770
let path = ModPath::from_kind(PathKind::Super(0));
68-
RawVisibility::Module(path, VisibilityExplicity::Explicit)
71+
RawVisibility::Module(path, VisibilityExplicitness::Explicit)
6972
}
7073
ast::VisibilityKind::Pub => RawVisibility::Public,
7174
}
@@ -85,7 +88,7 @@ impl RawVisibility {
8588
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
8689
pub enum Visibility {
8790
/// Visibility is restricted to a certain module.
88-
Module(ModuleId, VisibilityExplicity),
91+
Module(ModuleId, VisibilityExplicitness),
8992
/// Visibility is unrestricted.
9093
Public,
9194
}
@@ -206,12 +209,12 @@ impl Visibility {
206209

207210
/// Whether the item was imported through `pub(crate) use` or just `use`.
208211
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
209-
pub enum VisibilityExplicity {
212+
pub enum VisibilityExplicitness {
210213
Explicit,
211214
Implicit,
212215
}
213216

214-
impl VisibilityExplicity {
217+
impl VisibilityExplicitness {
215218
pub fn is_explicit(&self) -> bool {
216219
matches!(self, Self::Explicit)
217220
}

crates/hir-expand/src/mod_path.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -284,13 +284,13 @@ fn convert_path(
284284
}
285285

286286
fn convert_path_tt(db: &dyn ExpandDatabase, tt: &[tt::TokenTree]) -> Option<ModPath> {
287-
let mut leafs = tt.iter().filter_map(|tt| match tt {
287+
let mut leaves = tt.iter().filter_map(|tt| match tt {
288288
tt::TokenTree::Leaf(leaf) => Some(leaf),
289289
tt::TokenTree::Subtree(_) => None,
290290
});
291291
let mut segments = smallvec::smallvec![];
292-
let kind = match leafs.next()? {
293-
tt::Leaf::Punct(tt::Punct { char: ':', .. }) => match leafs.next()? {
292+
let kind = match leaves.next()? {
293+
tt::Leaf::Punct(tt::Punct { char: ':', .. }) => match leaves.next()? {
294294
tt::Leaf::Punct(tt::Punct { char: ':', .. }) => PathKind::Abs,
295295
_ => return None,
296296
},
@@ -300,7 +300,7 @@ fn convert_path_tt(db: &dyn ExpandDatabase, tt: &[tt::TokenTree]) -> Option<ModP
300300
tt::Leaf::Ident(tt::Ident { text, .. }) if text == "self" => PathKind::Super(0),
301301
tt::Leaf::Ident(tt::Ident { text, .. }) if text == "super" => {
302302
let mut deg = 1;
303-
while let Some(tt::Leaf::Ident(tt::Ident { text, .. })) = leafs.next() {
303+
while let Some(tt::Leaf::Ident(tt::Ident { text, .. })) = leaves.next() {
304304
if text != "super" {
305305
segments.push(Name::new_text_dont_use(text.clone()));
306306
break;
@@ -316,7 +316,7 @@ fn convert_path_tt(db: &dyn ExpandDatabase, tt: &[tt::TokenTree]) -> Option<ModP
316316
}
317317
_ => return None,
318318
};
319-
segments.extend(leafs.filter_map(|leaf| match leaf {
319+
segments.extend(leaves.filter_map(|leaf| match leaf {
320320
::tt::Leaf::Ident(ident) => Some(Name::new_text_dont_use(ident.text.clone())),
321321
_ => None,
322322
}));

crates/hir-ty/src/mir/lower.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ pub enum MirLowerError {
9797
MutatingRvalue,
9898
UnresolvedLabel,
9999
UnresolvedUpvar(Place),
100-
UnaccessableLocal,
100+
InaccessibleLocal,
101101

102102
// monomorphization errors:
103103
GenericArgNotProvided(TypeOrConstParamId, Substitution),
@@ -116,7 +116,7 @@ impl DropScopeToken {
116116
ctx.pop_drop_scope_internal(current, span)
117117
}
118118

119-
/// It is useful when we want a drop scope is syntaxically closed, but we don't want to execute any drop
119+
/// It is useful when we want a drop scope is syntactically closed, but we don't want to execute any drop
120120
/// code. Either when the control flow is diverging (so drop code doesn't reached) or when drop is handled
121121
/// for us (for example a block that ended with a return statement. Return will drop everything, so the block shouldn't
122122
/// do anything)
@@ -186,7 +186,7 @@ impl MirLowerError {
186186
| MirLowerError::UnsizedTemporary(_)
187187
| MirLowerError::IncompleteExpr
188188
| MirLowerError::IncompletePattern
189-
| MirLowerError::UnaccessableLocal
189+
| MirLowerError::InaccessibleLocal
190190
| MirLowerError::TraitFunctionDefinition(_, _)
191191
| MirLowerError::UnresolvedName(_)
192192
| MirLowerError::RecordLiteralWithoutPath
@@ -1843,8 +1843,8 @@ impl<'ctx> MirLowerCtx<'ctx> {
18431843
None => {
18441844
// FIXME: It should never happens, but currently it will happen in `const_dependent_on_local` test, which
18451845
// is a hir lowering problem IMO.
1846-
// never!("Using unaccessable local for binding is always a bug");
1847-
Err(MirLowerError::UnaccessableLocal)
1846+
// never!("Using inaccessible local for binding is always a bug");
1847+
Err(MirLowerError::InaccessibleLocal)
18481848
}
18491849
}
18501850
}

crates/hir-ty/src/tests/traits.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3424,7 +3424,7 @@ fn bin_op_with_rhs_is_self_for_assoc_bound() {
34243424
fn repro<T>(t: T) -> bool
34253425
where
34263426
T: Request,
3427-
T::Output: Convertable,
3427+
T::Output: Convertible,
34283428
{
34293429
let a = execute(&t).convert();
34303430
let b = execute(&t).convert();
@@ -3439,7 +3439,7 @@ where
34393439
{
34403440
<T as Request>::output()
34413441
}
3442-
trait Convertable {
3442+
trait Convertible {
34433443
type TraitSelf: PartialEq<Self::TraitSelf>;
34443444
type AssocAsDefaultSelf: PartialEq;
34453445
fn convert(self) -> Self::AssocAsDefaultSelf;

0 commit comments

Comments
 (0)