Skip to content

Commit 7b506ab

Browse files
committed
chore: inline format args on the lines already touched
These formatting macro calls were already being rewritten to drop redundant references, so capture their arguments in the format string too. Arguments that cannot be captured — method calls and field accesses — stay positional, so a few of these strings mix the two styles. Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
1 parent 5ee4cc3 commit 7b506ab

24 files changed

Lines changed: 53 additions & 77 deletions

File tree

libs/driver-adapters/src/conversion/mysql.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ mod test {
9898
for (val, expected) in test_cases {
9999
let actual = value_to_js_arg(&val.clone().into_value()).unwrap();
100100
if actual != expected {
101-
errors.push(format!("transforming: {:?}, expected: {:?}, actual: {:?}", val, expected, actual));
101+
errors.push(format!("transforming: {val:?}, expected: {expected:?}, actual: {actual:?}"));
102102
}
103103
}
104104
assert_eq!(errors.len(), 0, "{}", errors.join("\n"));

libs/driver-adapters/src/conversion/postgres.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ mod test {
100100
for (val, expected) in test_cases {
101101
let actual = value_to_js_arg(&val).unwrap();
102102
if actual != expected {
103-
errors.push(format!("transforming: {:?}, expected: {:?}, actual: {:?}", val, expected, actual));
103+
errors.push(format!("transforming: {val:?}, expected: {expected:?}, actual: {actual:?}"));
104104
}
105105
}
106106
assert_eq!(errors.len(), 0, "{}", errors.join("\n"));

libs/driver-adapters/src/conversion/sqlite.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ mod test {
105105
for (val, expected) in test_cases {
106106
let actual = value_to_js_arg(&val.clone().into_value()).unwrap();
107107
if actual != expected {
108-
errors.push(format!("transforming: {:?}, expected: {:?}, actual: {:?}", val, expected, actual));
108+
errors.push(format!("transforming: {val:?}, expected: {expected:?}, actual: {actual:?}"));
109109
}
110110
}
111111
assert_eq!(errors.len(), 0, "{}", errors.join("\n"));

libs/user-facing-errors/src/query_engine/validation.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -203,17 +203,13 @@ impl ValidationError {
203203
let (message, meta) = if let Some(err) = underlying_err {
204204
let err_msg = err.to_string();
205205
let message = format!(
206-
"Invalid argument value. `{}` is not a valid `{}`. Underlying error: {}",
207-
value, expected_argument_type, err_msg
206+
"Invalid argument value. `{value}` is not a valid `{expected_argument_type}`. Underlying error: {err_msg}"
208207
);
209208
let argument = ArgumentDescription::new(*argument_name, vec![Cow::Borrowed(expected_argument_type)]);
210209
let meta = json!({"argumentPath": argument_path, "argument": argument, "selectionPath": selection_path, "underlyingError": &err_msg});
211210
(message, Some(meta))
212211
} else {
213-
let message = format!(
214-
"Invalid argument value. `{}` is not a valid `{}`",
215-
value, expected_argument_type
216-
);
212+
let message = format!("Invalid argument value. `{value}` is not a valid `{expected_argument_type}`");
217213
let argument = ArgumentDescription::new(*argument_name, vec![Cow::Borrowed(expected_argument_type)]);
218214
let meta = json!({"argumentPath": argument_path, "argument": argument, "selectionPath": selection_path, "underlyingError": serde_json::Value::Null});
219215
(message, Some(meta))
@@ -469,7 +465,7 @@ impl ValidationError {
469465
/// }
470466
/// }
471467
pub fn selection_set_on_scalar(field_name: String, selection_path: Vec<&str>) -> Self {
472-
let message = format!("Cannot select over scalar field '{}'", field_name);
468+
let message = format!("Cannot select over scalar field '{field_name}'");
473469
ValidationError {
474470
kind: ValidationErrorKind::SelectionSetOnScalar,
475471
message,

libs/user-facing-errors/src/schema_engine.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl crate::UserFacingError for MigrationDoesNotApplyCleanly {
7171
message: _,
7272
meta: _,
7373
error_code,
74-
}) => format!("Error code: {}\n", error_code),
74+
}) => format!("Error code: {error_code}\n"),
7575
crate::ErrorType::Unknown(_) => String::new(),
7676
};
7777

@@ -170,7 +170,7 @@ impl crate::UserFacingError for ShadowDbCreationError {
170170
message: _,
171171
meta: _,
172172
error_code,
173-
}) => format!("Error code: {}\n", error_code),
173+
}) => format!("Error code: {error_code}\n"),
174174
crate::ErrorType::Unknown(_) => String::new(),
175175
};
176176

@@ -205,7 +205,7 @@ impl crate::UserFacingError for SoftResetFailed {
205205
message: _,
206206
meta: _,
207207
error_code,
208-
}) => format!("Error code: {}\n", error_code),
208+
}) => format!("Error code: {error_code}\n"),
209209
crate::ErrorType::Unknown(_) => String::new(),
210210
};
211211

