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