You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafusion.apache.org by gi...@apache.org on 2026/10/17 10:26:01 UTC
(datafusion-sqlparser-rs) branch main updated: Deny `clippy::allow_attributes` and `allow_attributes_without_reason` (#2653)
This is an automated email from the ASF dual-hosted git repository.
github-merge-queue[bot] pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion-sqlparser-rs.git
The following commit(s) were added to refs/heads/main by this push:
new 7b5821dd4 Deny `clippy::allow_attributes` and `allow_attributes_without_reason` (#2653)
7b5821dd4 is described below
commit 7b5821dd45ce13ba6a77b24c39854a863848c2b2
Author: Luca Cappelletti <ca...@gmail.com>
AuthorDate: Sat Oct 17 10:23:56 2026 +0000
Deny `clippy::allow_attributes` and `allow_attributes_without_reason` (#2653)
---
Cargo.toml | 2 ++
src/ast/mod.rs | 10 ++++------
src/ast/query.rs | 1 -
src/dialect/mod.rs | 3 +--
src/dialect/snowflake.rs | 5 ++++-
src/keywords.rs | 5 ++++-
src/lib.rs | 9 ++++-----
src/parser/mod.rs | 6 ++++--
src/tokenizer.rs | 5 ++++-
tests/sqlparser_common.rs | 13 ++++---------
10 files changed, 31 insertions(+), 28 deletions(-)
diff --git a/Cargo.toml b/Cargo.toml
index e4c34ab53..d66a4e7eb 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -40,6 +40,8 @@ path = "src/lib.rs"
unsafe_code = "forbid"
[lints.clippy]
+allow_attributes = "deny"
+allow_attributes_without_reason = "deny"
assertions_on_result_states = "deny"
ignore_without_reason = "deny"
manual_assert_eq = "deny"
diff --git a/src/ast/mod.rs b/src/ast/mod.rs
index c7cd6806f..f585121ad 100644
--- a/src/ast/mod.rs
+++ b/src/ast/mod.rs
@@ -3607,7 +3607,6 @@ impl fmt::Display for Analyze {
}
/// A top-level statement (SELECT, INSERT, CREATE, etc.)
-#[allow(clippy::large_enum_variant)]
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(
@@ -5165,9 +5164,10 @@ impl fmt::Display for Statement {
/// FROM
/// table_1"#);
/// ```
- // Clippy thinks this function is too complicated, but it is painful to
- // split up without extracting structs for each `Statement` variant.
- #[allow(clippy::cognitive_complexity)]
+ #[expect(
+ clippy::cognitive_complexity,
+ reason = "splitting this match would need a struct for each `Statement` variant"
+ )]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Statement::Flush {
@@ -8938,7 +8938,6 @@ impl fmt::Display for DescribeAlias {
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
-#[allow(clippy::large_enum_variant)]
/// Hive input/output format specification used in `CREATE TABLE`.
pub enum HiveIOFormat {
/// Generic IO format with separate input and output expressions.
@@ -10698,7 +10697,6 @@ impl fmt::Display for HiveSetLocation {
}
/// MySQL `ALTER TABLE` only [FIRST | AFTER column_name]
-#[allow(clippy::large_enum_variant)]
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
diff --git a/src/ast/query.rs b/src/ast/query.rs
index 81b3afa90..4aa82c7c3 100644
--- a/src/ast/query.rs
+++ b/src/ast/query.rs
@@ -143,7 +143,6 @@ impl fmt::Display for ProjectionSelect {
/// A node in a tree, representing a "query body" expression, roughly:
/// `SELECT ... [ {UNION|EXCEPT|INTERSECT} SELECT ...]`
-#[allow(clippy::large_enum_variant)]
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
diff --git a/src/dialect/mod.rs b/src/dialect/mod.rs
index d3778994d..d8f93e49e 100644
--- a/src/dialect/mod.rs
+++ b/src/dialect/mod.rs
@@ -2309,8 +2309,7 @@ mod tests {
}
}
- #[allow(clippy::needless_raw_string_hashes)]
- let statement = r#"SELECT 'Wayne\'s World'"#;
+ let statement = r"SELECT 'Wayne\'s World'";
let res1 = Parser::parse_sql(&MySqlDialect {}, statement);
let res2 = Parser::parse_sql(&WrappedDialect(MySqlDialect {}), statement);
assert_eq!(res1.unwrap(), res2.unwrap());
diff --git a/src/dialect/snowflake.rs b/src/dialect/snowflake.rs
index a25f28631..bc954a45b 100644
--- a/src/dialect/snowflake.rs
+++ b/src/dialect/snowflake.rs
@@ -866,7 +866,10 @@ fn parse_alter_session(parser: &mut Parser, set: bool) -> Result<Statement, Pars
/// Parse snowflake create table statement.
/// <https://docs.snowflake.com/en/sql-reference/sql/create-table>
/// <https://docs.snowflake.com/en/sql-reference/sql/create-iceberg-table>
-#[allow(clippy::too_many_arguments)]
+#[expect(
+ clippy::too_many_arguments,
+ reason = "each flag is a `CREATE` modifier the caller parsed before `TABLE`"
+)]
pub fn parse_create_table(
or_replace: bool,
global: Option<bool>,
diff --git a/src/keywords.rs b/src/keywords.rs
index 8f98c59b1..7e9382241 100644
--- a/src/keywords.rs
+++ b/src/keywords.rs
@@ -54,7 +54,10 @@ macro_rules! define_keywords {
#[derive(Debug, Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
- #[allow(non_camel_case_types)]
+ #[expect(
+ non_camel_case_types,
+ reason = "variants are spelled like the SQL keywords they name, such as `CURRENT_DATE`"
+ )]
/// An enumeration of SQL keywords recognized by the parser.
pub enum Keyword {
/// Represents no keyword.
diff --git a/src/lib.rs b/src/lib.rs
index ddf2fb74b..5f62e86ec 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -148,11 +148,10 @@
//![`TokenWithLocation`]: tokenizer::TokenWithLocation
#![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)]
+#![expect(
+ clippy::large_enum_variant,
+ reason = "a unified AST is worth the extra memory, and splitting nodes into separate types would bloat the API"
+)]
#![forbid(clippy::unreachable)]
#![forbid(missing_docs)]
diff --git a/src/parser/mod.rs b/src/parser/mod.rs
index cd8817097..7d2006b2d 100644
--- a/src/parser/mod.rs
+++ b/src/parser/mod.rs
@@ -8828,7 +8828,10 @@ impl<'a> Parser<'a> {
}
/// Parse `CREATE TABLE` statement.
- #[allow(clippy::too_many_arguments)]
+ #[expect(
+ clippy::too_many_arguments,
+ reason = "each flag is a `CREATE` modifier the caller parsed before `TABLE`"
+ )]
pub fn parse_create_table(
&mut self,
or_replace: bool,
@@ -16828,7 +16831,6 @@ impl<'a> Parser<'a> {
// followed by some joins or (B) another level of nesting.
let mut table_and_joins = self.parse_table_and_joins()?;
- #[allow(clippy::if_same_then_else)]
if !table_and_joins.joins.is_empty() {
self.expect_token(&Token::RParen)?;
let alias = self.maybe_parse_table_alias()?;
diff --git a/src/tokenizer.rs b/src/tokenizer.rs
index 423bbea31..2adf0aa99 100644
--- a/src/tokenizer.rs
+++ b/src/tokenizer.rs
@@ -2421,7 +2421,10 @@ impl<'a> Tokenizer<'a> {
(s, last_char)
}
- #[allow(clippy::unnecessary_wraps)]
+ #[expect(
+ clippy::unnecessary_wraps,
+ reason = "the match arms in `next_token` return this value directly"
+ )]
fn consume_and_return(
&self,
chars: &mut State,
diff --git a/tests/sqlparser_common.rs b/tests/sqlparser_common.rs
index 66824165c..53fbe1b49 100644
--- a/tests/sqlparser_common.rs
+++ b/tests/sqlparser_common.rs
@@ -4729,7 +4729,6 @@ fn parse_assert() {
}
#[test]
-#[allow(clippy::collapsible_match)]
fn parse_assert_message() {
let sql = "ASSERT (SELECT COUNT(*) FROM my_table) > 0 AS 'No rows in my_table'";
let ast = one_statement_parses_to(
@@ -4739,16 +4738,12 @@ fn parse_assert_message() {
match ast {
Statement::Assert {
condition: _condition,
- message: Some(message),
- } => {
- match message {
- Expr::Value(ValueWithSpan {
+ message:
+ Some(Expr::Value(ValueWithSpan {
value: Value::SingleQuotedString(s),
span: _,
- }) => assert_eq!(s, "No rows in my_table"),
- _ => unreachable!(),
- };
- }
+ })),
+ } => assert_eq!(s, "No rows in my_table"),
_ => unreachable!(),
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org