@@ -91,6 +91,31 @@ declare_clippy_lint! {
91
91
"suspicious formatting of `else`"
92
92
}
93
93
94
+ declare_clippy_lint ! {
95
+ /// ### What it does
96
+ /// Checks for an `if` expression followed by either a block or another `if` that
97
+ /// looks like it should have an `else` between them.
98
+ ///
99
+ /// ### Why is this bad?
100
+ /// This is probably some refactoring remnant, even if the code is correct, it
101
+ /// might look confusing.
102
+ ///
103
+ /// ### Example
104
+ /// ```rust,ignore
105
+ /// if foo {
106
+ /// } { // looks like an `else` is missing here
107
+ /// }
108
+ ///
109
+ /// if foo {
110
+ /// } if bar { // looks like an `else` is missing here
111
+ /// }
112
+ /// ```
113
+ #[ clippy:: version = "1.90.0" ]
114
+ pub POSSIBLE_MISSING_ELSE ,
115
+ suspicious,
116
+ "possibly missing `else`"
117
+ }
118
+
94
119
declare_clippy_lint ! {
95
120
/// ### What it does
96
121
/// Checks for possible missing comma in an array. It lints if
@@ -116,6 +141,7 @@ declare_lint_pass!(Formatting => [
116
141
SUSPICIOUS_ASSIGNMENT_FORMATTING ,
117
142
SUSPICIOUS_UNARY_OP_FORMATTING ,
118
143
SUSPICIOUS_ELSE_FORMATTING ,
144
+ POSSIBLE_MISSING_ELSE ,
119
145
POSSIBLE_MISSING_COMMA
120
146
] ) ;
121
147
@@ -307,7 +333,7 @@ fn check_missing_else(cx: &EarlyContext<'_>, first: &Expr, second: &Expr) {
307
333
308
334
span_lint_and_note (
309
335
cx,
310
- SUSPICIOUS_ELSE_FORMATTING ,
336
+ POSSIBLE_MISSING_ELSE ,
311
337
else_span,
312
338
format ! ( "this looks like {looks_like} but the `else` is missing" ) ,
313
339
None ,
0 commit comments