Skip to content

Commit e7bf186

Browse files
authored
fix new rust 1.87 cargo clippy warnings (#1856)
1 parent ae587dc commit e7bf186

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

src/ast/visitor.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -741,15 +741,16 @@ mod tests {
741741
}
742742
}
743743

744-
fn do_visit<V: Visitor>(sql: &str, visitor: &mut V) -> Statement {
744+
fn do_visit<V: Visitor<Break = ()>>(sql: &str, visitor: &mut V) -> Statement {
745745
let dialect = GenericDialect {};
746746
let tokens = Tokenizer::new(&dialect, sql).tokenize().unwrap();
747747
let s = Parser::new(&dialect)
748748
.with_tokens(tokens)
749749
.parse_statement()
750750
.unwrap();
751751

752-
s.visit(visitor);
752+
let flow = s.visit(visitor);
753+
assert_eq!(flow, ControlFlow::Continue(()));
753754
s
754755
}
755756

@@ -938,7 +939,8 @@ mod tests {
938939
.unwrap();
939940

940941
let mut visitor = QuickVisitor {};
941-
s.visit(&mut visitor);
942+
let flow = s.visit(&mut visitor);
943+
assert_eq!(flow, ControlFlow::Continue(()));
942944
}
943945
}
944946

@@ -969,15 +971,16 @@ mod visit_mut_tests {
969971
}
970972
}
971973

972-
fn do_visit_mut<V: VisitorMut>(sql: &str, visitor: &mut V) -> Statement {
974+
fn do_visit_mut<V: VisitorMut<Break = ()>>(sql: &str, visitor: &mut V) -> Statement {
973975
let dialect = GenericDialect {};
974976
let tokens = Tokenizer::new(&dialect, sql).tokenize().unwrap();
975977
let mut s = Parser::new(&dialect)
976978
.with_tokens(tokens)
977979
.parse_statement()
978980
.unwrap();
979981

980-
s.visit(visitor);
982+
let flow = s.visit(visitor);
983+
assert_eq!(flow, ControlFlow::Continue(()));
981984
s
982985
}
983986

src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@
149149
150150
#![cfg_attr(not(feature = "std"), no_std)]
151151
#![allow(clippy::upper_case_acronyms)]
152+
// Permit large enum variants to keep a unified, expressive AST.
153+
// Splitting complex nodes (expressions, statements, types) into separate types
154+
// would bloat the API and hide intent. Extra memory is a worthwhile tradeoff.
155+
#![allow(clippy::large_enum_variant)]
152156

153157
// Allow proc-macros to find this crate
154158
extern crate self as sqlparser;

src/parser/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2558,10 +2558,7 @@ impl<'a> Parser<'a> {
25582558
self.expect_token(&Token::LParen)?;
25592559
let mut trim_where = None;
25602560
if let Token::Word(word) = self.peek_token().token {
2561-
if [Keyword::BOTH, Keyword::LEADING, Keyword::TRAILING]
2562-
.iter()
2563-
.any(|d| word.keyword == *d)
2564-
{
2561+
if [Keyword::BOTH, Keyword::LEADING, Keyword::TRAILING].contains(&word.keyword) {
25652562
trim_where = Some(self.parse_trim_where()?);
25662563
}
25672564
}

tests/sqlparser_common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14346,7 +14346,7 @@ fn test_visit_order() {
1434614346
let sql = "SELECT CASE a WHEN 1 THEN 2 WHEN 3 THEN 4 ELSE 5 END";
1434714347
let stmt = verified_stmt(sql);
1434814348
let mut visited = vec![];
14349-
sqlparser::ast::visit_expressions(&stmt, |expr| {
14349+
let _ = sqlparser::ast::visit_expressions(&stmt, |expr| {
1435014350
visited.push(expr.to_string());
1435114351
core::ops::ControlFlow::<()>::Continue(())
1435214352
});

0 commit comments

Comments
 (0)