Skip to content

Commit 0edf323

Browse files
authored
chore: update Rust to 1.97.1 (#5849)
## Overview Bumps the pinned toolchain in `rust-toolchain.toml` from 1.92.0 to 1.97.1 and fixes everything the new Clippy complains about, so `make pedantic` is green again. ## Changes The bulk of the diff is the new lint against redundant references in formatting macro arguments. `format!`, `panic!` and `assert_eq!` already take their arguments by reference, so the explicit `&` was pointless. Purely mechanical, no behaviour change. The rest, one by one: - **`sql_schema_differ.rs`** — `Some(TableChange::…).filter(|_| differ.primary_key_changed())` becomes `differ.primary_key_changed().then_some(TableChange::…)`. The lint warns that this reorders the condition against the value; harmless here, since the value is a unit variant and the predicate is a pure query. - **`native_types.rs`, `flavour/postgres.rs`** — `a.and_then(|a| b.map(|b| (a, b)))` becomes `a.zip(b)`. - **`datasource_loader.rs`** — `sort_by(|(a, _), (b, _)| a.cmp(b))` becomes `sort_by_key`. - **`validations/fields.rs`** — the `DecimalType` capability check moves from an `if` inside the match arm into a match guard. - **`quaint/src/ast/values.rs`, `query_document/selection.rs`** — two blocks that returned `None` on the miss now use `?`. - **`configuration.rs`, `statistics.rs`, `differ_database.rs`** — `iter().map(|(_, v)| …)` over maps becomes `values()`. - **`visitor/mssql.rs`** — drop a no-op `into_iter()` on an argument that already accepts `IntoIterator`. ## Inlined format arguments Since the redundant-reference fix was already rewriting those formatting macro calls, the second commit captures their arguments in the format string as well — `panic!("Unknown driver adapter: {}", s)` becomes `panic!("Unknown driver adapter: {s}")`. This is scoped to the lines this PR already touches. Every argument that *can* be captured is, including in calls that also carry arguments that cannot be, so a few strings mix the two styles: ```rust format!("{alter_column_prefix} SET DATA TYPE {}", render_column_type(columns.next, renderer)) ``` What stays positional is only what the language cannot capture: method calls (`field.name()`) and field accesses (`self.schema`). Note that `clippy::uninlined_format_args` only fires when *all* of a call's arguments are capturable, so the mixed cases above are beyond what the lint would ask for. With this PR applied, no fully-capturable call remains on any line it touches. ## Verification - `make pedantic` passes (both the native and the `wasm32-unknown-unknown` Clippy passes). - `make test-unit` passes: 112 test binaries, no failures. --------- Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
1 parent 9d90ce2 commit 0edf323

43 files changed

Lines changed: 101 additions & 143 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

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/parser-database/src/attributes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ fn visit_relation_field_attributes(rfid: RelationFieldId, ctx: &mut Context<'_>)
361361
if ctx.visit_optional_single_attr("id") {
362362
let msg = format!(
363363
"The field `{}` is a relation field and cannot be marked with `@id`. Only scalar fields can be declared as id.",
364-
&ast_field.name(),
364+
ast_field.name(),
365365
);
366366
ctx.push_attribute_validation_error(&msg);
367367
ctx.discard_arguments();

psl/psl-core/src/datamodel_connector/native_types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ impl NativeTypeArguments for (u32, u32) {
164164

165165
fn from_parts(parts: &[String]) -> Option<Self> {
166166
match parts {
167-
[a, b] => a.parse().ok().and_then(|a| b.parse().ok().map(|b| (a, b))),
167+
[a, b] => a.parse().ok().zip(b.parse().ok()),
168168
_ => None,
169169
}
170170
}

psl/psl-core/src/validate/datasource_loader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ fn lift_datasource(
166166
return None;
167167
}
168168

169-
schemas.sort_by(|(a, _), (b, _)| a.cmp(b));
169+
schemas.sort_by_key(|(a, _)| *a);
170170

171171
for pair in schemas.windows(2) {
172172
if pair[0].0 == pair[1].0 {

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

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -295,20 +295,20 @@ pub(super) fn validate_scalar_field_connector_specific(field: ScalarFieldWalker<
295295
}
296296
}
297297

298-
ScalarFieldType::BuiltInScalar(ScalarType::Decimal) => {
299-
if !ctx.has_capability(ConnectorCapability::DecimalType) {
300-
ctx.push_error(DatamodelError::new_field_validation_error(
301-
&format!(
302-
"Field `{}` in {container} `{}` can't be of type Decimal. The current connector does not support the Decimal type.",
303-
field.name(),
304-
field.model().name(),
305-
),
306-
container,
307-
field.model().name(),
298+
ScalarFieldType::BuiltInScalar(ScalarType::Decimal)
299+
if !ctx.has_capability(ConnectorCapability::DecimalType) =>
300+
{
301+
ctx.push_error(DatamodelError::new_field_validation_error(
302+
&format!(
303+
"Field `{}` in {container} `{}` can't be of type Decimal. The current connector does not support the Decimal type.",
308304
field.name(),
309-
field.ast_field().span(),
310-
));
311-
}
305+
field.model().name(),
306+
),
307+
container,
308+
field.model().name(),
309+
field.name(),
310+
field.ast_field().span(),
311+
));
312312
}
313313

314314
_ => (),
@@ -364,11 +364,10 @@ 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),
371-
&source.name,
370+
source.name,
372371
connector.native_type_to_string(&native_type)
373372
);
374373

psl/psl-core/src/validate/validation_pipeline/validations/relations/many_to_many/implicit.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ pub(crate) fn validate_singular_id(relation: ImplicitManyToManyRelationWalker<'_
1414

1515
let message = format!(
1616
"The relation field `{}` on {container} `{}` references `{}` which does not have an `@id` field. Models without `@id` cannot be part of a many to many relation. Use an explicit intermediate Model to represent this relationship.",
17-
&relation_field.name(),
18-
&relation_field.model().name(),
19-
&relation_field.related_model().name(),
17+
relation_field.name(),
18+
relation_field.model().name(),
19+
relation_field.related_model().name(),
2020
);
2121

2222
ctx.push_error(DatamodelError::new_field_validation_error(
@@ -34,7 +34,7 @@ pub(crate) fn validate_singular_id(relation: ImplicitManyToManyRelationWalker<'_
3434
ctx.push_error(DatamodelError::new_validation_error(
3535
&format!(
3636
"Implicit many-to-many relations must always reference the id field of the related model. Change the argument `references` to use the id field of the related model `{}`. But it is referencing the following fields that are not the id: {}",
37-
&relation_field.related_model().name(),
37+
relation_field.related_model().name(),
3838
relation_field.referenced_fields().into_iter().flatten().map(|f| f.name()).collect::<Vec<_>>().join(", ")
3939
),
4040
relation_field.ast_field().span())

0 commit comments

Comments
 (0)