@@ -91,6 +91,31 @@ declare_clippy_lint! {
9191 "suspicious formatting of `else`"
9292}
9393
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+
94119declare_clippy_lint ! {
95120 /// ### What it does
96121 /// Checks for possible missing comma in an array. It lints if
@@ -116,6 +141,7 @@ declare_lint_pass!(Formatting => [
116141 SUSPICIOUS_ASSIGNMENT_FORMATTING ,
117142 SUSPICIOUS_UNARY_OP_FORMATTING ,
118143 SUSPICIOUS_ELSE_FORMATTING ,
144+ POSSIBLE_MISSING_ELSE ,
119145 POSSIBLE_MISSING_COMMA
120146] ) ;
121147
@@ -307,7 +333,7 @@ fn check_missing_else(cx: &EarlyContext<'_>, first: &Expr, second: &Expr) {
307333
308334 span_lint_and_note (
309335 cx,
310- SUSPICIOUS_ELSE_FORMATTING ,
336+ POSSIBLE_MISSING_ELSE ,
311337 else_span,
312338 format ! ( "this looks like {looks_like} but the `else` is missing" ) ,
313339 None ,
0 commit comments