Skip to content

Commit ae5d391

Browse files
committed
Remove LetChain
1 parent da93ee8 commit ae5d391

File tree

2 files changed

+1
-93
lines changed

2 files changed

+1
-93
lines changed

clippy_lints/src/len_zero.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ impl<'tcx> LateLintPass<'tcx> for LenZero {
170170
if let ExprKind::Let(lt) = expr.kind
171171
&& has_is_empty(cx, lt.init)
172172
&& match lt.pat.kind {
173-
PatKind::Slice([], _, []) => true,
173+
PatKind::Slice([], None, []) => true,
174174
PatKind::Lit(lit) if is_empty_string(lit) => true,
175175
_ => false,
176176
}

clippy_utils/src/higher.rs

-92
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use crate::consts::{constant_simple, Constant};
66
use crate::ty::is_type_diagnostic_item;
77
use crate::{is_expn_of, match_def_path, paths};
8-
use hir::BinOpKind;
98
use if_chain::if_chain;
109
use rustc_ast::ast;
1110
use rustc_hir as hir;
@@ -138,97 +137,6 @@ impl<'hir> IfLet<'hir> {
138137
}
139138
}
140139

141-
/// A `let` chain, like `if true && let Some(true) = x {}`
142-
#[derive(Debug)]
143-
pub struct LetChain<'hir> {
144-
pub conds: Vec<IfOrIfLetInChain<'hir>>,
145-
pub if_then: &'hir Expr<'hir>,
146-
pub if_else: Option<&'hir Expr<'hir>>,
147-
}
148-
149-
impl<'hir> LetChain<'hir> {
150-
pub fn hir(expr: &Expr<'hir>) -> Option<Self> {
151-
if let ExprKind::If(cond, if_then, if_else) = expr.kind {
152-
let mut conds = vec![];
153-
let mut cursor = cond;
154-
while let ExprKind::Binary(binop, lhs, rhs) = cursor.kind
155-
&& let BinOpKind::And = binop.node
156-
{
157-
cursor = lhs;
158-
conds.push(IfOrIfLetInChain::hir(rhs)?);
159-
}
160-
161-
// The final lhs cannot be `&&`
162-
conds.push(IfOrIfLetInChain::hir(cursor)?);
163-
164-
return Some(Self {
165-
conds,
166-
if_then,
167-
if_else,
168-
});
169-
}
170-
171-
None
172-
}
173-
}
174-
175-
/// An `if let` or `if` expression in a let chain.
176-
#[derive(Debug)]
177-
pub enum IfOrIfLetInChain<'hir> {
178-
If(IfInChain<'hir>),
179-
IfLet(IfLetInChain<'hir>),
180-
}
181-
182-
impl<'hir> IfOrIfLetInChain<'hir> {
183-
pub fn hir(expr: &Expr<'hir>) -> Option<Self> {
184-
match expr.kind {
185-
ExprKind::DropTemps(cond) => Some(IfInChain { cond }.into()),
186-
ExprKind::Let(hir::Let {
187-
pat: let_pat,
188-
init: let_expr,
189-
span: let_span,
190-
..
191-
}) => Some(
192-
IfLetInChain {
193-
let_pat,
194-
let_expr,
195-
let_span: *let_span,
196-
}
197-
.into(),
198-
),
199-
_ => None,
200-
}
201-
}
202-
}
203-
204-
impl<'hir> From<IfInChain<'hir>> for IfOrIfLetInChain<'hir> {
205-
fn from(value: IfInChain<'hir>) -> Self {
206-
Self::If(value)
207-
}
208-
}
209-
210-
impl<'hir> From<IfLetInChain<'hir>> for IfOrIfLetInChain<'hir> {
211-
fn from(value: IfLetInChain<'hir>) -> Self {
212-
Self::IfLet(value)
213-
}
214-
}
215-
216-
/// An `if` expression in a let chain.
217-
#[derive(Debug)]
218-
pub struct IfInChain<'hir> {
219-
pub cond: &'hir Expr<'hir>,
220-
}
221-
222-
/// An `if let` expression in a let chain.
223-
#[derive(Debug)]
224-
pub struct IfLetInChain<'hir> {
225-
pub let_span: Span,
226-
/// `if let` pattern
227-
pub let_pat: &'hir Pat<'hir>,
228-
/// `if let` scrutinee
229-
pub let_expr: &'hir Expr<'hir>,
230-
}
231-
232140
/// An `if let` or `match` expression. Useful for lints that trigger on one or the other.
233141
#[derive(Debug)]
234142
pub enum IfLetOrMatch<'hir> {

0 commit comments

Comments
 (0)