about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCatherine Flores <catherine.3.flores@gmail.com>2023-07-22 05:57:39 -0500
committerCatherine Flores <catherine.3.flores@gmail.com>2023-07-22 06:15:02 -0500
commitae5d391d21fb227da007da44286e43ce61f10f38 (patch)
treeff008c2e4a9e8673ed480046fcb114de5c94b31f
parentda93ee86e5708cd991d7e21012ff2a2a980b0b2d (diff)
downloadrust-ae5d391d21fb227da007da44286e43ce61f10f38.tar.gz
rust-ae5d391d21fb227da007da44286e43ce61f10f38.zip
Remove `LetChain`
-rw-r--r--clippy_lints/src/len_zero.rs2
-rw-r--r--clippy_utils/src/higher.rs92
2 files changed, 1 insertions, 93 deletions
diff --git a/clippy_lints/src/len_zero.rs b/clippy_lints/src/len_zero.rs
index a707921ce7e..d4236926a6c 100644
--- a/clippy_lints/src/len_zero.rs
+++ b/clippy_lints/src/len_zero.rs
@@ -170,7 +170,7 @@ impl<'tcx> LateLintPass<'tcx> for LenZero {
         if let ExprKind::Let(lt) = expr.kind
             && has_is_empty(cx, lt.init)
             && match lt.pat.kind {
-                PatKind::Slice([], _, []) => true,
+                PatKind::Slice([], None, []) => true,
                 PatKind::Lit(lit) if is_empty_string(lit) => true,
                 _ => false,
             }
diff --git a/clippy_utils/src/higher.rs b/clippy_utils/src/higher.rs
index 312e6ea40c5..802adbd4d2d 100644
--- a/clippy_utils/src/higher.rs
+++ b/clippy_utils/src/higher.rs
@@ -5,7 +5,6 @@
 use crate::consts::{constant_simple, Constant};
 use crate::ty::is_type_diagnostic_item;
 use crate::{is_expn_of, match_def_path, paths};
-use hir::BinOpKind;
 use if_chain::if_chain;
 use rustc_ast::ast;
 use rustc_hir as hir;
@@ -138,97 +137,6 @@ impl<'hir> IfLet<'hir> {
     }
 }
 
-/// A `let` chain, like `if true && let Some(true) = x {}`
-#[derive(Debug)]
-pub struct LetChain<'hir> {
-    pub conds: Vec<IfOrIfLetInChain<'hir>>,
-    pub if_then: &'hir Expr<'hir>,
-    pub if_else: Option<&'hir Expr<'hir>>,
-}
-
-impl<'hir> LetChain<'hir> {
-    pub fn hir(expr: &Expr<'hir>) -> Option<Self> {
-        if let ExprKind::If(cond, if_then, if_else) = expr.kind {
-            let mut conds = vec![];
-            let mut cursor = cond;
-            while let ExprKind::Binary(binop, lhs, rhs) = cursor.kind
-                && let BinOpKind::And = binop.node
-            {
-                cursor = lhs;
-                conds.push(IfOrIfLetInChain::hir(rhs)?);
-            }
-
-            // The final lhs cannot be `&&`
-            conds.push(IfOrIfLetInChain::hir(cursor)?);
-
-            return Some(Self {
-                conds,
-                if_then,
-                if_else,
-            });
-        }
-
-        None
-    }
-}
-
-/// An `if let` or `if` expression in a let chain.
-#[derive(Debug)]
-pub enum IfOrIfLetInChain<'hir> {
-    If(IfInChain<'hir>),
-    IfLet(IfLetInChain<'hir>),
-}
-
-impl<'hir> IfOrIfLetInChain<'hir> {
-    pub fn hir(expr: &Expr<'hir>) -> Option<Self> {
-        match expr.kind {
-            ExprKind::DropTemps(cond) => Some(IfInChain { cond }.into()),
-            ExprKind::Let(hir::Let {
-                pat: let_pat,
-                init: let_expr,
-                span: let_span,
-                ..
-            }) => Some(
-                IfLetInChain {
-                    let_pat,
-                    let_expr,
-                    let_span: *let_span,
-                }
-                .into(),
-            ),
-            _ => None,
-        }
-    }
-}
-
-impl<'hir> From<IfInChain<'hir>> for IfOrIfLetInChain<'hir> {
-    fn from(value: IfInChain<'hir>) -> Self {
-        Self::If(value)
-    }
-}
-
-impl<'hir> From<IfLetInChain<'hir>> for IfOrIfLetInChain<'hir> {
-    fn from(value: IfLetInChain<'hir>) -> Self {
-        Self::IfLet(value)
-    }
-}
-
-/// An `if` expression in a let chain.
-#[derive(Debug)]
-pub struct IfInChain<'hir> {
-    pub cond: &'hir Expr<'hir>,
-}
-
-/// An `if let` expression in a let chain.
-#[derive(Debug)]
-pub struct IfLetInChain<'hir> {
-    pub let_span: Span,
-    /// `if let` pattern
-    pub let_pat: &'hir Pat<'hir>,
-    /// `if let` scrutinee
-    pub let_expr: &'hir Expr<'hir>,
-}
-
 /// An `if let` or `match` expression. Useful for lints that trigger on one or the other.
 #[derive(Debug)]
 pub enum IfLetOrMatch<'hir> {