From d300ffc555e9c8879310471e27d458f00584ac41 Mon Sep 17 00:00:00 2001 From: matt rice Date: Tue, 21 Oct 2025 17:56:31 -0700 Subject: [PATCH] Fix clippy lints --- cfgrammar/src/lib/yacc/ast.rs | 2 +- lrlex/src/lib/ctbuilder.rs | 11 +++++------ lrpar/cttests/src/grmtools_section.test | 4 +--- lrpar/cttests/src/multi_start.y | 8 ++++---- lrpar/examples/calc_ast_arena/src/main.rs | 8 ++++---- 5 files changed, 15 insertions(+), 18 deletions(-) diff --git a/cfgrammar/src/lib/yacc/ast.rs b/cfgrammar/src/lib/yacc/ast.rs index cfca3310e..8672b3b71 100644 --- a/cfgrammar/src/lib/yacc/ast.rs +++ b/cfgrammar/src/lib/yacc/ast.rs @@ -825,7 +825,7 @@ mod test { "#; let astart_ast_validity = - ASTWithValidityInfo::new(YaccKind::Original(YaccOriginalActionKind::NoAction), &y_src); + ASTWithValidityInfo::new(YaccKind::Original(YaccOriginalActionKind::NoAction), y_src); let bstart_rule = astart_ast_validity.ast().get_rule("BStart").unwrap(); let bstart_ast_validity = astart_ast_validity .clone_and_change_start_rule(bstart_rule.clone()) diff --git a/lrlex/src/lib/ctbuilder.rs b/lrlex/src/lib/ctbuilder.rs index 61bd8fb76..044a04b08 100644 --- a/lrlex/src/lib/ctbuilder.rs +++ b/lrlex/src/lib/ctbuilder.rs @@ -321,9 +321,9 @@ where /// .lexer_in_src_dir("calc.l")? /// .build()?; /// ``` - pub fn lrpar_config(mut self, config_func: F) -> Self + pub fn lrpar_config(mut self, config_func: F) -> Self where - F: Fn(CTParserBuilder) -> CTParserBuilder, + F: Fn(CTParserBuilder) -> CTParserBuilder + 'a, { self.lrpar_config = Some(Box::new(config_func)); self @@ -1375,11 +1375,10 @@ impl CTTokenMapBuilder { )) }) .collect::>>()?; - let unused_annotation; - if self.allow_dead_code { - unused_annotation = quote! {#[allow(dead_code)]}; + let unused_annotation = if self.allow_dead_code { + quote! {#[allow(dead_code)]} } else { - unused_annotation = quote! {}; + quote! {} }; // Since the formatter doesn't preserve comments and we don't want to lose build time, // just format the module contents. diff --git a/lrpar/cttests/src/grmtools_section.test b/lrpar/cttests/src/grmtools_section.test index 616bc25c7..463eef14a 100644 --- a/lrpar/cttests/src/grmtools_section.test +++ b/lrpar/cttests/src/grmtools_section.test @@ -119,9 +119,7 @@ grammar: | array_seq -> Vec> : %empty { Vec::new() } | val { - let mut x = Vec::new(); - x.push($1); - x + vec![$1] } | array_seq ',' val { $1.push($3); diff --git a/lrpar/cttests/src/multi_start.y b/lrpar/cttests/src/multi_start.y index 69ac59d8b..e0fd045e9 100644 --- a/lrpar/cttests/src/multi_start.y +++ b/lrpar/cttests/src/multi_start.y @@ -4,10 +4,10 @@ %% AStart -> () - : A ':' BStart ';' {()} + : A ':' BStart ';' {} ; BStart -> () - : B ',' C {()} - | C ',' B {()} - ; \ No newline at end of file + : B ',' C {} + | C ',' B {} + ; diff --git a/lrpar/examples/calc_ast_arena/src/main.rs b/lrpar/examples/calc_ast_arena/src/main.rs index e711ae303..55596ad27 100644 --- a/lrpar/examples/calc_ast_arena/src/main.rs +++ b/lrpar/examples/calc_ast_arena/src/main.rs @@ -61,11 +61,11 @@ fn eval( e: &Expr, ) -> Result { match e { - Expr::Add { span, lhs, rhs } => eval(lexer, *lhs)? - .checked_add(eval(lexer, *rhs)?) + Expr::Add { span, lhs, rhs } => eval(lexer, lhs)? + .checked_add(eval(lexer, rhs)?) .ok_or((*span, "overflowed")), - Expr::Mul { span, lhs, rhs } => eval(lexer, *lhs)? - .checked_mul(eval(lexer, *rhs)?) + Expr::Mul { span, lhs, rhs } => eval(lexer, lhs)? + .checked_mul(eval(lexer, rhs)?) .ok_or((*span, "overflowed")), Expr::Number { span } => lexer .span_str(*span)