Skip to content

Commit b31ede7

Browse files
authored
chore: fix clippy error in ci (#803)
* chore: fix clippy error in ci * chore: fix fmt
1 parent 4955863 commit b31ede7

16 files changed

+371
-444
lines changed

examples/cli.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ $ cargo run --feature json_example --example cli FILENAME.sql [--dialectname]
4646
"--hive" => Box::new(HiveDialect {}),
4747
"--redshift" => Box::new(RedshiftSqlDialect {}),
4848
"--generic" | "" => Box::new(GenericDialect {}),
49-
s => panic!("Unexpected parameter: {}", s),
49+
s => panic!("Unexpected parameter: {s}"),
5050
};
5151

5252
println!("Parsing from file '{}' using {:?}", &filename, dialect);
@@ -75,16 +75,16 @@ $ cargo run --feature json_example --example cli FILENAME.sql [--dialectname]
7575
#[cfg(feature = "json_example")]
7676
{
7777
let serialized = serde_json::to_string_pretty(&statements).unwrap();
78-
println!("Serialized as JSON:\n{}", serialized);
78+
println!("Serialized as JSON:\n{serialized}");
7979
}
8080
} else {
81-
println!("Parse results:\n{:#?}", statements);
81+
println!("Parse results:\n{statements:#?}");
8282
}
8383

8484
std::process::exit(0);
8585
}
8686
Err(e) => {
87-
println!("Error during parsing: {:?}", e);
87+
println!("Error during parsing: {e:?}");
8888
std::process::exit(1);
8989
}
9090
}

examples/parse_select.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ fn main() {
2525

2626
let ast = Parser::parse_sql(&dialect, sql).unwrap();
2727

28-
println!("AST: {:?}", ast);
28+
println!("AST: {ast:?}");
2929
}

