Skip to content

Commit 2edba96

Browse files
authored
Merge pull request #19 from kemingy/lint
fix: make cargo clippy happy
2 parents e4e9f49 + 32a1d23 commit 2edba96

27 files changed

+182
-191
lines changed

examples/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ $ cargo run --example cli - [--dialectname]
6363
};
6464

6565
let contents = if filename == "-" {
66-
println!("Parsing from stdin using {:?}", dialect);
66+
println!("Parsing from stdin using {dialect:?}");
6767
let mut buf = Vec::new();
6868
stdin()
6969
.read_to_end(&mut buf)

sqlparser_bench/benches/sqlparser_bench.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,24 @@ fn basic_queries(c: &mut Criterion) {
4545

4646
let large_statement = {
4747
let expressions = (0..1000)
48-
.map(|n| format!("FN_{}(COL_{})", n, n))
48+
.map(|n| format!("FN_{n}(COL_{n})"))
4949
.collect::<Vec<_>>()
5050
.join(", ");
5151
let tables = (0..1000)
52-
.map(|n| format!("TABLE_{}", n))
52+
.map(|n| format!("TABLE_{n}"))
5353
.collect::<Vec<_>>()
5454
.join(" JOIN ");
5555
let where_condition = (0..1000)
56-
.map(|n| format!("COL_{} = {}", n, n))
56+
.map(|n| format!("COL_{n} = {n}"))
5757
.collect::<Vec<_>>()
5858
.join(" OR ");
5959
let order_condition = (0..1000)
60-
.map(|n| format!("COL_{} DESC", n))
60+
.map(|n| format!("COL_{n} DESC"))
6161
.collect::<Vec<_>>()
6262
.join(", ");
6363

6464
format!(
65-
"SELECT {} FROM {} WHERE {} ORDER BY {}",
66-
expressions, tables, where_condition, order_condition
65+
"SELECT {expressions} FROM {tables} WHERE {where_condition} ORDER BY {order_condition}"
6766
)
6867
};
6968

src/ast/data_type.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ impl fmt::Display for DataType {
565565
}
566566
DataType::Enum(vals, bits) => {
567567
match bits {
568-
Some(bits) => write!(f, "ENUM{}", bits),
568+
Some(bits) => write!(f, "ENUM{bits}"),
569569
None => write!(f, "ENUM"),
570570
}?;
571571
write!(f, "(")?;
@@ -613,16 +613,16 @@ impl fmt::Display for DataType {
613613
}
614614
// ClickHouse
615615
DataType::Nullable(data_type) => {
616-
write!(f, "Nullable({})", data_type)
616+
write!(f, "Nullable({data_type})")
617617
}
618618
DataType::FixedString(character_length) => {
619-
write!(f, "FixedString({})", character_length)
619+
write!(f, "FixedString({character_length})")
620620
}
621621
DataType::LowCardinality(data_type) => {
622-
write!(f, "LowCardinality({})", data_type)
622+
write!(f, "LowCardinality({data_type})")
623623
}
624624
DataType::Map(key_data_type, value_data_type) => {
625-
write!(f, "Map({}, {})", key_data_type, value_data_type)
625+
write!(f, "Map({key_data_type}, {value_data_type})")
626626
}
627627
DataType::Tuple(fields) => {
628628
write!(f, "Tuple({})", display_comma_separated(fields))
@@ -815,7 +815,7 @@ impl fmt::Display for CharacterLength {
815815
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
816816
match self {
817817
CharacterLength::IntegerLength { length, unit } => {
818-
write!(f, "{}", length)?;
818+
write!(f, "{length}")?;
819819
if let Some(unit) = unit {
820820
write!(f, " {unit}")?;
821821
}

src/ast/dcl.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ impl fmt::Display for AlterRoleOperation {
175175
in_database,
176176
} => {
177177
if let Some(database_name) = in_database {
178-
write!(f, "IN DATABASE {} ", database_name)?;
178+
write!(f, "IN DATABASE {database_name} ")?;
179179
}
180180

181181
match config_value {
@@ -189,7 +189,7 @@ impl fmt::Display for AlterRoleOperation {
189189
in_database,
190190
} => {
191191
if let Some(database_name) = in_database {
192-
write!(f, "IN DATABASE {} ", database_name)?;
192+
write!(f, "IN DATABASE {database_name} ")?;
193193
}
194194

195195
match config_name {
@@ -220,15 +220,15 @@ impl fmt::Display for Use {
220220
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
221221
f.write_str("USE ")?;
222222
match self {
223-
Use::Catalog(name) => write!(f, "CATALOG {}", name),
224-
Use::Schema(name) => write!(f, "SCHEMA {}", name),
225-
Use::Database(name) => write!(f, "DATABASE {}", name),
226-
Use::Warehouse(name) => write!(f, "WAREHOUSE {}", name),
227-
Use::Role(name) => write!(f, "ROLE {}", name),
223+
Use::Catalog(name) => write!(f, "CATALOG {name}"),
224+
Use::Schema(name) => write!(f, "SCHEMA {name}"),
225+
Use::Database(name) => write!(f, "DATABASE {name}"),
226+
Use::Warehouse(name) => write!(f, "WAREHOUSE {name}"),
227+
Use::Role(name) => write!(f, "ROLE {name}"),
228228
Use::SecondaryRoles(secondary_roles) => {
229-
write!(f, "SECONDARY ROLES {}", secondary_roles)
229+
write!(f, "SECONDARY ROLES {secondary_roles}")
230230
}
231-
Use::Object(name) => write!(f, "{}", name),
231+
Use::Object(name) => write!(f, "{name}"),
232232
Use::Default => write!(f, "DEFAULT"),
233233
}
234234
}

src/ast/ddl.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ pub enum Owner {
332332
impl fmt::Display for Owner {
333333
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
334334
match self {
335-
Owner::Ident(ident) => write!(f, "{}", ident),
335+
Owner::Ident(ident) => write!(f, "{ident}"),
336336
Owner::CurrentRole => write!(f, "CURRENT_ROLE"),
337337
Owner::CurrentUser => write!(f, "CURRENT_USER"),
338338
Owner::SessionUser => write!(f, "SESSION_USER"),
@@ -390,14 +390,14 @@ impl fmt::Display for AlterTableOperation {
390390
if *if_not_exists {
391391
write!(f, " IF NOT EXISTS")?;
392392
}
393-
write!(f, " {} ({})", name, query)
393+
write!(f, " {name} ({query})")
394394
}
395395
AlterTableOperation::DropProjection { if_exists, name } => {
396396
write!(f, "DROP PROJECTION")?;
397397
if *if_exists {
398398
write!(f, " IF EXISTS")?;
399399
}
400-
write!(f, " {}", name)
400+
write!(f, " {name}")
401401
}
402402
AlterTableOperation::MaterializeProjection {
403403
if_exists,
@@ -408,9 +408,9 @@ impl fmt::Display for AlterTableOperation {
408408
if *if_exists {
409409
write!(f, " IF EXISTS")?;
410410
}
411-
write!(f, " {}", name)?;
411+
write!(f, " {name}")?;
412412
if let Some(partition) = partition {
413-
write!(f, " IN PARTITION {}", partition)?;
413+
write!(f, " IN PARTITION {partition}")?;
414414
}
415415
Ok(())
416416
}
@@ -423,9 +423,9 @@ impl fmt::Display for AlterTableOperation {
423423
if *if_exists {
424424
write!(f, " IF EXISTS")?;
425425
}
426-
write!(f, " {}", name)?;
426+
write!(f, " {name}")?;
427427
if let Some(partition) = partition {
428-
write!(f, " IN PARTITION {}", partition)?;
428+
write!(f, " IN PARTITION {partition}")?;
429429
}
430430
Ok(())
431431
}
@@ -661,7 +661,7 @@ impl fmt::Display for AlterColumnOperation {
661661
AlterColumnOperation::SetDefault { value } => {
662662
write!(f, "SET DEFAULT {value}")
663663
}
664-
AlterColumnOperation::DropDefault {} => {
664+
AlterColumnOperation::DropDefault => {
665665
write!(f, "DROP DEFAULT")
666666
}
667667
AlterColumnOperation::SetDataType { data_type, using } => {
@@ -910,7 +910,7 @@ impl fmt::Display for TableConstraint {
910910
write!(f, " ON UPDATE {action}")?;
911911
}
912912
if let Some(characteristics) = characteristics {
913-
write!(f, " {}", characteristics)?;
913+
write!(f, " {characteristics}")?;
914914
}
915915
Ok(())
916916
}
@@ -1152,7 +1152,7 @@ impl fmt::Display for ViewColumnDef {
11521152
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
11531153
write!(f, "{}", self.name)?;
11541154
if let Some(data_type) = self.data_type.as_ref() {
1155-
write!(f, " {}", data_type)?;
1155+
write!(f, " {data_type}")?;
11561156
}
11571157
if let Some(options) = self.options.as_ref() {
11581158
write!(f, " {}", display_comma_separated(options.as_slice()))?;
@@ -1532,7 +1532,7 @@ impl fmt::Display for ColumnOption {
15321532
} => {
15331533
write!(f, "{}", if *is_primary { "PRIMARY KEY" } else { "UNIQUE" })?;
15341534
if let Some(characteristics) = characteristics {
1535-
write!(f, " {}", characteristics)?;
1535+
write!(f, " {characteristics}")?;
15361536
}
15371537
Ok(())
15381538
}
@@ -1554,7 +1554,7 @@ impl fmt::Display for ColumnOption {
15541554
write!(f, " ON UPDATE {action}")?;
15551555
}
15561556
if let Some(characteristics) = characteristics {
1557-
write!(f, " {}", characteristics)?;
1557+
write!(f, " {characteristics}")?;
15581558
}
15591559
Ok(())
15601560
}
@@ -1613,7 +1613,7 @@ impl fmt::Display for ColumnOption {
16131613
write!(f, "{parameters}")
16141614
}
16151615
OnConflict(keyword) => {
1616-
write!(f, "ON CONFLICT {:?}", keyword)?;
1616+
write!(f, "ON CONFLICT {keyword:?}")?;
16171617
Ok(())
16181618
}
16191619
Policy(parameters) => {

src/ast/dml.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ impl Display for CreateTable {
226226
name = self.name,
227227
)?;
228228
if let Some(on_cluster) = &self.on_cluster {
229-
write!(f, " ON CLUSTER {}", on_cluster)?;
229+
write!(f, " ON CLUSTER {on_cluster}")?;
230230
}
231231
if !self.columns.is_empty() || !self.constraints.is_empty() {
232232
write!(f, " ({}", display_comma_separated(&self.columns))?;
@@ -364,10 +364,10 @@ impl Display for CreateTable {
364364
write!(f, " AUTO_INCREMENT {auto_increment_offset}")?;
365365
}
366366
if let Some(primary_key) = &self.primary_key {
367-
write!(f, " PRIMARY KEY {}", primary_key)?;
367+
write!(f, " PRIMARY KEY {primary_key}")?;
368368
}
369369
if let Some(order_by) = &self.order_by {
370-
write!(f, " ORDER BY {}", order_by)?;
370+
write!(f, " ORDER BY {order_by}")?;
371371
}
372372
if let Some(partition_by) = self.partition_by.as_ref() {
373373
write!(f, " PARTITION BY {partition_by}")?;

src/ast/helpers/stmt_data_loading.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ impl fmt::Display for DataLoadingOptions {
123123
} else {
124124
f.write_str(" ")?;
125125
}
126-
write!(f, "{}", option)?;
126+
write!(f, "{option}")?;
127127
}
128128
}
129129
Ok(())

0 commit comments

Comments
 (0)