Repository: pest-parser/pest (language: rust)

Issue:
CI is still broken
This should just be applying some style fixes suggested by clippy:

<https://travis-ci.org/github/pest-parser/pest/jobs/740477199>


Discussion / hints:

Fix patch:
diff --git a/meta/src/optimizer/concatenator.rs b/meta/src/optimizer/concatenator.rs
index e0aab7bc..8ff7590c 100644
--- a/meta/src/optimizer/concatenator.rs
+++ b/meta/src/optimizer/concatenator.rs
@@ -10,25 +10,24 @@
 use ast::*;
 
 pub fn concatenate(rule: Rule) -> Rule {
-    match rule {
-        Rule { name, ty, expr } => Rule {
-            name,
-            ty,
-            expr: expr.map_bottom_up(|expr| {
-                if ty == RuleType::Atomic {
-                    // TODO: Use box syntax when it gets stabilized.
-                    match expr {
-                        Expr::Seq(lhs, rhs) => match (*lhs, *rhs) {
-                            (Expr::Str(lhs), Expr::Str(rhs)) => Expr::Str(lhs + &rhs),
-                            (Expr::Insens(lhs), Expr::Insens(rhs)) => Expr::Insens(lhs + &rhs),
-                            (lhs, rhs) => Expr::Seq(Box::new(lhs), Box::new(rhs)),
-                        },
-                        expr => expr,
-                    }
-                } else {
-                    expr
+    let Rule { name, ty, expr } = rule;
+    Rule {
+        name,
+        ty,
+        expr: expr.map_bottom_up(|expr| {
+            if ty == RuleType::Atomic {
+                // TODO: Use box syntax when it gets stabilized.
+                match expr {
+                    Expr::Seq(lhs, rhs) => match (*lhs, *rhs) {
+                        (Expr::Str(lhs), Expr::Str(rhs)) => Expr::Str(lhs + &rhs),
+                        (Expr::Insens(lhs), Expr::Insens(rhs)) => Expr::Insens(lhs + &rhs),
+                        (lhs, rhs) => Expr::Seq(Box::new(lhs), Box::new(rhs)),
+                    },
+                    expr => expr,
                 }
-            }),
-        },
+            } else {
+                expr
+            }
+        }),
     }
 }
diff --git a/meta/src/optimizer/factorizer.rs b/meta/src/optimizer/factorizer.rs
index 236289e1..dc1bab61 100644
--- a/meta/src/optimizer/factorizer.rs
+++ b/meta/src/optimizer/factorizer.rs
@@ -10,29 +10,25 @@
 use ast::*;
 
 pub fn factor(rule: Rule) -> Rule {
-    match rule {
-        Rule { name, ty, expr } => Rule {
-            name,
-            ty,
-            expr: expr.map_top_down(|expr| {
-                // TODO: Use box syntax when it gets stabilized.
-                match expr {
-                    Expr::Choice(lhs, rhs) => match (*lhs, *rhs) {
-                        (Expr::Seq(l1, r1), Expr::Seq(l2, r2)) => {
-                            if l1 == l2 {
-                                Expr::Seq(l1, Box::new(Expr::Choice(r1, r2)))
-                            } else {
-                                Expr::Choice(
-                                    Box::new(Expr::Seq(l1, r1)),
-                                    Box::new(Expr::Seq(l2, r2)),
-                                )
-                            }
+    let Rule { name, ty, expr } = rule;
+    Rule {
+        name,
+        ty,
+        expr: expr.map_top_down(|expr| {
+            // TODO: Use box syntax when it gets stabilized.
+            match expr {
+                Expr::Choice(lhs, rhs) => match (*lhs, *rhs) {
+                    (Expr::Seq(l1, r1), Expr::Seq(l2, r2)) => {
+                        if l1 == l2 {
+                            Expr::Seq(l1, Box::new(Expr::Choice(r1, r2)))
+                        } else {
+                            Expr::Choice(Box::new(Expr::Seq(l1, r1)), Box::new(Expr::Seq(l2, r2)))
                         }
-                        (lhs, rhs) => Expr::Choice(Box::new(lhs), Box::new(rhs)),
-                    },
-                    expr => expr,
-                }
-            }),
-        },
+                    }
+                    (lhs, rhs) => Expr::Choice(Box::new(lhs), Box::new(rhs)),
+                },
+                expr => expr,
+            }
+        }),
     }
 }
diff --git a/meta/src/optimizer/restorer.rs b/meta/src/optimizer/restorer.rs
index 34a710ea..fd67790e 100644
--- a/meta/src/optimizer/restorer.rs
+++ b/meta/src/optimizer/restorer.rs
@@ -14,13 +14,9 @@ pub fn restore_on_err(
     rule: OptimizedRule,
     rules: &HashMap<String, OptimizedExpr>,
 ) -> OptimizedRule {
-    match rule {
-        OptimizedRule { name, ty, expr } => {
-            let expr = expr.map_bottom_up(|expr| wrap_branching_exprs(expr, rules));
-
-            OptimizedRule { name, ty, expr }
-        }
-    }
+    let OptimizedRule { name, ty, expr } = rule;
+    let expr = expr.map_bottom_up(|expr| wrap_branching_exprs(expr, rules));
+    OptimizedRule { name, ty, expr }
 }
 
 fn wrap_branching_exprs(
diff --git a/meta/src/optimizer/rotater.rs b/meta/src/optimizer/rotater.rs
index 3588738a..f313ae06 100644
--- a/meta/src/optimizer/rotater.rs
+++ b/meta/src/optimizer/rotater.rs
@@ -35,11 +35,10 @@ pub fn rotate(rule: Rule) -> Rule {
         }
     }
 
-    match rule {
-        Rule { name, ty, expr } => Rule {
-            name,
-            ty,
-            expr: expr.map_top_down(rotate_internal),
-        },
+    let Rule { name, ty, expr } = rule;
+    Rule {
+        name,
+        ty,
+        expr: expr.map_top_down(rotate_internal),
     }
 }
diff --git a/meta/src/optimizer/skipper.rs b/meta/src/optimizer/skipper.rs
index f55edc06..cad31246 100644
--- a/meta/src/optimizer/skipper.rs
+++ b/meta/src/optimizer/skipper.rs
@@ -28,30 +28,29 @@ pub fn skip(rule: Rule) -> Rule {
         }
     }
 
-    match rule {
-        Rule { name, ty, expr } => Rule {
-            name,
-            ty,
-            expr: if ty == RuleType::Atomic {
-                expr.map_top_down(|expr| {
-                    // TODO: Use box syntax when it gets stabilized.
-                    if let Expr::Rep(expr) = expr.clone() {
-                        if let Expr::Seq(lhs, rhs) = *expr.clone() {
-                            if let (Expr::NegPred(expr), Expr::Ident(ident)) = (*lhs, *rhs) {
-                                if ident == "ANY" {
-                                    if let Some(expr) = populate_choices(*expr, vec![]) {
-                                        return expr;
-                                    }
+    let Rule { name, ty, expr } = rule;
+    Rule {
+        name,
+        ty,
+        expr: if ty == RuleType::Atomic {
+            expr.map_top_down(|expr| {
+                // TODO: Use box syntax when it gets stabilized.
+                if let Expr::Rep(expr) = expr.clone() {
+                    if let Expr::Seq(lhs, rhs) = *expr {
+                        if let (Expr::NegPred(expr), Expr::Ident(ident)) = (*lhs, *rhs) {
+                            if ident == "ANY" {
+                                if let Some(expr) = populate_choices(*expr, vec![]) {
+                                    return expr;
                                 }
                             }
                         }
-                    };
+                    }
+                };
 
-                    expr
-                })
-            } else {
                 expr
-            },
+            })
+        } else {
+            expr
         },
     }
 }
diff --git a/meta/src/optimizer/unroller.rs b/meta/src/optimizer/unroller.rs
index fff17336..b1e84e40 100644
--- a/meta/src/optimizer/unroller.rs
+++ b/meta/src/optimizer/unroller.rs
@@ -10,58 +10,57 @@
 use ast::*;
 
 pub fn unroll(rule: Rule) -> Rule {
-    match rule {
-        Rule { name, ty, expr } => Rule {
-            name,
-            ty,
-            expr: expr.map_bottom_up(|expr| match expr {
-                Expr::RepOnce(expr) => Expr::Seq(expr.clone(), Box::new(Expr::Rep(expr))),
-                Expr::RepExact(expr, num) => (1..num + 1)
-                    .map(|_| *expr.clone())
-                    .rev()
-                    .fold(None, |rep, expr| match rep {
-                        None => Some(expr),
-                        Some(rep) => Some(Expr::Seq(Box::new(expr), Box::new(rep))),
-                    })
-                    .unwrap(),
-                Expr::RepMin(expr, min) => (1..min + 2)
-                    .map(|i| {
-                        if i <= min {
-                            *expr.clone()
-                        } else {
-                            Expr::Rep(expr.clone())
-                        }
-                    })
-                    .rev()
-                    .fold(None, |rep, expr| match rep {
-                        None => Some(expr),
-                        Some(rep) => Some(Expr::Seq(Box::new(expr), Box::new(rep))),
-                    })
-                    .unwrap(),
-                Expr::RepMax(expr, max) => (1..max + 1)
-                    .map(|_| Expr::Opt(expr.clone()))
-                    .rev()
-                    .fold(None, |rep, expr| match rep {
-                        None => Some(expr),
-                        Some(rep) => Some(Expr::Seq(Box::new(expr), Box::new(rep))),
-                    })
-                    .unwrap(),
-                Expr::RepMinMax(expr, min, max) => (1..max + 1)
-                    .map(|i| {
-                        if i <= min {
-                            *expr.clone()
-                        } else {
-                            Expr::Opt(expr.clone())
-                        }
-                    })
-                    .rev()
-                    .fold(None, |rep, expr| match rep {
-                        None => Some(expr),
-                        Some(rep) => Some(Expr::Seq(Box::new(expr), Box::new(rep))),
-                    })
-                    .unwrap(),
-                expr => expr,
-            }),
-        },
+    let Rule { name, ty, expr } = rule;
+    Rule {
+        name,
+        ty,
+        expr: expr.map_bottom_up(|expr| match expr {
+            Expr::RepOnce(expr) => Expr::Seq(expr.clone(), Box::new(Expr::Rep(expr))),
+            Expr::RepExact(expr, num) => (1..num + 1)
+                .map(|_| *expr.clone())
+                .rev()
+                .fold(None, |rep, expr| match rep {
+                    None => Some(expr),
+                    Some(rep) => Some(Expr::Seq(Box::new(expr), Box::new(rep))),
+                })
+                .unwrap(),
+            Expr::RepMin(expr, min) => (1..min + 2)
+                .map(|i| {
+                    if i <= min {
+                        *expr.clone()
+                    } else {
+                        Expr::Rep(expr.clone())
+                    }
+                })
+                .rev()
+                .fold(None, |rep, expr| match rep {
+                    None => Some(expr),
+                    Some(rep) => Some(Expr::Seq(Box::new(expr), Box::new(rep))),
+                })
+                .unwrap(),
+            Expr::RepMax(expr, max) => (1..max + 1)
+                .map(|_| Expr::Opt(expr.clone()))
+                .rev()
+                .fold(None, |rep, expr| match rep {
+                    None => Some(expr),
+                    Some(rep) => Some(Expr::Seq(Box::new(expr), Box::new(rep))),
+                })
+                .unwrap(),
+            Expr::RepMinMax(expr, min, max) => (1..max + 1)
+                .map(|i| {
+                    if i <= min {
+                        *expr.clone()
+                    } else {
+                        Expr::Opt(expr.clone())
+                    }
+                })
+                .rev()
+                .fold(None, |rep, expr| match rep {
+                    None => Some(expr),
+                    Some(rep) => Some(Expr::Seq(Box::new(expr), Box::new(rep))),
+                })
+                .unwrap(),
+            expr => expr,
+        }),
     }
 }
diff --git a/meta/src/parser.rs b/meta/src/parser.rs
index 5f6f3b37..09d08719 100644
--- a/meta/src/parser.rs
+++ b/meta/src/parser.rs
@@ -125,13 +125,9 @@ pub enum ParserExpr<'i> {
 }
 
 fn convert_rule(rule: ParserRule) -> AstRule {
-    match rule {
-        ParserRule { name, ty, node, .. } => {
-            let expr = convert_node(node);
-
-            AstRule { name, ty, expr }
-        }
-    }
+    let ParserRule { name, ty, node, .. } = rule;
+    let expr = convert_node(node);
+    AstRule { name, ty, expr }
 }
 
 fn convert_node(node: ParserNode) -> Expr {
diff --git a/pest/src/position.rs b/pest/src/position.rs
index 76e3383b..0591b3e2 100644
--- a/pest/src/position.rs
+++ b/pest/src/position.rs
@@ -605,7 +605,7 @@ mod tests {
         let pos1 = Position::from_start(input1);
         let pos2 = Position::from_start(input2);
 
-        pos1.cmp(&pos2);
+        let _ = pos1.cmp(&pos2);
     }
 
     #[test]


Test patch: