Skip to content

fix new rust 1.87 cargo clippy warnings #1856

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/ast/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -741,15 +741,16 @@ mod tests {
}
}

fn do_visit<V: Visitor>(sql: &str, visitor: &mut V) -> Statement {
fn do_visit<V: Visitor<Break = ()>>(sql: &str, visitor: &mut V) -> Statement {
let dialect = GenericDialect {};
let tokens = Tokenizer::new(&dialect, sql).tokenize().unwrap();
let s = Parser::new(&dialect)
.with_tokens(tokens)
.parse_statement()
.unwrap();

s.visit(visitor);
let flow = s.visit(visitor);
assert_eq!(flow, ControlFlow::Continue(()));
s
}

Expand Down Expand Up @@ -938,7 +939,8 @@ mod tests {
.unwrap();

let mut visitor = QuickVisitor {};
s.visit(&mut visitor);
let flow = s.visit(&mut visitor);
assert_eq!(flow, ControlFlow::Continue(()));
}
}

Expand Down Expand Up @@ -969,15 +971,16 @@ mod visit_mut_tests {
}
}

fn do_visit_mut<V: VisitorMut>(sql: &str, visitor: &mut V) -> Statement {
fn do_visit_mut<V: VisitorMut<Break = ()>>(sql: &str, visitor: &mut V) -> Statement {
let dialect = GenericDialect {};
let tokens = Tokenizer::new(&dialect, sql).tokenize().unwrap();
let mut s = Parser::new(&dialect)
.with_tokens(tokens)
.parse_statement()
.unwrap();

s.visit(visitor);
let flow = s.visit(visitor);
assert_eq!(flow, ControlFlow::Continue(()));
s
}

Expand Down
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@

#![cfg_attr(not(feature = "std"), no_std)]
#![allow(clippy::upper_case_acronyms)]
// Permit large enum variants to keep a unified, expressive AST.
// Splitting complex nodes (expressions, statements, types) into separate types
// would bloat the API and hide intent. Extra memory is a worthwhile tradeoff.
#![allow(clippy::large_enum_variant)]

// Allow proc-macros to find this crate
extern crate self as sqlparser;
Expand Down
5 changes: 1 addition & 4 deletions src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2558,10 +2558,7 @@ impl<'a> Parser<'a> {
self.expect_token(&Token::LParen)?;
let mut trim_where = None;
if let Token::Word(word) = self.peek_token().token {
if [Keyword::BOTH, Keyword::LEADING, Keyword::TRAILING]
.iter()
.any(|d| word.keyword == *d)
{
if [Keyword::BOTH, Keyword::LEADING, Keyword::TRAILING].contains(&word.keyword) {
trim_where = Some(self.parse_trim_where()?);
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/sqlparser_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14346,7 +14346,7 @@ fn test_visit_order() {
let sql = "SELECT CASE a WHEN 1 THEN 2 WHEN 3 THEN 4 ELSE 5 END";
let stmt = verified_stmt(sql);
let mut visited = vec![];
sqlparser::ast::visit_expressions(&stmt, |expr| {
let _ = sqlparser::ast::visit_expressions(&stmt, |expr| {
visited.push(expr.to_string());
core::ops::ControlFlow::<()>::Continue(())
});
Expand Down