]> git.lizzy.rs Git - rust.git/blob - src/docs/suspicious_else_formatting.txt
[Arithmetic] Consider literals
[rust.git] / src / docs / suspicious_else_formatting.txt
1 ### What it does
2 Checks for formatting of `else`. It lints if the `else`
3 is followed immediately by a newline or the `else` seems to be missing.
4
5 ### Why is this bad?
6 This is probably some refactoring remnant, even if the
7 code is correct, it might look confusing.
8
9 ### Example
10 ```
11 if foo {
12 } { // looks like an `else` is missing here
13 }
14
15 if foo {
16 } if bar { // looks like an `else` is missing here
17 }
18
19 if foo {
20 } else
21
22 { // this is the `else` block of the previous `if`, but should it be?
23 }
24
25 if foo {
26 } else
27
28 if bar { // this is the `else` block of the previous `if`, but should it be?
29 }
30 ```