|
1 | 1 | use clippy_utils::diagnostics::span_lint_and_then; |
| 2 | +use clippy_utils::higher::IfLetOrMatch; |
2 | 3 | use clippy_utils::visitors::is_local_used; |
3 | | -use clippy_utils::{higher, is_lang_ctor, is_unit_expr, path_to_local, peel_ref_operators, SpanlessEq}; |
| 4 | +use clippy_utils::{is_lang_ctor, is_unit_expr, path_to_local, peel_ref_operators, SpanlessEq}; |
4 | 5 | use if_chain::if_chain; |
5 | 6 | use rustc_hir::LangItem::OptionNone; |
6 | | -use rustc_hir::{Arm, Expr, ExprKind, Guard, HirId, MatchSource, Pat, PatKind, StmtKind}; |
| 7 | +use rustc_hir::{Arm, Expr, ExprKind, Guard, HirId, Pat, PatKind, StmtKind}; |
7 | 8 | use rustc_lint::{LateContext, LateLintPass}; |
8 | 9 | use rustc_session::{declare_lint_pass, declare_tool_lint}; |
9 | 10 | use rustc_span::{MultiSpan, Span}; |
@@ -150,33 +151,6 @@ fn strip_singleton_blocks<'hir>(mut expr: &'hir Expr<'hir>) -> &'hir Expr<'hir> |
150 | 151 | expr |
151 | 152 | } |
152 | 153 |
|
153 | | -enum IfLetOrMatch<'hir> { |
154 | | - Match(&'hir Expr<'hir>, &'hir [Arm<'hir>], MatchSource), |
155 | | - /// scrutinee, pattern, then block, else block |
156 | | - IfLet( |
157 | | - &'hir Expr<'hir>, |
158 | | - &'hir Pat<'hir>, |
159 | | - &'hir Expr<'hir>, |
160 | | - Option<&'hir Expr<'hir>>, |
161 | | - ), |
162 | | -} |
163 | | - |
164 | | -impl<'hir> IfLetOrMatch<'hir> { |
165 | | - fn parse(cx: &LateContext<'_>, expr: &Expr<'hir>) -> Option<Self> { |
166 | | - match expr.kind { |
167 | | - ExprKind::Match(expr, arms, source) => Some(Self::Match(expr, arms, source)), |
168 | | - _ => higher::IfLet::hir(cx, expr).map( |
169 | | - |higher::IfLet { |
170 | | - let_expr, |
171 | | - let_pat, |
172 | | - if_then, |
173 | | - if_else, |
174 | | - }| { Self::IfLet(let_expr, let_pat, if_then, if_else) }, |
175 | | - ), |
176 | | - } |
177 | | - } |
178 | | -} |
179 | | - |
180 | 154 | /// A "wild-like" arm has a wild (`_`) or `None` pattern and no guard. Such arms can be "collapsed" |
181 | 155 | /// into a single wild arm without any significant loss in semantics or readability. |
182 | 156 | fn arm_is_wild_like(cx: &LateContext<'_>, arm: &Arm<'_>) -> bool { |
|
0 commit comments