Skip to content

Commit fba1306

Browse files
authored
chore: update rust to 1.89.0 (#5587)
Update Rust to 1.89.0 and fix new compiler and clippy warnings.
1 parent 94468c2 commit fba1306

44 files changed

Lines changed: 345 additions & 350 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/query-engine-common/src/tracer.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ pub async fn start_trace(
2929
.and_then(|tc| tc.traceparent)
3030
.and_then(|tp| tp.parse::<TraceParent>().ok());
3131

32-
if let Some(traceparent) = traceparent {
33-
if traceparent.sampled() {
34-
exporter
35-
.start_capturing(request_id, CaptureSettings::new(CaptureTarget::Spans))
36-
.await;
37-
}
32+
if let Some(traceparent) = traceparent
33+
&& traceparent.sampled()
34+
{
35+
exporter
36+
.start_capturing(request_id, CaptureSettings::new(CaptureTarget::Spans))
37+
.await;
3838
}
3939

4040
Ok(traceparent)

libs/telemetry/src/exporter.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -200,18 +200,18 @@ impl Exporter {
200200
}
201201

202202
Message::AddSpan(request_id, span) => {
203-
if let Some(trace) = traces.get_mut(&request_id) {
204-
if trace.settings.filter(CaptureTarget::Spans) {
205-
trace.data.spans.push(span.into());
206-
}
203+
if let Some(trace) = traces.get_mut(&request_id)
204+
&& trace.settings.filter(CaptureTarget::Spans)
205+
{
206+
trace.data.spans.push(span.into());
207207
}
208208
}
209209

210210
Message::AddEvent(request_id, event) => {
211-
if let Some(trace) = traces.get_mut(&request_id) {
212-
if trace.settings.filter(event.level.into()) {
213-
trace.data.events.push(event.into());
214-
}
211+
if let Some(trace) = traces.get_mut(&request_id)
212+
&& trace.settings.filter(event.level.into())
213+
{
214+
trace.data.events.push(event.into());
215215
}
216216
}
217217
}

prisma-fmt/src/code_actions/block.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,17 @@ pub(super) fn create_missing_block_for_model(
4848
model.newline(),
4949
);
5050

51-
if let Some(ds) = context.datasource() {
52-
if ds.active_provider == "mongodb" {
53-
push_missing_block(
54-
diag,
55-
context.params.text_document.uri.clone(),
56-
range,
57-
"type",
58-
actions,
59-
model.newline(),
60-
);
61-
}
51+
if let Some(ds) = context.datasource()
52+
&& ds.active_provider == "mongodb"
53+
{
54+
push_missing_block(
55+
diag,
56+
context.params.text_document.uri.clone(),
57+
range,
58+
"type",
59+
actions,
60+
model.newline(),
61+
);
6262
}
6363
})
6464
}

prisma-fmt/src/text_document_completion.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,16 +112,16 @@ fn push_ast_completions(ctx: CompletionContext<'_>, completion_list: &mut Comple
112112
ast::FieldPosition::Attribute("relation", _, AttributePosition::ArgumentValue(attr_name, value)),
113113
),
114114
) => {
115-
if let Some(attr_name) = attr_name {
116-
if attr_name == "onDelete" || attr_name == "onUpdate" {
117-
ctx.connector()
118-
.referential_actions(&relation_mode)
119-
.iter()
120-
.filter(|ref_action| ref_action.to_string().starts_with(&value))
121-
.for_each(|referential_action| {
122-
referential_actions::referential_action_completion(completion_list, referential_action)
123-
});
124-
}
115+
if let Some(attr_name) = attr_name
116+
&& (attr_name == "onDelete" || attr_name == "onUpdate")
117+
{
118+
ctx.connector()
119+
.referential_actions(&relation_mode)
120+
.iter()
121+
.filter(|ref_action| ref_action.to_string().starts_with(&value))
122+
.for_each(|referential_action| {
123+
referential_actions::referential_action_completion(completion_list, referential_action)
124+
});
125125
}
126126
}
127127

psl/parser-database/src/attributes.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -802,16 +802,16 @@ fn visit_relation(model_id: crate::ModelId, relation_field_id: RelationFieldId,
802802
}
803803

804804
// Validate referential actions.
805-
if let Some(on_delete) = ctx.visit_optional_arg("onDelete") {
806-
if let Some(action) = crate::ReferentialAction::try_from_expression(on_delete, ctx.diagnostics) {
807-
ctx.types[relation_field_id].on_delete = Some((action, on_delete.span()));
808-
}
805+
if let Some(on_delete) = ctx.visit_optional_arg("onDelete")
806+
&& let Some(action) = crate::ReferentialAction::try_from_expression(on_delete, ctx.diagnostics)
807+
{
808+
ctx.types[relation_field_id].on_delete = Some((action, on_delete.span()));
809809
}
810810

811-
if let Some(on_update) = ctx.visit_optional_arg("onUpdate") {
812-
if let Some(action) = crate::ReferentialAction::try_from_expression(on_update, ctx.diagnostics) {
813-
ctx.types[relation_field_id].on_update = Some((action, on_update.span()));
814-
}
811+
if let Some(on_update) = ctx.visit_optional_arg("onUpdate")
812+
&& let Some(action) = crate::ReferentialAction::try_from_expression(on_update, ctx.diagnostics)
813+
{
814+
ctx.types[relation_field_id].on_update = Some((action, on_update.span()));
815815
}
816816

817817
let fk_name = {

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -119,19 +119,19 @@ impl ConstraintNames {
119119
connector: &dyn Connector,
120120
double_at: bool,
121121
) -> Option<DatamodelError> {
122-
if let Some(name) = name {
123-
if name.len() > connector.max_identifier_length() {
124-
let ats = if double_at { "@@" } else { "@" };
125-
return Some(DatamodelError::new_model_validation_error(
126-
&format!(
127-
"The constraint name '{name}' specified in the `map` argument for the `{ats}{attribute}` constraint is too long for your chosen provider. The maximum allowed length is {} bytes.",
128-
connector.max_identifier_length()
129-
),
130-
"model",
131-
object_name,
132-
span,
133-
));
134-
}
122+
if let Some(name) = name
123+
&& name.len() > connector.max_identifier_length()
124+
{
125+
let ats = if double_at { "@@" } else { "@" };
126+
return Some(DatamodelError::new_model_validation_error(
127+
&format!(
128+
"The constraint name '{name}' specified in the `map` argument for the `{ats}{attribute}` constraint is too long for your chosen provider. The maximum allowed length is {} bytes.",
129+
connector.max_identifier_length()
130+
),
131+
"model",
132+
object_name,
133+
span,
134+
));
135135
}
136136
None
137137
}

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,13 @@ fn lift_datasource(
179179
};
180180

181181
if let Some((shadow_url, _)) = &shadow_database_url {
182-
if let (Some(direct_url), Some(direct_url_span)) = (&direct_url, direct_url_span) {
183-
if shadow_url == direct_url {
184-
diagnostics.push_error(DatamodelError::new_shadow_database_is_same_as_direct_url_error(
185-
source_name,
186-
direct_url_span,
187-
));
188-
}
182+
if let (Some(direct_url), Some(direct_url_span)) = (&direct_url, direct_url_span)
183+
&& shadow_url == direct_url
184+
{
185+
diagnostics.push_error(DatamodelError::new_shadow_database_is_same_as_direct_url_error(
186+
source_name,
187+
direct_url_span,
188+
));
189189
}
190190

191191
if shadow_url == &url {

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ fn lift_generator(
6161
.collect::<Option<HashMap<_, _>>>()?;
6262

6363
// E.g., "library"
64-
if let Some(expr) = args.get(ENGINE_TYPE_KEY) {
65-
if !expr.is_string() {
66-
diagnostics.push_error(DatamodelError::new_type_mismatch_error(
67-
"String",
68-
expr.describe_value_type(),
69-
&expr.to_string(),
70-
expr.span(),
71-
))
72-
}
64+
if let Some(expr) = args.get(ENGINE_TYPE_KEY)
65+
&& !expr.is_string()
66+
{
67+
diagnostics.push_error(DatamodelError::new_type_mismatch_error(
68+
"String",
69+
expr.describe_value_type(),
70+
&expr.to_string(),
71+
expr.span(),
72+
))
7373
}
7474

7575
// E.g., "prisma-client-js"

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,10 @@ pub(crate) fn validate_length_used_with_correct_types(
123123
return;
124124
}
125125

126-
if let Some(r#type) = attr.as_index_field().scalar_field_type().as_builtin_scalar() {
127-
if [ScalarType::String, ScalarType::Bytes].iter().any(|t| t == &r#type) {
128-
return;
129-
}
126+
if let Some(r#type) = attr.as_index_field().scalar_field_type().as_builtin_scalar()
127+
&& [ScalarType::String, ScalarType::Bytes].iter().any(|t| t == &r#type)
128+
{
129+
return;
130130
};
131131

132132
let message = "The length argument is only allowed with field types `String` or `Bytes`.";
@@ -148,16 +148,16 @@ pub(super) fn validate_native_type_arguments<'db>(field: impl Into<TypedFieldWal
148148
};
149149

150150
// Validate that the attribute is scoped with the right datasource name.
151-
if let Some(datasource) = ctx.datasource {
152-
if datasource.name != attr_scope {
153-
let suggestion = [datasource.name.as_str(), type_name].join(".");
154-
ctx.push_error(DatamodelError::new_invalid_prefix_for_native_types(
155-
attr_scope,
156-
&datasource.name,
157-
&suggestion,
158-
span,
159-
));
160-
}
151+
if let Some(datasource) = ctx.datasource
152+
&& datasource.name != attr_scope
153+
{
154+
let suggestion = [datasource.name.as_str(), type_name].join(".");
155+
ctx.push_error(DatamodelError::new_invalid_prefix_for_native_types(
156+
attr_scope,
157+
&datasource.name,
158+
&suggestion,
159+
span,
160+
));
161161
}
162162

163163
let constructor = if let Some(cons) = ctx.connector.find_native_type_constructor(type_name) {

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

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -48,24 +48,23 @@ pub(super) fn unique_index_has_a_unique_custom_name_per_model(
4848
) {
4949
let model = index.model();
5050

51-
if let Some(name) = index.name() {
52-
if names
51+
if let Some(name) = index.name()
52+
&& names
5353
.constraint_namespace
5454
.local_custom_name_scope_violations(model.id, name.as_ref())
55-
{
56-
let message = format!(
57-
"The given custom name `{name}` has to be unique on the model. Please provide a different name for the `name` argument."
58-
);
59-
60-
let from_arg = index.ast_attribute().span_for_argument("name");
61-
let span = from_arg.unwrap_or(index.ast_attribute().span);
62-
63-
ctx.push_error(DatamodelError::new_attribute_validation_error(
64-
&message,
65-
index.attribute_name(),
66-
span,
67-
));
68-
}
55+
{
56+
let message = format!(
57+
"The given custom name `{name}` has to be unique on the model. Please provide a different name for the `name` argument."
58+
);
59+
60+
let from_arg = index.ast_attribute().span_for_argument("name");
61+
let span = from_arg.unwrap_or(index.ast_attribute().span);
62+
63+
ctx.push_error(DatamodelError::new_attribute_validation_error(
64+
&message,
65+
index.attribute_name(),
66+
span,
67+
));
6968
}
7069
}
7170

@@ -270,14 +269,14 @@ pub(crate) fn clustering_can_be_defined_only_once(index: IndexWalker<'_>, ctx: &
270269
return;
271270
}
272271

273-
if let Some(pk) = index.model().primary_key() {
274-
if matches!(pk.clustered(), Some(true) | None) {
275-
ctx.push_error(DatamodelError::new_attribute_validation_error(
276-
"A model can only hold one clustered index or key.",
277-
index.attribute_name(),
278-
index.ast_attribute().span,
279-
));
280-
}
272+
if let Some(pk) = index.model().primary_key()
273+
&& matches!(pk.clustered(), Some(true) | None)
274+
{
275+
ctx.push_error(DatamodelError::new_attribute_validation_error(
276+
"A model can only hold one clustered index or key.",
277+
index.attribute_name(),
278+
index.ast_attribute().span,
279+
));
281280
}
282281

283282
for other in index.model().indexes() {

0 commit comments

Comments
 (0)