Skip to content

Commit ebee0da

Browse files
committed
fix(BREAKING): make clippy happy
1 parent 2aa896f commit ebee0da

File tree

4 files changed

+23
-22
lines changed

4 files changed

+23
-22
lines changed

src/diff.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ use thiserror::Error;
1111
#[derive(Error, Debug)]
1212
pub struct DiffError {
1313
kind: DiffErrorKind,
14-
statement_a: Option<Statement>,
15-
statement_b: Option<Statement>,
14+
statement_a: Option<Box<Statement>>,
15+
statement_b: Option<Box<Statement>>,
1616
}
1717

1818
impl fmt::Display for DiffError {
@@ -42,8 +42,8 @@ impl DiffError {
4242
) -> Self {
4343
Self {
4444
kind,
45-
statement_a,
46-
statement_b,
45+
statement_a: statement_a.map(Box::new),
46+
statement_b: statement_b.map(Box::new),
4747
}
4848
}
4949
}

src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,20 +138,20 @@ mod tests {
138138
F: Fn(SyntaxTree, SyntaxTree) -> SyntaxTree,
139139
{
140140
let ast_a = SyntaxTree::builder()
141-
.dialect(tc.dialect.clone())
141+
.dialect(tc.dialect)
142142
.sql(tc.sql_a)
143143
.build()
144144
.unwrap();
145145
let ast_b = SyntaxTree::builder()
146-
.dialect(tc.dialect.clone())
146+
.dialect(tc.dialect)
147147
.sql(tc.sql_b)
148148
.build()
149149
.unwrap();
150150
SyntaxTree::builder()
151-
.dialect(tc.dialect.clone())
151+
.dialect(tc.dialect)
152152
.sql(tc.expect)
153153
.build()
154-
.expect(format!("invalid SQL: {:?}", tc.expect).as_str());
154+
.unwrap_or_else(|_| panic!("invalid SQL: {:?}", tc.expect));
155155
let actual = testfn(ast_a, ast_b);
156156
assert_eq!(actual.to_string(), tc.expect, "{tc:?}");
157157
}

src/migration.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ use thiserror::Error;
1111
#[derive(Error, Debug)]
1212
pub struct MigrateError {
1313
kind: MigrateErrorKind,
14-
statement_a: Option<Statement>,
15-
statement_b: Option<Statement>,
14+
statement_a: Option<Box<Statement>>,
15+
statement_b: Option<Box<Statement>>,
1616
}
1717

1818
impl fmt::Display for MigrateError {
@@ -42,8 +42,8 @@ impl MigrateError {
4242
) -> Self {
4343
Self {
4444
kind,
45-
statement_a,
46-
statement_b,
45+
statement_a: statement_a.map(Box::new),
46+
statement_b: statement_b.map(Box::new),
4747
}
4848
}
4949
}
@@ -54,9 +54,9 @@ enum MigrateErrorKind {
5454
#[error("can't migrate unnamed index")]
5555
UnnamedIndex,
5656
#[error("ALTER TABLE operation \"{0}\" not yet supported")]
57-
AlterTableOpNotImplemented(AlterTableOperation),
57+
AlterTableOpNotImplemented(Box<AlterTableOperation>),
5858
#[error("invalid ALTER TYPE operation \"{0}\"")]
59-
AlterTypeInvalidOp(AlterTypeOperation),
59+
AlterTypeInvalidOp(Box<AlterTypeOperation>),
6060
#[error("not yet supported")]
6161
NotImplemented,
6262
}
@@ -325,7 +325,9 @@ fn migrate_alter_table(
325325
}
326326
op => {
327327
return Err(MigrateError::builder()
328-
.kind(MigrateErrorKind::AlterTableOpNotImplemented(op.clone()))
328+
.kind(MigrateErrorKind::AlterTableOpNotImplemented(Box::new(
329+
op.clone(),
330+
)))
329331
.statement_a(Statement::CreateTable(t.clone()))
330332
.build())
331333
}
@@ -380,9 +382,9 @@ fn migrate_alter_type(
380382
Ok((name, UserDefinedTypeRepresentation::Enum { labels }))
381383
}
382384
UserDefinedTypeRepresentation::Composite { .. } => Err(MigrateError::builder()
383-
.kind(MigrateErrorKind::AlterTypeInvalidOp(
385+
.kind(MigrateErrorKind::AlterTypeInvalidOp(Box::new(
384386
other.operation.clone(),
385-
))
387+
)))
386388
.statement_a(Statement::CreateType {
387389
name,
388390
representation,
@@ -400,9 +402,9 @@ fn migrate_alter_type(
400402
Ok((name, UserDefinedTypeRepresentation::Enum { labels }))
401403
}
402404
UserDefinedTypeRepresentation::Composite { .. } => Err(MigrateError::builder()
403-
.kind(MigrateErrorKind::AlterTypeInvalidOp(
405+
.kind(MigrateErrorKind::AlterTypeInvalidOp(Box::new(
404406
other.operation.clone(),
405-
))
407+
)))
406408
.statement_a(Statement::CreateType {
407409
name,
408410
representation,

src/path_template.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,8 +1070,7 @@ mod tests {
10701070
let mut timestamp = data.timestamp;
10711071
tmpl.segments
10721072
.iter()
1073-
.map(|s| &s.tokens)
1074-
.flatten()
1073+
.flat_map(|s| &s.tokens)
10751074
.for_each(|t| {
10761075
match t {
10771076
Token::Timestamp(ts) => timestamp = ts.clone().try_into().unwrap(),
@@ -1156,7 +1155,7 @@ mod tests {
11561155
eprintln!("{input:?}");
11571156
let template = super::parser::parse(input)
11581157
.context(format!("test case {i:02}"))
1159-
.expect(format!("{input} should parse").as_str());
1158+
.unwrap_or_else(|_| panic!("{input} should parse"));
11601159
let data = data(&template);
11611160
let template = template.with_up_down();
11621161
let out = template.resolve(&data);

0 commit comments

Comments
 (0)