src/ast/data_type.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -186,13 +186,13 @@ impl fmt::Display for DataType {
186186
}
187187
DataType::Blob(size) => format_type_with_optional_length(f, "BLOB", size, false),
188188
DataType::Numeric(info) => {
189-
write!(f, "NUMERIC{}", info)
189+
write!(f, "NUMERIC{info}")
190190
}
191191
DataType::Decimal(info) => {
192-
write!(f, "DECIMAL{}", info)
192+
write!(f, "DECIMAL{info}")
193193
}
194194
DataType::Dec(info) => {
195-
write!(f, "DEC{}", info)
195+
write!(f, "DEC{info}")
196196
}
197197
DataType::Float(size) => format_type_with_optional_length(f, "FLOAT", size, false),
198198
DataType::TinyInt(zerofill) => {
@@ -250,14 +250,14 @@ impl fmt::Display for DataType {
250250
DataType::Bytea => write!(f, "BYTEA"),
251251
DataType::Array(ty) => {
252252
if let Some(t) = &ty {
253-
write!(f, "{}[]", t)
253+
write!(f, "{t}[]")
254254
} else {
255255
write!(f, "ARRAY")
256256
}
257257
}
258258
DataType::Custom(ty, modifiers) => {
259259
if modifiers.is_empty() {
260-
write!(f, "{}", ty)
260+
write!(f, "{ty}")
261261
} else {
262262
write!(f, "{}({})", ty, modifiers.join(", "))
263263
}
@@ -292,9 +292,9 @@ fn format_type_with_optional_length(
292292
len: &Option<u64>,
293293
unsigned: bool,
294294
) -> fmt::Result {
295-
write!(f, "{}", sql_type)?;
295+
write!(f, "{sql_type}")?;
296296
if let Some(len) = len {
297-
write!(f, "({})", len)?;
297+
write!(f, "({len})")?;
298298
}
299299
if unsigned {
300300
write!(f, " UNSIGNED")?;
@@ -307,9 +307,9 @@ fn format_character_string_type(
307307
sql_type: &str,
308308
size: &Option<CharacterLength>,
309309
) -> fmt::Result {
310-
write!(f, "{}", sql_type)?;
310+
write!(f, "{sql_type}")?;
311311
if let Some(size) = size {
312-
write!(f, "({})", size)?;
312+
write!(f, "({size})")?;
313313
}
314314
Ok(())
315315
}
@@ -320,7 +320,7 @@ fn format_datetime_precision_and_tz(
320320
len: &Option<u64>,
321321
time_zone: &TimezoneInfo,
322322
) -> fmt::Result {
323-
write!(f, "{}", sql_type)?;
323+
write!(f, "{sql_type}")?;
324324
let len_fmt = len.as_ref().map(|l| format!("({l})")).unwrap_or_default();
325325

326326
match time_zone {
@@ -432,7 +432,7 @@ impl fmt::Display for CharacterLength {
432432
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
433433
write!(f, "{}", self.length)?;
434434
if let Some(unit) = &self.unit {
435-
write!(f, " {}", unit)?;
435+
write!(f, " {unit}")?;
436436
}
437437
Ok(())
438438
}

src/ast/ddl.rs

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ impl fmt::Display for AlterTableOperation {
117117
display_comma_separated(new_partitions),
118118
ine = if *if_not_exists { " IF NOT EXISTS" } else { "" }
119119
),
120-
AlterTableOperation::AddConstraint(c) => write!(f, "ADD {}", c),
120+
AlterTableOperation::AddConstraint(c) => write!(f, "ADD {c}"),
121121
AlterTableOperation::AddColumn {
122122
column_keyword,
123123
if_not_exists,
@@ -135,7 +135,7 @@ impl fmt::Display for AlterTableOperation {
135135
Ok(())
136136
}
137137
AlterTableOperation::AlterColumn { column_name, op } => {
138-
write!(f, "ALTER COLUMN {} {}", column_name, op)
138+
write!(f, "ALTER COLUMN {column_name} {op}")
139139
}
140140
AlterTableOperation::DropPartitions {
141141
partitions,
@@ -183,29 +183,25 @@ impl fmt::Display for AlterTableOperation {
183183
AlterTableOperation::RenameColumn {
184184
old_column_name,
185185
new_column_name,
186-
} => write!(
187-
f,
188-
"RENAME COLUMN {} TO {}",
189-
old_column_name, new_column_name
190-
),
186+
} => write!(f, "RENAME COLUMN {old_column_name} TO {new_column_name}"),
191187
AlterTableOperation::RenameTable { table_name } => {
192-
write!(f, "RENAME TO {}", table_name)
188+
write!(f, "RENAME TO {table_name}")
193189
}
194190
AlterTableOperation::ChangeColumn {
195191
old_name,
196192
new_name,
197193
data_type,
198194
options,
199195
} => {
200-
write!(f, "CHANGE COLUMN {} {} {}", old_name, new_name, data_type)?;
196+
write!(f, "CHANGE COLUMN {old_name} {new_name} {data_type}")?;
201197
if options.is_empty() {
202198
Ok(())
203199
} else {
204200
write!(f, " {}", display_separated(options, " "))
205201
}
206202
}
207203
AlterTableOperation::RenameConstraint { old_name, new_name } => {
208-
write!(f, "RENAME CONSTRAINT {} TO {}", old_name, new_name)
204+
write!(f, "RENAME CONSTRAINT {old_name} TO {new_name}")
209205
}
210206
}
211207
}
@@ -215,7 +211,7 @@ impl fmt::Display for AlterIndexOperation {
215211
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
216212
match self {
217213
AlterIndexOperation::RenameIndex { index_name } => {
218-
write!(f, "RENAME TO {}", index_name)
214+
write!(f, "RENAME TO {index_name}")
219215
}
220216
}
221217
}
@@ -248,16 +244,16 @@ impl fmt::Display for AlterColumnOperation {
248244
AlterColumnOperation::SetNotNull => write!(f, "SET NOT NULL",),
249245
AlterColumnOperation::DropNotNull => write!(f, "DROP NOT NULL",),
250246
AlterColumnOperation::SetDefault { value } => {
251-
write!(f, "SET DEFAULT {}", value)
247+
write!(f, "SET DEFAULT {value}")
252248
}
253249
AlterColumnOperation::DropDefault {} => {
254250
write!(f, "DROP DEFAULT")
255251
}
256252
AlterColumnOperation::SetDataType { data_type, using } => {
257253
if let Some(expr) = using {
258-
write!(f, "SET DATA TYPE {} USING {}", data_type, expr)
254+
write!(f, "SET DATA TYPE {data_type} USING {expr}")
259255
} else {
260-
write!(f, "SET DATA TYPE {}", data_type)
256+
write!(f, "SET DATA TYPE {data_type}")
261257
}
262258
}
263259
}
@@ -369,10 +365,10 @@ impl fmt::Display for TableConstraint {
369365
display_comma_separated(referred_columns),
370366
)?;
371367
if let Some(action) = on_delete {
372-
write!(f, " ON DELETE {}", action)?;
368+
write!(f, " ON DELETE {action}")?;
373369
}
374370
if let Some(action) = on_update {
375-
write!(f, " ON UPDATE {}", action)?;
371+
write!(f, " ON UPDATE {action}")?;
376372
}
377373
Ok(())
378374
}
@@ -387,10 +383,10 @@ impl fmt::Display for TableConstraint {
387383
} => {
388384
write!(f, "{}", if *display_as_key { "KEY" } else { "INDEX" })?;
389385
if let Some(name) = name {
390-
write!(f, " {}", name)?;
386+
write!(f, " {name}")?;
391387
}
392388
if let Some(index_type) = index_type {
393-
write!(f, " USING {}", index_type)?;
389+
write!(f, " USING {index_type}")?;
394390
}
395391
write!(f, " ({})", display_comma_separated(columns))?;
396392

@@ -409,11 +405,11 @@ impl fmt::Display for TableConstraint {
409405
}
410406

411407
if !matches!(index_type_display, KeyOrIndexDisplay::None) {
412-
write!(f, " {}", index_type_display)?;
408+
write!(f, " {index_type_display}")?;
413409
}
414410

415411
if let Some(name) = opt_index_name {
416-
write!(f, " {}", name)?;
412+
write!(f, " {name}")?;
417413
}
418414

419415
write!(f, " ({})", display_comma_separated(columns))?;
@@ -500,7 +496,7 @@ impl fmt::Display for ColumnDef {
500496
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
501497
write!(f, "{} {}", self.name, self.data_type)?;
502498
for option in &self.options {
503-
write!(f, " {}", option)?;
499+
write!(f, " {option}")?;
504500
}
505501
Ok(())
506502
}
@@ -580,7 +576,7 @@ impl fmt::Display for ColumnOption {
580576
match self {
581577
Null => write!(f, "NULL"),
582578
NotNull => write!(f, "NOT NULL"),
583-
Default(expr) => write!(f, "DEFAULT {}", expr),
579+
Default(expr) => write!(f, "DEFAULT {expr}"),
584580
Unique { is_primary } => {
585581
write!(f, "{}", if *is_primary { "PRIMARY KEY" } else { "UNIQUE" })
586582
}
@@ -590,23 +586,23 @@ impl fmt::Display for ColumnOption {
590586
on_delete,
591587
on_update,
592588
} => {
593-
write!(f, "REFERENCES {}", foreign_table)?;
589+
write!(f, "REFERENCES {foreign_table}")?;
594590
if !referred_columns.is_empty() {
595591
write!(f, " ({})", display_comma_separated(referred_columns))?;
596592
}
597593
if let Some(action) = on_delete {
598-
write!(f, " ON DELETE {}", action)?;
594+
write!(f, " ON DELETE {action}")?;
599595
}
600596
if let Some(action) = on_update {
601-
write!(f, " ON UPDATE {}", action)?;
597+
write!(f, " ON UPDATE {action}")?;
602598
}
603599
Ok(())
604600
}
605-
Check(expr) => write!(f, "CHECK ({})", expr),
601+
Check(expr) => write!(f, "CHECK ({expr})"),
606602
DialectSpecific(val) => write!(f, "{}", display_separated(val, " ")),
607-
CharacterSet(n) => write!(f, "CHARACTER SET {}", n),
603+
CharacterSet(n) => write!(f, "CHARACTER SET {n}"),
608604
Comment(v) => write!(f, "COMMENT '{}'", escape_single_quote_string(v)),
609-
OnUpdate(expr) => write!(f, "ON UPDATE {}", expr),
605+
OnUpdate(expr) => write!(f, "ON UPDATE {expr}"),
610606
}
611607
}
612608
}
@@ -616,7 +612,7 @@ fn display_constraint_name(name: &'_ Option<Ident>) -> impl fmt::Display + '_ {
616612
impl<'a> fmt::Display for ConstraintName<'a> {
617613
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
618614
if let Some(name) = self.0 {
619-
write!(f, "CONSTRAINT {} ", name)?;
615+
write!(f, "CONSTRAINT {name} ")?;
620616
}
621617
Ok(())
622618
}

0 commit comments

Comments
 (0)