Skip to content

Commit

Permalink
Auto merge of rust-lang#16469 - Young-Flash:ci_typos, r=lnicola
Browse files Browse the repository at this point in the history
internal: add typos check CI (part 2)

follow up rust-lang#16448
  • Loading branch information
bors committed Feb 2, 2024
2 parents 980d348 + a52a4d9 commit 8f6a728
Show file tree
Hide file tree
Showing 22 changed files with 450 additions and 208 deletions.
18 changes: 16 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,25 @@ jobs:
working-directory: ./editors/code
if: needs.changes.outputs.typescript == 'true'

typo-check:
name: Typo Check
runs-on: ubuntu-latest
timeout-minutes: 10
env:
FORCE_COLOR: 1
TYPOS_VERSION: v1.18.0
steps:
- name: download typos
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

- name: check for typos
run: typos

end-success:
name: bors build finished
if: github.event.pusher.name == 'bors' && success()
runs-on: ubuntu-latest
needs: [rust, rust-cross, typescript]
needs: [rust, rust-cross, typescript, typo-check]
steps:
- name: Mark the job as successful
run: exit 0
Expand All @@ -220,7 +234,7 @@ jobs:
name: bors build finished
if: github.event.pusher.name == 'bors' && !success()
runs-on: ubuntu-latest
needs: [rust, rust-cross, typescript]
needs: [rust, rust-cross, typescript, typo-check]
steps:
- name: Mark the job as a failure
run: exit 1
31 changes: 31 additions & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[default.extend-identifiers]
AnserStyle = "AnserStyle"
datas = "datas"
impl_froms = "impl_froms"
selfs = "selfs"

[default.extend-words]
anser = "anser"
ba = "ba"
fo = "fo"
ket = "ket"
makro = "makro"
raison = "raison"
trivias = "trivias"
TOOD = "TOOD"

[default]
extend-ignore-re = [
# ignore string which contains $x (x is a num), which use widely in test
".*\\$\\d.*",
# ignore generated content like `boxed....nner()`, `Defaul...efault`
"\\w*\\.{3,4}\\w*",
]

[files]
extend-exclude = [
"*.json",
"*.rast",
"crates/parser/test_data/lexer/err/*",
"bench_data/*",
]
6 changes: 3 additions & 3 deletions crates/hir-def/src/find_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::{
item_scope::ItemInNs,
nameres::DefMap,
path::{ModPath, PathKind},
visibility::{Visibility, VisibilityExplicity},
visibility::{Visibility, VisibilityExplicitness},
CrateRootModuleId, ModuleDefId, ModuleId,
};