psl/psl-core/src/validate/validation_pipeline/validations/fields.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,7 @@ pub(super) fn validate_unsupported_field_type(field: ScalarFieldWalker<'_>, ctx:
364364
&& let Some(prisma_type) = connector.scalar_type_for_native_type(&native_type, ctx.extension_types)
365365
{
366366
let msg = format!(
367-
"The type `Unsupported(\"{}\")` you specified in the type definition for the field `{}` is supported as a native type by Prisma. Please use the native type notation `{} @{}.{}` for full support.",
368-
unsupported_lit,
367+
"The type `Unsupported(\"{unsupported_lit}\")` you specified in the type definition for the field `{}` is supported as a native type by Prisma. Please use the native type notation `{} @{}.{}` for full support.",
369368
field.name(),
370369
prisma_type.display(ctx.db),
371370
source.name,

psl/psl-core/src/validate/validation_pipeline/validations/relations/one_to_one.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,11 @@ pub(crate) fn fields_and_references_are_defined(relation: InlineRelationWalker<'
4141

4242
if is_empty_fields(forward.referencing_fields()) && is_empty_fields(back.referencing_fields()) {
4343
let message = format!(
44-
"The relation fields `{}` on Model `{}` and `{}` on Model `{}` do not provide the `fields` argument in the {} attribute. You have to provide it on one of the two fields.",
44+
"The relation fields `{}` on Model `{}` and `{}` on Model `{}` do not provide the `fields` argument in the {RELATION_ATTRIBUTE_NAME} attribute. You have to provide it on one of the two fields.",
4545
forward.name(),
4646
forward.model().name(),
4747
back.name(),
4848
back.model().name(),
49-
RELATION_ATTRIBUTE_NAME
5049
);
5150

5251
ctx.push_error(DatamodelError::new_attribute_validation_error(

psl/psl/tests/common/asserts.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ impl WarningAsserts for Vec<DatamodelWarning> {
115115
assert_eq!(
116116
self.len(),
117117
1,
118-
"Expected exactly one validation warning. Warnings are: {:?}",
119-
self
118+
"Expected exactly one validation warning. Warnings are: {self:?}"
120119
);
121120
assert_eq!(self[0], warning);
122121
self
@@ -696,7 +695,7 @@ impl DefaultValueAssert for ast::Expression {
696695
panic!("Expected a numeric value for the `cuid()` version.");
697696
}
698697
} else {
699-
panic!("Expected `cuid()` to be a function, got {}", self);
698+
panic!("Expected `cuid()` to be a function, got {self}");
700699
}
701700

702701
self
@@ -720,7 +719,7 @@ impl DefaultValueAssert for ast::Expression {
720719
panic!("Expected a numeric value for the `uuid()` version.");
721720
}
722721
} else {
723-
panic!("Expected `cuid()` to be a function, got {}", self);
722+
panic!("Expected `cuid()` to be a function, got {self}");
724723
}
725724

726725
self

quaint/src/tests/query.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1683,11 +1683,11 @@ async fn op_test_div_one_level(api: &mut dyn TestApi) -> crate::Result<()> {
16831683
#[test_each_connector(tags("postgresql"))]
16841684
async fn enum_values(api: &mut dyn TestApi) -> crate::Result<()> {
16851685
let type_name = api.get_name();
1686-
let create_type = format!("CREATE TYPE {} AS ENUM ('A', 'B')", type_name);
1686+
let create_type = format!("CREATE TYPE {type_name} AS ENUM ('A', 'B')");
16871687
api.conn().raw_cmd(&create_type).await?;
16881688

16891689
let table = api
1690-
.create_temp_table(&format!("id SERIAL PRIMARY KEY, value {}", type_name))
1690+
.create_temp_table(&format!("id SERIAL PRIMARY KEY, value {type_name}"))
16911691
.await?;
16921692

16931693
api.conn()

quaint/src/tests/query/error.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ async fn foreign_key_constraint_violation(api: &mut dyn TestApi) -> crate::Resul
240240
let parent = api.create_temp_table("id smallint not null primary key").await?;
241241
let foreign_key = api.foreign_key(&parent, "id", "parent_id");
242242
let child = api
243-
.create_temp_table(&format!("parent_id smallint not null, {}", foreign_key))
243+
.create_temp_table(&format!("parent_id smallint not null, {foreign_key}"))
244244
.await?;
245245

246246
let insert = Insert::single_into(&child).value("parent_id", 10);
@@ -267,11 +267,10 @@ async fn ms_my_foreign_key_constraint_violation(api: &mut dyn TestApi) -> crate:
267267

268268
let create_table = format!(
269269
r#"
270-
CREATE TABLE {} (
270+
CREATE TABLE {child_table} (
271271
parent_id smallint not null,
272-
CONSTRAINT {} FOREIGN KEY (parent_id) REFERENCES {}(id))
273-
"#,
274-
child_table, constraint, parent_table
272+
CONSTRAINT {constraint} FOREIGN KEY (parent_id) REFERENCES {parent_table}(id))
273+
"#
275274
);
276275

277276
api.conn().raw_cmd(&create_table).await?;
@@ -284,8 +283,8 @@ async fn ms_my_foreign_key_constraint_violation(api: &mut dyn TestApi) -> crate:
284283
let err = result.unwrap_err();
285284
assert!(matches!(err.kind(), ErrorKind::ForeignKeyConstraintViolation { .. }));
286285

287-
api.conn().raw_cmd(&format!("DROP TABLE {}", child_table)).await?;
288-
api.conn().raw_cmd(&format!("DROP TABLE {}", parent_table)).await?;
286+
api.conn().raw_cmd(&format!("DROP TABLE {child_table}")).await?;
287+
api.conn().raw_cmd(&format!("DROP TABLE {parent_table}")).await?;
289288

290289
Ok(())
291290
}
@@ -405,10 +404,7 @@ async fn unsupported_column_type(api: &mut dyn TestApi) -> crate::Result<()> {
405404
let table = api.create_temp_table("point point, points point[]").await?;
406405
api.conn()
407406
.query_raw(
408-
&format!(
409-
r#"INSERT INTO {} ("point", "points") VALUES (Point(1,2), '{{"(1, 2)", "(2, 3)"}}')"#,
410-
table
411-
),
407+
&format!(r#"INSERT INTO {table} ("point", "points") VALUES (Point(1,2), '{{"(1, 2)", "(2, 3)"}}')"#),
412408
&[],
413409
)
414410
.await?;

0 commit comments

Comments
 (0)