Fixing typos
This commit is contained in:
parent
2742ac0748
commit
03a3f74365
@ -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
|
||||
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
|
||||
lints independant of the compiler's AST / HIR data structures**.
|
||||
lints independent of the compiler's AST / HIR data structures**.
|
||||
|
||||
# Approach
|
||||
|
||||
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
|
||||
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
|
||||
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
|
||||
@ -270,7 +270,7 @@ pattern!{
|
||||
// matches if expressions that **may or may not** 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 | 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 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
|
||||
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.
|
||||
@ -717,7 +717,7 @@ if false {
|
||||
#### Problems
|
||||
|
||||
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
|
||||
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.
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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).
|
||||
|
||||
#### Functional composition
|
||||
|
@ -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() {
|
||||
diag.span_suggestion_with_style(
|
||||
gen_span,
|
||||
"add a type paremeter",
|
||||
"add a type parameter",
|
||||
format!(", {{ /* Generic name */ }}: {}", ¶m.name.ident().as_str()[5..]),
|
||||
rustc_errors::Applicability::HasPlaceholders,
|
||||
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.parent(),
|
||||
),
|
||||
"add a type paremeter",
|
||||
"add a type parameter",
|
||||
format!("<{{ /* Generic name */ }}: {}>", ¶m.name.ident().as_str()[5..]),
|
||||
rustc_errors::Applicability::HasPlaceholders,
|
||||
rustc_errors::SuggestionStyle::ShowAlways,
|
||||
|
@ -97,7 +97,7 @@ pub fn check_fn(cx: &LateContext<'_>, kind: FnKind<'_>, decl: &FnDecl<'_>, body:
|
||||
|
||||
let Some(correct_field) = correct_field else {
|
||||
// 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;
|
||||
};
|
||||
|
||||
|
@ -925,7 +925,7 @@
|
||||
#[clippy::version = "1.66.0"]
|
||||
pub MANUAL_FILTER,
|
||||
complexity,
|
||||
"reimplentation of `filter`"
|
||||
"reimplementation of `filter`"
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
|
@ -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.
|
||||
/// `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`].
|
||||
///
|
||||
/// This function is expensive and should be used sparingly.
|
||||
|
@ -5,7 +5,7 @@ LL | pub fn a(_: impl Trait) {}
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= 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) {}
|
||||
| +++++++++++++++++++++++++++++++
|
||||
@ -16,7 +16,7 @@ error: '`impl Trait` used as a function parameter'
|
||||
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) {}
|
||||
| +++++++++++++++++++++++++++++++
|
||||
|
@ -87,7 +87,7 @@ fn main() {
|
||||
let kitten = Kitten {};
|
||||
let _ = kitten.clone();
|
||||
let _ = own_same_from_ref(&kitten);
|
||||
// this shouln't lint
|
||||
// this shouldn't lint
|
||||
let _ = kitten.to_vec();
|
||||
|
||||
// we expect no lints for this
|
||||
|
@ -87,7 +87,7 @@ fn main() {
|
||||
let kitten = Kitten {};
|
||||
let _ = kitten.to_owned();
|
||||
let _ = own_same_from_ref(&kitten);
|
||||
// this shouln't lint
|
||||
// this shouldn't lint
|
||||
let _ = kitten.to_vec();
|
||||
|
||||
// we expect no lints for this
|
||||
|
@ -406,7 +406,7 @@ mod issue10041 {
|
||||
struct Bomb;
|
||||
|
||||
impl Bomb {
|
||||
// Hidden <Rhs = Self> default generic paramter.
|
||||
// Hidden <Rhs = Self> default generic parameter.
|
||||
pub fn new() -> impl PartialOrd {
|
||||
0i32
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user