Expand Down Expand Up @@ -544,11 +544,11 @@ fn find_local_import_locations(
if let Some((name, vis, declared)) = data.scope.name_of(item) {
if vis.is_visible_from(db, from) {
let is_pub_or_explicit = match vis {
Visibility::Module(_, VisibilityExplicity::Explicit) => {
Visibility::Module(_, VisibilityExplicitness::Explicit) => {
cov_mark::hit!(explicit_private_imports);
true
}
Visibility::Module(_, VisibilityExplicity::Implicit) => {
Visibility::Module(_, VisibilityExplicitness::Implicit) => {
cov_mark::hit!(discount_private_imports);
false
}
Expand Down
8 changes: 5 additions & 3 deletions crates/hir-def/src/item_scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use syntax::ast;
use crate::{
db::DefDatabase,
per_ns::PerNs,
visibility::{Visibility, VisibilityExplicity},
visibility::{Visibility, VisibilityExplicitness},
AdtId, BuiltinType, ConstId, ExternCrateId, HasModule, ImplId, LocalModuleId, Lookup, MacroId,
ModuleDefId, ModuleId, TraitId, UseId,
};
Expand Down Expand Up @@ -653,14 +653,16 @@ impl ItemScope {
.map(|(_, vis, _)| vis)
.chain(self.values.values_mut().map(|(_, vis, _)| vis))
.chain(self.unnamed_trait_imports.values_mut().map(|(vis, _)| vis))
.for_each(|vis| *vis = Visibility::Module(this_module, VisibilityExplicity::Implicit));
.for_each(|vis| {
*vis = Visibility::Module(this_module, VisibilityExplicitness::Implicit)
});

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

*vis = Visibility::Module(this_module, VisibilityExplicity::Implicit);
*vis = Visibility::Module(this_module, VisibilityExplicitness::Implicit);
}
}

Expand Down
12 changes: 6 additions & 6 deletions crates/hir-def/src/item_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ use crate::{
generics::{GenericParams, LifetimeParamData, TypeOrConstParamData},
path::{path, AssociatedTypeBinding, GenericArgs, ImportAlias, ModPath, Path, PathKind},
type_ref::{Mutability, TraitRef, TypeBound, TypeRef},
visibility::{RawVisibility, VisibilityExplicity},
visibility::{RawVisibility, VisibilityExplicitness},
BlockId, Lookup,
};

Expand Down Expand Up @@ -253,10 +253,10 @@ impl ItemVisibilities {
RawVisibility::Public => RawVisibilityId::PUB,
RawVisibility::Module(path, explicitiy) if path.segments().is_empty() => {
match (&path.kind, explicitiy) {
(PathKind::Super(0), VisibilityExplicity::Explicit) => {
(PathKind::Super(0), VisibilityExplicitness::Explicit) => {
RawVisibilityId::PRIV_EXPLICIT
}
(PathKind::Super(0), VisibilityExplicity::Implicit) => {
(PathKind::Super(0), VisibilityExplicitness::Implicit) => {
RawVisibilityId::PRIV_IMPLICIT
}
(PathKind::Crate, _) => RawVisibilityId::PUB_CRATE,
Expand All @@ -270,11 +270,11 @@ impl ItemVisibilities {

static VIS_PUB: RawVisibility = RawVisibility::Public;
static VIS_PRIV_IMPLICIT: RawVisibility =
RawVisibility::Module(ModPath::from_kind(PathKind::Super(0)), VisibilityExplicity::Implicit);
RawVisibility::Module(ModPath::from_kind(PathKind::Super(0)), VisibilityExplicitness::Implicit);
static VIS_PRIV_EXPLICIT: RawVisibility =
RawVisibility::Module(ModPath::from_kind(PathKind::Super(0)), VisibilityExplicity::Explicit);
RawVisibility::Module(ModPath::from_kind(PathKind::Super(0)), VisibilityExplicitness::Explicit);
static VIS_PUB_CRATE: RawVisibility =
RawVisibility::Module(ModPath::from_kind(PathKind::Crate), VisibilityExplicity::Explicit);
RawVisibility::Module(ModPath::from_kind(PathKind::Crate), VisibilityExplicitness::Explicit);

#[derive(Default, Debug, Eq, PartialEq)]
struct ItemTreeData {
Expand Down
4 changes: 2 additions & 2 deletions crates/hir-def/src/macro_expansion_tests/builtin_fn_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,13 +460,13 @@ fn test_concat_expand() {
#[rustc_builtin_macro]
macro_rules! concat {}
fn main() { concat!("foo", "r", 0, r#"bar"#, "\n", false, '"', '\0'); }
fn main() { concat!("fo", "o", 0, r#"bar"#, "\n", false, '"', '\0'); }
"##,
expect![[r##"
#[rustc_builtin_macro]
macro_rules! concat {}
fn main() { "foor0bar\nfalse\"\u{0}"; }
fn main() { "foo0bar\nfalse\"\u{0}"; }
"##]],
);
}
Expand Down
8 changes: 4 additions & 4 deletions crates/hir-def/src/macro_expansion_tests/mbe/regression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,11 +544,11 @@ fn test_proptest_arbitrary() {
check(
r#"
macro_rules! arbitrary {
([$($bounds : tt)*] $typ: ty, $strat: ty, $params: ty;
([$($bounds : tt)*] $typ: ty, $strategy: ty, $params: ty;
$args: ident => $logic: expr) => {
impl<$($bounds)*> $crate::arbitrary::Arbitrary for $typ {
type Parameters = $params;
type Strategy = $strat;
type Strategy = $strategy;
fn arbitrary_with($args: Self::Parameters) -> Self::Strategy {
$logic
}
Expand All @@ -569,11 +569,11 @@ arbitrary!(
"#,
expect![[r#"
macro_rules! arbitrary {
([$($bounds : tt)*] $typ: ty, $strat: ty, $params: ty;
([$($bounds : tt)*] $typ: ty, $strategy: ty, $params: ty;
$args: ident => $logic: expr) => {
impl<$($bounds)*> $crate::arbitrary::Arbitrary for $typ {
type Parameters = $params;
type Strategy = $strat;
type Strategy = $strategy;
fn arbitrary_with($args: Self::Parameters) -> Self::Strategy {
$logic
}
Expand Down
4 changes: 2 additions & 2 deletions crates/hir-def/src/nameres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ use crate::{
nameres::{diagnostics::DefDiagnostic, path_resolution::ResolveMode},
path::ModPath,
per_ns::PerNs,
visibility::{Visibility, VisibilityExplicity},
visibility::{Visibility, VisibilityExplicitness},
AstId, BlockId, BlockLoc, CrateRootModuleId, EnumId, EnumVariantId, ExternCrateId, FunctionId,
LocalModuleId, Lookup, MacroExpander, MacroId, ModuleId, ProcMacroId, UseId,
};
Expand Down Expand Up @@ -336,7 +336,7 @@ impl DefMap {
// this visibility for anything outside IDE, so that's probably OK.
let visibility = Visibility::Module(
ModuleId { krate, local_id, block: None },
VisibilityExplicity::Implicit,
VisibilityExplicitness::Implicit,
);
let module_data = ModuleData::new(
ModuleOrigin::BlockExpr { block: block.ast_id, id: block_id },
Expand Down
4 changes: 2 additions & 2 deletions crates/hir-def/src/nameres/path_resolution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ impl DefMap {
within_impl: bool,
) -> Option<Visibility> {
let mut vis = match visibility {
RawVisibility::Module(path, explicity) => {
RawVisibility::Module(path, explicitness) => {
let (result, remaining) =
self.resolve_path(db, original_module, path, BuiltinShadowMode::Module, None);
if remaining.is_some() {
return None;
}
let types = result.take_types()?;
match types {
ModuleDefId::ModuleId(m) => Visibility::Module(m, *explicity),
ModuleDefId::ModuleId(m) => Visibility::Module(m, *explicitness),
// error: visibility needs to refer to module
_ => {
return None;
Expand Down
21 changes: 12 additions & 9 deletions crates/hir-def/src/visibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@ use crate::{
pub enum RawVisibility {
/// `pub(in module)`, `pub(crate)` or `pub(super)`. Also private, which is
/// equivalent to `pub(self)`.
Module(ModPath, VisibilityExplicity),
Module(ModPath, VisibilityExplicitness),
/// `pub`.
Public,
}

impl RawVisibility {
pub(crate) const fn private() -> RawVisibility {
RawVisibility::Module(ModPath::from_kind(PathKind::Super(0)), VisibilityExplicity::Implicit)
RawVisibility::Module(
ModPath::from_kind(PathKind::Super(0)),
VisibilityExplicitness::Implicit,
)
}

pub(crate) fn from_ast(
Expand All @@ -53,19 +56,19 @@ impl RawVisibility {
None => return RawVisibility::private(),
Some(path) => path,
};
RawVisibility::Module(path, VisibilityExplicity::Explicit)
RawVisibility::Module(path, VisibilityExplicitness::Explicit)
}
ast::VisibilityKind::PubCrate => {
let path = ModPath::from_kind(PathKind::Crate);
RawVisibility::Module(path, VisibilityExplicity::Explicit)
RawVisibility::Module(path, VisibilityExplicitness::Explicit)
}
ast::VisibilityKind::PubSuper => {
let path = ModPath::from_kind(PathKind::Super(1));
RawVisibility::Module(path, VisibilityExplicity::Explicit)
RawVisibility::Module(path, VisibilityExplicitness::Explicit)
}
ast::VisibilityKind::PubSelf => {
let path = ModPath::from_kind(PathKind::Super(0));
RawVisibility::Module(path, VisibilityExplicity::Explicit)
RawVisibility::Module(path, VisibilityExplicitness::Explicit)
}
ast::VisibilityKind::Pub => RawVisibility::Public,
}
Expand All @@ -85,7 +88,7 @@ impl RawVisibility {
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum Visibility {
/// Visibility is restricted to a certain module.
Module(ModuleId, VisibilityExplicity),
Module(ModuleId, VisibilityExplicitness),
/// Visibility is unrestricted.
Public,
}
Expand Down Expand Up @@ -206,12 +209,12 @@ impl Visibility {

/// Whether the item was imported through `pub(crate) use` or just `use`.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum VisibilityExplicity {
pub enum VisibilityExplicitness {
Explicit,
Implicit,
}

impl VisibilityExplicity {
impl VisibilityExplicitness {
pub fn is_explicit(&self) -> bool {
matches!(self, Self::Explicit)
}
Expand Down
10 changes: 5 additions & 5 deletions crates/hir-expand/src/mod_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,13 +284,13 @@ fn convert_path(
}

fn convert_path_tt(db: &dyn ExpandDatabase, tt: &[tt::TokenTree]) -> Option<ModPath> {
let mut leafs = tt.iter().filter_map(|tt| match tt {
let mut leaves = tt.iter().filter_map(|tt| match tt {
tt::TokenTree::Leaf(leaf) => Some(leaf),
tt::TokenTree::Subtree(_) => None,
});
let mut segments = smallvec::smallvec![];
let kind = match leafs.next()? {
tt::Leaf::Punct(tt::Punct { char: ':', .. }) => match leafs.next()? {
let kind = match leaves.next()? {
tt::Leaf::Punct(tt::Punct { char: ':', .. }) => match leaves.next()? {
tt::Leaf::Punct(tt::Punct { char: ':', .. }) => PathKind::Abs,
_ => return None,
},
Expand All @@ -300,7 +300,7 @@ fn convert_path_tt(db: &dyn ExpandDatabase, tt: &[tt::TokenTree]) -> Option<ModP
tt::Leaf::Ident(tt::Ident { text, .. }) if text == "self" => PathKind::Super(0),
tt::Leaf::Ident(tt::Ident { text, .. }) if text == "super" => {
let mut deg = 1;
while let Some(tt::Leaf::Ident(tt::Ident { text, .. })) = leafs.next() {
while let Some(tt::Leaf::Ident(tt::Ident { text, .. })) = leaves.next() {
if text != "super" {
segments.push(Name::new_text_dont_use(text.clone()));
break;
Expand All @@ -316,7 +316,7 @@ fn convert_path_tt(db: &dyn ExpandDatabase, tt: &[tt::TokenTree]) -> Option<ModP
}
_ => return None,
};
segments.extend(leafs.filter_map(|leaf| match leaf {
segments.extend(leaves.filter_map(|leaf| match leaf {
::tt::Leaf::Ident(ident) => Some(Name::new_text_dont_use(ident.text.clone())),
_ => None,
}));
Expand Down
10 changes: 5 additions & 5 deletions crates/hir-ty/src/mir/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ pub enum MirLowerError {
MutatingRvalue,
UnresolvedLabel,
UnresolvedUpvar(Place),
UnaccessableLocal,
InaccessibleLocal,

// monomorphization errors:
GenericArgNotProvided(TypeOrConstParamId, Substitution),
Expand All @@ -116,7 +116,7 @@ impl DropScopeToken {
ctx.pop_drop_scope_internal(current, span)
}

/// It is useful when we want a drop scope is syntaxically closed, but we don't want to execute any drop
/// It is useful when we want a drop scope is syntactically closed, but we don't want to execute any drop
/// code. Either when the control flow is diverging (so drop code doesn't reached) or when drop is handled
/// for us (for example a block that ended with a return statement. Return will drop everything, so the block shouldn't
/// do anything)
Expand Down Expand Up @@ -186,7 +186,7 @@ impl MirLowerError {
| MirLowerError::UnsizedTemporary(_)
| MirLowerError::IncompleteExpr
| MirLowerError::IncompletePattern
| MirLowerError::UnaccessableLocal
| MirLowerError::InaccessibleLocal
| MirLowerError::TraitFunctionDefinition(_, _)
| MirLowerError::UnresolvedName(_)
| MirLowerError::RecordLiteralWithoutPath
Expand Down Expand Up @@ -1843,8 +1843,8 @@ impl<'ctx> MirLowerCtx<'ctx> {
None => {
// FIXME: It should never happens, but currently it will happen in `const_dependent_on_local` test, which
// is a hir lowering problem IMO.
// never!("Using unaccessable local for binding is always a bug");
Err(MirLowerError::UnaccessableLocal)
// never!("Using inaccessible local for binding is always a bug");
Err(MirLowerError::InaccessibleLocal)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/hir-ty/src/tests/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3424,7 +3424,7 @@ fn bin_op_with_rhs_is_self_for_assoc_bound() {
fn repro<T>(t: T) -> bool
where
T: Request,
T::Output: Convertable,
T::Output: Convertible,
{
let a = execute(&t).convert();
let b = execute(&t).convert();
Expand All @@ -3439,7 +3439,7 @@ where
{
<T as Request>::output()
}
trait Convertable {
trait Convertible {
type TraitSelf: PartialEq<Self::TraitSelf>;
type AssocAsDefaultSelf: PartialEq;
fn convert(self) -> Self::AssocAsDefaultSelf;
Expand Down
Loading

0 comments on commit 8f6a728

Please sign in to comment.