Skip to content

Commit cee5ac8

Browse files
committed
chore: fix clippy error in ci
1 parent ca93941 commit cee5ac8

15 files changed

+363
-397
lines changed

examples/cli.rs

Lines changed: 3 additions & 3 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);
@@ -78,13 +78,13 @@ $ cargo run --feature json_example --example cli FILENAME.sql [--dialectname]
7878
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 & 26 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,
@@ -185,27 +185,26 @@ impl fmt::Display for AlterTableOperation {
185185
new_column_name,
186186
} => write!(
187187
f,
188-
"RENAME COLUMN {} TO {}",
189-
old_column_name, new_column_name
188+
"RENAME COLUMN {old_column_name} TO {new_column_name}"
190189
),
191190
AlterTableOperation::RenameTable { table_name } => {
192-
write!(f, "RENAME TO {}", table_name)
191+
write!(f, "RENAME TO {table_name}")
193192
}
194193
AlterTableOperation::ChangeColumn {
195194
old_name,
196195
new_name,
197196
data_type,
198197
options,
199198
} => {
200-
write!(f, "CHANGE COLUMN {} {} {}", old_name, new_name, data_type)?;
199+
write!(f, "CHANGE COLUMN {old_name} {new_name} {data_type}")?;
201200
if options.is_empty() {
202201
Ok(())
203202
} else {
204203
write!(f, " {}", display_separated(options, " "))
205204
}
206205
}
207206
AlterTableOperation::RenameConstraint { old_name, new_name } => {
208-
write!(f, "RENAME CONSTRAINT {} TO {}", old_name, new_name)
207+
write!(f, "RENAME CONSTRAINT {old_name} TO {new_name}")
209208
}
210209
}
211210
}
@@ -215,7 +214,7 @@ impl fmt::Display for AlterIndexOperation {
215214
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
216215
match self {
217216
AlterIndexOperation::RenameIndex { index_name } => {
218-
write!(f, "RENAME TO {}", index_name)
217+
write!(f, "RENAME TO {index_name}")
219218
}
220219
}
221220
}
@@ -248,16 +247,16 @@ impl fmt::Display for AlterColumnOperation {
248247
AlterColumnOperation::SetNotNull => write!(f, "SET NOT NULL",),
249248
AlterColumnOperation::DropNotNull => write!(f, "DROP NOT NULL",),
250249
AlterColumnOperation::SetDefault { value } => {
251-
write!(f, "SET DEFAULT {}", value)
250+
write!(f, "SET DEFAULT {value}")
252251
}
253252
AlterColumnOperation::DropDefault {} => {
254253
write!(f, "DROP DEFAULT")
255254
}
256255
AlterColumnOperation::SetDataType { data_type, using } => {
257256
if let Some(expr) = using {
258-
write!(f, "SET DATA TYPE {} USING {}", data_type, expr)
257+
write!(f, "SET DATA TYPE {data_type} USING {expr}")
259258
} else {
260-
write!(f, "SET DATA TYPE {}", data_type)
259+
write!(f, "SET DATA TYPE {data_type}")
261260
}
262261
}
263262
}
@@ -369,10 +368,10 @@ impl fmt::Display for TableConstraint {
369368
display_comma_separated(referred_columns),
370369
)?;
371370
if let Some(action) = on_delete {
372-
write!(f, " ON DELETE {}", action)?;
371+
write!(f, " ON DELETE {action}")?;
373372
}
374373
if let Some(action) = on_update {
375-
write!(f, " ON UPDATE {}", action)?;
374+
write!(f, " ON UPDATE {action}")?;
376375
}
377376
Ok(())
378377
}
@@ -387,10 +386,10 @@ impl fmt::Display for TableConstraint {
387386
} => {
388387
write!(f, "{}", if *display_as_key { "KEY" } else { "INDEX" })?;
389388
if let Some(name) = name {
390-
write!(f, " {}", name)?;
389+
write!(f, " {name}")?;
391390
}
392391
if let Some(index_type) = index_type {
393-
write!(f, " USING {}", index_type)?;
392+
write!(f, " USING {index_type}")?;
394393
}
395394
write!(f, " ({})", display_comma_separated(columns))?;
396395

@@ -409,11 +408,11 @@ impl fmt::Display for TableConstraint {
409408
}
410409

411410
if !matches!(index_type_display, KeyOrIndexDisplay::None) {
412-
write!(f, " {}", index_type_display)?;
411+
write!(f, " {index_type_display}")?;
413412
}
414413

415414
if let Some(name) = opt_index_name {
416-
write!(f, " {}", name)?;
415+
write!(f, " {name}")?;
417416
}
418417

419418
write!(f, " ({})", display_comma_separated(columns))?;
@@ -500,7 +499,7 @@ impl fmt::Display for ColumnDef {
500499
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
501500
write!(f, "{} {}", self.name, self.data_type)?;
502501
for option in &self.options {
503-
write!(f, " {}", option)?;
502+
write!(f, " {option}")?;
504503
}
505504
Ok(())
506505
}
@@ -580,7 +579,7 @@ impl fmt::Display for ColumnOption {
580579
match self {
581580
Null => write!(f, "NULL"),
582581
NotNull => write!(f, "NOT NULL"),
583-
Default(expr) => write!(f, "DEFAULT {}", expr),
582+
Default(expr) => write!(f, "DEFAULT {expr}"),
584583
Unique { is_primary } => {
585584
write!(f, "{}", if *is_primary { "PRIMARY KEY" } else { "UNIQUE" })
586585
}
@@ -590,23 +589,23 @@ impl fmt::Display for ColumnOption {
590589
on_delete,
591590
on_update,
592591
} => {
593-
write!(f, "REFERENCES {}", foreign_table)?;
592+
write!(f, "REFERENCES {foreign_table}")?;
594593
if !referred_columns.is_empty() {
595594
write!(f, " ({})", display_comma_separated(referred_columns))?;
596595
}
597596
if let Some(action) = on_delete {
598-
write!(f, " ON DELETE {}", action)?;
597+
write!(f, " ON DELETE {action}")?;
599598
}
600599
if let Some(action) = on_update {
601-
write!(f, " ON UPDATE {}", action)?;
600+
write!(f, " ON UPDATE {action}")?;
602601
}
603602
Ok(())
604603
}
605-
Check(expr) => write!(f, "CHECK ({})", expr),
604+
Check(expr) => write!(f, "CHECK ({expr})"),
606605
DialectSpecific(val) => write!(f, "{}", display_separated(val, " ")),
607-
CharacterSet(n) => write!(f, "CHARACTER SET {}", n),
606+
CharacterSet(n) => write!(f, "CHARACTER SET {n}"),
608607
Comment(v) => write!(f, "COMMENT '{}'", escape_single_quote_string(v)),
609-
OnUpdate(expr) => write!(f, "ON UPDATE {}", expr),
608+
OnUpdate(expr) => write!(f, "ON UPDATE {expr}"),
610609
}
611610
}
612611
}
@@ -616,7 +615,7 @@ fn display_constraint_name(name: &'_ Option<Ident>) -> impl fmt::Display + '_ {
616615
impl<'a> fmt::Display for ConstraintName<'a> {
617616
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
618617
if let Some(name) = self.0 {
619-
write!(f, "CONSTRAINT {} ", name)?;
618+
write!(f, "CONSTRAINT {name} ")?;
620619
}
621620
Ok(())
622621
}

0 commit comments

Comments
 (0)