1
Fork 0

Fixing typos

This commit is contained in:
Andreas Deininger 2023-02-27 21:17:25 +01:00
parent 2742ac0748
commit 03a3f74365
9 changed files with 17 additions and 17 deletions

View file

@ -68,13 +68,13 @@ The second part of the motivation is clippy's dependence on unstable
compiler-internal data structures. Clippy lints are currently written against compiler-internal data structures. Clippy lints are currently written against
the compiler's AST / HIR which means that even small changes in these data the compiler's AST / HIR which means that even small changes in these data
structures might break a lot of lints. The second goal of this RFC is to **make structures might break a lot of lints. The second goal of this RFC is to **make
lints independant of the compiler's AST / HIR data structures**. lints independent of the compiler's AST / HIR data structures**.
# Approach # Approach
A lot of complexity in writing lints currently seems to come from having to A lot of complexity in writing lints currently seems to come from having to
manually implement the matching logic (see code samples above). It's an manually implement the matching logic (see code samples above). It's an
imparative style that describes *how* to match a syntax tree node instead of imperative style that describes *how* to match a syntax tree node instead of
specifying *what* should be matched against declaratively. In other areas, it's specifying *what* should be matched against declaratively. In other areas, it's
common to use declarative patterns to describe desired information and let the common to use declarative patterns to describe desired information and let the
implementation do the actual matching. A well-known example of this approach are implementation do the actual matching. A well-known example of this approach are
@ -270,7 +270,7 @@ pattern!{
// matches if expressions that **may or may not** have an else block // matches if expressions that **may or may not** have an else block
// Attn: `If(_, _, _)` matches only ifs that **have** an else block // Attn: `If(_, _, _)` matches only ifs that **have** an else block
// //
// | if with else block | if witout else block // | if with else block | if without else block
// If(_, _, _) | match | no match // If(_, _, _) | match | no match
// If(_, _, _?) | match | match // If(_, _, _?) | match | match
// If(_, _, ()) | no match | match // If(_, _, ()) | no match | match
@ -568,7 +568,7 @@ another example, `Array( Lit(_)* )` is a valid pattern because the parameter of
## The IsMatch Trait ## The IsMatch Trait
The pattern syntax and the *PatternTree* are independant of specific syntax tree The pattern syntax and the *PatternTree* are independent of specific syntax tree
implementations (rust ast / hir, syn, ...). When looking at the different implementations (rust ast / hir, syn, ...). When looking at the different
pattern examples in the previous sections, it can be seen that the patterns pattern examples in the previous sections, it can be seen that the patterns
don't contain any information specific to a certain syntax tree implementation. don't contain any information specific to a certain syntax tree implementation.
@ -717,7 +717,7 @@ if false {
#### Problems #### Problems
Extending Rust syntax (which is quite complex by itself) with additional syntax Extending Rust syntax (which is quite complex by itself) with additional syntax
needed for specifying patterns (alternations, sequences, repetisions, named needed for specifying patterns (alternations, sequences, repetitions, named
submatches, ...) might become difficult to read and really hard to parse submatches, ...) might become difficult to read and really hard to parse
properly. properly.
@ -858,7 +858,7 @@ would be evaluated as soon as the `Block(_)#then` was matched.
Another idea in this area would be to introduce a syntax for backreferences. Another idea in this area would be to introduce a syntax for backreferences.
They could be used to require that multiple parts of a pattern should match the They could be used to require that multiple parts of a pattern should match the
same value. For example, the `assign_op_pattern` lint that searches for `a = a same value. For example, the `assign_op_pattern` lint that searches for `a = a
op b` and recommends changing it to `a op= b` requires that both occurrances of op b` and recommends changing it to `a op= b` requires that both occurrences of
`a` are the same. Using `=#...` as syntax for backreferences, the lint could be `a` are the same. Using `=#...` as syntax for backreferences, the lint could be
implemented like this: implemented like this:
@ -882,7 +882,7 @@ least two return statements" could be a practical addition.
For patterns like "a literal that is not a boolean literal" one currently needs For patterns like "a literal that is not a boolean literal" one currently needs
to list all alternatives except the boolean case. Introducing a negation to list all alternatives except the boolean case. Introducing a negation
operator that allows to write `Lit(!Bool(_))` might be a good idea. This pattern operator that allows to write `Lit(!Bool(_))` might be a good idea. This pattern
would be eqivalent to `Lit( Char(_) | Int(_) )` (given that currently only three would be equivalent to `Lit( Char(_) | Int(_) )` (given that currently only three
literal types are implemented). literal types are implemented).
#### Functional composition #### Functional composition

View file

@ -22,7 +22,7 @@ pub(super) fn check_fn<'tcx>(cx: &LateContext<'_>, kind: &'tcx FnKind<'_>, body:
if let Some(gen_span) = generics.span_for_param_suggestion() { if let Some(gen_span) = generics.span_for_param_suggestion() {
diag.span_suggestion_with_style( diag.span_suggestion_with_style(
gen_span, gen_span,
"add a type paremeter", "add a type parameter",
format!(", {{ /* Generic name */ }}: {}", &param.name.ident().as_str()[5..]), format!(", {{ /* Generic name */ }}: {}", &param.name.ident().as_str()[5..]),
rustc_errors::Applicability::HasPlaceholders, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowAlways, rustc_errors::SuggestionStyle::ShowAlways,
@ -35,7 +35,7 @@ pub(super) fn check_fn<'tcx>(cx: &LateContext<'_>, kind: &'tcx FnKind<'_>, body:
ident.span.ctxt(), ident.span.ctxt(),
ident.span.parent(), ident.span.parent(),
), ),
"add a type paremeter", "add a type parameter",
format!("<{{ /* Generic name */ }}: {}>", &param.name.ident().as_str()[5..]), format!("<{{ /* Generic name */ }}: {}>", &param.name.ident().as_str()[5..]),
rustc_errors::Applicability::HasPlaceholders, rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowAlways, rustc_errors::SuggestionStyle::ShowAlways,

View file

@ -97,7 +97,7 @@ pub fn check_fn(cx: &LateContext<'_>, kind: FnKind<'_>, decl: &FnDecl<'_>, body:
let Some(correct_field) = correct_field else { let Some(correct_field) = correct_field else {
// There is no field corresponding to the getter name. // There is no field corresponding to the getter name.
// FIXME: This can be a false positive if the correct field is reachable trought deeper autodereferences than used_field is // FIXME: This can be a false positive if the correct field is reachable through deeper autodereferences than used_field is
return; return;
}; };

View file

@ -925,7 +925,7 @@ declare_clippy_lint! {
#[clippy::version = "1.66.0"] #[clippy::version = "1.66.0"]
pub MANUAL_FILTER, pub MANUAL_FILTER,
complexity, complexity,
"reimplentation of `filter`" "reimplementation of `filter`"
} }
#[derive(Default)] #[derive(Default)]

View file

@ -617,7 +617,7 @@ fn item_children_by_name(tcx: TyCtxt<'_>, def_id: DefId, name: Symbol) -> Vec<Re
/// Can return multiple resolutions when there are multiple versions of the same crate, e.g. /// Can return multiple resolutions when there are multiple versions of the same crate, e.g.
/// `memchr::memchr` could return the functions from both memchr 1.0 and memchr 2.0. /// `memchr::memchr` could return the functions from both memchr 1.0 and memchr 2.0.
/// ///
/// Also returns multiple results when there are mulitple paths under the same name e.g. `std::vec` /// Also returns multiple results when there are multiple paths under the same name e.g. `std::vec`
/// would have both a [`DefKind::Mod`] and [`DefKind::Macro`]. /// would have both a [`DefKind::Mod`] and [`DefKind::Macro`].
/// ///
/// This function is expensive and should be used sparingly. /// This function is expensive and should be used sparingly.

View file

@ -5,7 +5,7 @@ LL | pub fn a(_: impl Trait) {}
| ^^^^^^^^^^ | ^^^^^^^^^^
| |
= note: `-D clippy::impl-trait-in-params` implied by `-D warnings` = note: `-D clippy::impl-trait-in-params` implied by `-D warnings`
help: add a type paremeter help: add a type parameter
| |
LL | pub fn a<{ /* Generic name */ }: Trait>(_: impl Trait) {} LL | pub fn a<{ /* Generic name */ }: Trait>(_: impl Trait) {}
| +++++++++++++++++++++++++++++++ | +++++++++++++++++++++++++++++++
@ -16,7 +16,7 @@ error: '`impl Trait` used as a function parameter'
LL | pub fn c<C: Trait>(_: C, _: impl Trait) {} LL | pub fn c<C: Trait>(_: C, _: impl Trait) {}
| ^^^^^^^^^^ | ^^^^^^^^^^
| |
help: add a type paremeter help: add a type parameter
| |
LL | pub fn c<C: Trait, { /* Generic name */ }: Trait>(_: C, _: impl Trait) {} LL | pub fn c<C: Trait, { /* Generic name */ }: Trait>(_: C, _: impl Trait) {}
| +++++++++++++++++++++++++++++++ | +++++++++++++++++++++++++++++++

View file

@ -87,7 +87,7 @@ fn main() {
let kitten = Kitten {}; let kitten = Kitten {};
let _ = kitten.clone(); let _ = kitten.clone();
let _ = own_same_from_ref(&kitten); let _ = own_same_from_ref(&kitten);
// this shouln't lint // this shouldn't lint
let _ = kitten.to_vec(); let _ = kitten.to_vec();
// we expect no lints for this // we expect no lints for this

View file

@ -87,7 +87,7 @@ fn main() {
let kitten = Kitten {}; let kitten = Kitten {};
let _ = kitten.to_owned(); let _ = kitten.to_owned();
let _ = own_same_from_ref(&kitten); let _ = own_same_from_ref(&kitten);
// this shouln't lint // this shouldn't lint
let _ = kitten.to_vec(); let _ = kitten.to_vec();
// we expect no lints for this // we expect no lints for this

View file

@ -406,7 +406,7 @@ mod issue10041 {
struct Bomb; struct Bomb;
impl Bomb { impl Bomb {
// Hidden <Rhs = Self> default generic paramter. // Hidden <Rhs = Self> default generic parameter.
pub fn new() -> impl PartialOrd { pub fn new() -> impl PartialOrd {
0i32 0i32
} }