From 6b8acdc28da5fa581dcfee2b441667be8b411a37 Mon Sep 17 00:00:00 2001 From: Jeremy Lempereur Date: Wed, 6 Sep 2023 13:09:34 +0200 Subject: [PATCH] Update rust toolchain to 1.72.0 (#3707) Update rust toolchain to 1.72.0 --- .changesets/maint_igni_rust_1_72_0.md | 5 +++++ Cargo.toml | 2 +- apollo-router-scaffold/templates/base/Dockerfile | 2 +- apollo-router/Cargo.toml | 2 +- apollo-router/README.md | 2 +- apollo-router/src/json_ext.rs | 2 +- apollo-router/src/plugins/authorization/mod.rs | 6 +++--- apollo-router/src/plugins/coprocessor_test.rs | 16 ++++++++-------- apollo-router/src/query_planner/execution.rs | 6 +++--- apollo-router/src/query_planner/labeler.rs | 5 +++-- apollo-router/src/query_planner/plan.rs | 2 +- apollo-router/src/services/execution_service.rs | 4 ++-- apollo-router/src/spec/operation_limits.rs | 5 ++--- apollo-router/src/spec/query/transform.rs | 15 +++++++++------ apollo-router/src/uplink/mod.rs | 2 +- docs/source/customizations/custom-binary.mdx | 2 +- rust-toolchain.toml | 4 ++-- 17 files changed, 45 insertions(+), 37 deletions(-) create mode 100644 .changesets/maint_igni_rust_1_72_0.md diff --git a/.changesets/maint_igni_rust_1_72_0.md b/.changesets/maint_igni_rust_1_72_0.md new file mode 100644 index 0000000000..9371f0dcfa --- /dev/null +++ b/.changesets/maint_igni_rust_1_72_0.md @@ -0,0 +1,5 @@ +### Update rust toolchain to 1.72.0 ([PR #3707](https://github.com/apollographql/router/pull/3707)) + +The router-bridge update now allows us to use the latest rust version. + +By [@o0Ignition0o](https://github.com/o0Ignition0o) in https://github.com/apollographql/router/pull/3707 diff --git a/Cargo.toml b/Cargo.toml index 9c44480765..4861dbc154 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,4 +1,5 @@ [workspace] +resolver = "2" default-members = ["apollo-router"] members = [ "apollo-router", @@ -40,4 +41,3 @@ incremental = false [profile.release-dhat] inherits = "release" debug = 1 - diff --git a/apollo-router-scaffold/templates/base/Dockerfile b/apollo-router-scaffold/templates/base/Dockerfile index 3514b700dc..db76b6d0bb 100644 --- a/apollo-router-scaffold/templates/base/Dockerfile +++ b/apollo-router-scaffold/templates/base/Dockerfile @@ -1,6 +1,6 @@ # Use the rust build image from docker as our base # renovate-automation: rustc version -FROM rust:1.71.1 as build +FROM rust:1.72.0 as build # Set our working directory for the build WORKDIR /usr/src/router diff --git a/apollo-router/Cargo.toml b/apollo-router/Cargo.toml index 7e8d6fed3e..4f91e8a2dc 100644 --- a/apollo-router/Cargo.toml +++ b/apollo-router/Cargo.toml @@ -8,7 +8,7 @@ description = "A configurable, high-performance routing runtime for Apollo Feder license = "Elastic-2.0" # renovate-automation: rustc version -rust-version = "1.71.1" +rust-version = "1.72.0" edition = "2021" build = "build/main.rs" diff --git a/apollo-router/README.md b/apollo-router/README.md index b2e5cec865..4934b8a099 100644 --- a/apollo-router/README.md +++ b/apollo-router/README.md @@ -27,4 +27,4 @@ Most Apollo Router features can be defined using our [YAML configuration](https: If you prefer to write customizations in Rust or need more advanced customizations, see our section on [native customizations](https://www.apollographql.com/docs/router/customizations/native) for information on how to use `apollo-router` as a Rust library. We also publish Rust-specific documentation on our [`apollo-router` crate docs](https://docs.rs/crate/apollo-router). -The minimum supported Rust version (MSRV) for this version of `apollo-router` is **1.71.1**. +The minimum supported Rust version (MSRV) for this version of `apollo-router` is **1.72.0**. diff --git a/apollo-router/src/json_ext.rs b/apollo-router/src/json_ext.rs index e05b010550..6955f15924 100644 --- a/apollo-router/src/json_ext.rs +++ b/apollo-router/src/json_ext.rs @@ -144,7 +144,7 @@ impl ValueExt for Value { a_value.deep_merge(b_value); } - a.extend(b.into_iter()); + a.extend(b); } (_, Value::Null) => {} (Value::Object(_), Value::Array(_)) => { diff --git a/apollo-router/src/plugins/authorization/mod.rs b/apollo-router/src/plugins/authorization/mod.rs index babcc91c1b..7bc42dd114 100644 --- a/apollo-router/src/plugins/authorization/mod.rs +++ b/apollo-router/src/plugins/authorization/mod.rs @@ -252,7 +252,7 @@ impl AuthorizationPlugin { let compiler = match filter_res { None => compiler, Some((query, paths)) => { - unauthorized_paths.extend(paths.into_iter()); + unauthorized_paths.extend(paths); if query.is_empty() { return Err(QueryPlannerError::Unauthorized(unauthorized_paths)); @@ -272,7 +272,7 @@ impl AuthorizationPlugin { let compiler = match filter_res { None => compiler, Some((query, paths)) => { - unauthorized_paths.extend(paths.into_iter()); + unauthorized_paths.extend(paths); if query.is_empty() { return Err(QueryPlannerError::Unauthorized(unauthorized_paths)); @@ -292,7 +292,7 @@ impl AuthorizationPlugin { let compiler = match filter_res { None => compiler, Some((query, paths)) => { - unauthorized_paths.extend(paths.into_iter()); + unauthorized_paths.extend(paths); if query.is_empty() { return Err(QueryPlannerError::Unauthorized(unauthorized_paths)); diff --git a/apollo-router/src/plugins/coprocessor_test.rs b/apollo-router/src/plugins/coprocessor_test.rs index 297391af5e..26ef229eb7 100644 --- a/apollo-router/src/plugins/coprocessor_test.rs +++ b/apollo-router/src/plugins/coprocessor_test.rs @@ -287,7 +287,7 @@ mod tests { Box::pin(async { Ok(hyper::Response::builder() .body(Body::from( - r##"{ + r#"{ "version": 1, "stage": "SubgraphRequest", "control": { @@ -299,7 +299,7 @@ mod tests { "body": "Errors need a message, this will fail to deserialize" }] } - }"##, + }"#, )) .unwrap()) }) @@ -386,7 +386,7 @@ mod tests { Box::pin(async { Ok(hyper::Response::builder() .body(Body::from( - r##"{ + r#"{ "version": 1, "stage": "SubgraphRequest", "control": "continue", @@ -429,7 +429,7 @@ mod tests { }, "serviceName": "service name shouldn't change", "uri": "http://thisurihaschanged" - }"##, + }"#, )) .unwrap()) }) @@ -478,7 +478,7 @@ mod tests { Box::pin(async { Ok(hyper::Response::builder() .body(Body::from( - r##"{ + r#"{ "version": 1, "stage": "SubgraphRequest", "control": { @@ -495,7 +495,7 @@ mod tests { "headers": { "aheader": ["a value"] } - }"##, + }"#, )) .unwrap()) }) @@ -556,7 +556,7 @@ mod tests { Box::pin(async { Ok(hyper::Response::builder() .body(Body::from( - r##"{ + r#"{ "version": 1, "stage": "SubgraphResponse", "headers": { @@ -598,7 +598,7 @@ mod tests { "this-is-a-test-context": 42 } } - }"##, + }"#, )) .unwrap()) }) diff --git a/apollo-router/src/query_planner/execution.rs b/apollo-router/src/query_planner/execution.rs index 0cb52f333f..35945844cc 100644 --- a/apollo-router/src/query_planner/execution.rs +++ b/apollo-router/src/query_planner/execution.rs @@ -439,7 +439,7 @@ impl DeferredNode { let (primary_value, primary_errors) = primary_receiver.recv().await.unwrap_or_default(); value.deep_merge(primary_value); - errors.extend(primary_errors.into_iter()) + errors.extend(primary_errors) } else { while let Some((v, _remaining)) = stream.next().await { // a Err(RecvError) means either that the fetch was not performed and the @@ -486,7 +486,7 @@ impl DeferredNode { let (primary_value, primary_errors) = primary_receiver.recv().await.unwrap_or_default(); v.deep_merge(primary_value); - errors.extend(primary_errors.into_iter()) + errors.extend(primary_errors) } if let Err(e) = tx @@ -511,7 +511,7 @@ impl DeferredNode { let (primary_value, primary_errors) = primary_receiver.recv().await.unwrap_or_default(); value.deep_merge(primary_value); - errors.extend(primary_errors.into_iter()); + errors.extend(primary_errors); if let Err(e) = tx .send( diff --git a/apollo-router/src/query_planner/labeler.rs b/apollo-router/src/query_planner/labeler.rs index cdf7cf4ea6..7bbb095eb7 100644 --- a/apollo-router/src/query_planner/labeler.rs +++ b/apollo-router/src/query_planner/labeler.rs @@ -65,8 +65,9 @@ impl<'a> Visitor for Labeler<'a> { ) -> Result, BoxError> { let parent_type = hir.type_condition().unwrap_or(parent_type); - let Some(selection_set) = selection_set(self, hir.selection_set(), parent_type)? - else { return Ok(None) }; + let Some(selection_set) = selection_set(self, hir.selection_set(), parent_type)? else { + return Ok(None); + }; let mut encoder_node = apollo_encoder::InlineFragment::new(selection_set); diff --git a/apollo-router/src/query_planner/plan.rs b/apollo-router/src/query_planner/plan.rs index b2f87ffe48..803ceaab3b 100644 --- a/apollo-router/src/query_planner/plan.rs +++ b/apollo-router/src/query_planner/plan.rs @@ -234,7 +234,7 @@ impl PlanNode { Self::Subscription { primary, rest } => match rest { Some(rest) => Box::new( rest.service_usage() - .chain(Some(primary.service_name.as_str()).into_iter()), + .chain(Some(primary.service_name.as_str())), ) as Box + 'a>, None => Box::new(Some(primary.service_name.as_str()).into_iter()), }, diff --git a/apollo-router/src/services/execution_service.rs b/apollo-router/src/services/execution_service.rs index 5e38fab3a6..3de41b2891 100644 --- a/apollo-router/src/services/execution_service.rs +++ b/apollo-router/src/services/execution_service.rs @@ -267,9 +267,9 @@ impl ExecutionService { schema.api_schema(), variables_set, ) - .into_iter(), + , ); - nullified_paths.extend(paths.into_iter()); + nullified_paths.extend(paths); }); match (response.path.as_ref(), response.data.as_ref()) { diff --git a/apollo-router/src/spec/operation_limits.rs b/apollo-router/src/spec/operation_limits.rs index e0ed96f15a..c6815382a9 100644 --- a/apollo-router/src/spec/operation_limits.rs +++ b/apollo-router/src/spec/operation_limits.rs @@ -81,12 +81,11 @@ pub(crate) fn check( debug_assert_eq!(ids.len(), 1); let query_id = ids[0]; - let Some(operation) = compiler.db.find_operation(query_id, operation_name.clone()) - else { + let Some(operation) = compiler.db.find_operation(query_id, operation_name.clone()) else { // Undefined or ambiguous operation name. // The request is invalid and will be rejected by some other part of the router, // if it wasn’t already before we got to this code path. - return Ok(()) + return Ok(()); }; let mut fragment_cache = HashMap::new(); diff --git a/apollo-router/src/spec/query/transform.rs b/apollo-router/src/spec/query/transform.rs index 3ece3b907a..76bfe0f9be 100644 --- a/apollo-router/src/spec/query/transform.rs +++ b/apollo-router/src/spec/query/transform.rs @@ -116,8 +116,9 @@ pub(crate) fn operation( .ok_or("ObjectTypeDefMissing")?; let type_name = object_type.name(); - let Some(selection_set) = selection_set(visitor, def.selection_set(), type_name)? - else { return Ok(None) }; + let Some(selection_set) = selection_set(visitor, def.selection_set(), type_name)? else { + return Ok(None); + }; let mut encoder_node = apollo_encoder::OperationDefinition::new(operation_type(def.operation_ty()), selection_set); @@ -151,8 +152,9 @@ pub(crate) fn fragment_definition( let name = hir.name(); let type_condition = hir.type_condition(); - let Some(selection_set) = selection_set(visitor, hir.selection_set(), type_condition)? - else { return Ok(None) }; + let Some(selection_set) = selection_set(visitor, hir.selection_set(), type_condition)? else { + return Ok(None); + }; let type_condition = apollo_encoder::TypeCondition::new(type_condition.into()); let mut encoder_node = @@ -237,8 +239,9 @@ pub(crate) fn inline_fragment( ) -> Result, BoxError> { let parent_type = hir.type_condition().unwrap_or(parent_type); - let Some(selection_set) = selection_set(visitor, hir.selection_set(), parent_type)? - else { return Ok(None) }; + let Some(selection_set) = selection_set(visitor, hir.selection_set(), parent_type)? else { + return Ok(None); + }; let mut encoder_node = apollo_encoder::InlineFragment::new(selection_set); diff --git a/apollo-router/src/uplink/mod.rs b/apollo-router/src/uplink/mod.rs index 2fb38ef4d1..1399a6b606 100644 --- a/apollo-router/src/uplink/mod.rs +++ b/apollo-router/src/uplink/mod.rs @@ -78,7 +78,7 @@ pub enum Endpoints { impl Default for Endpoints { fn default() -> Self { Self::fallback( - vec![GCP_URL, AWS_URL] + [GCP_URL, AWS_URL] .iter() .map(|url| Url::parse(url).expect("default urls must be valid")) .collect(), diff --git a/docs/source/customizations/custom-binary.mdx b/docs/source/customizations/custom-binary.mdx index 0934ac7cca..e5a7750124 100644 --- a/docs/source/customizations/custom-binary.mdx +++ b/docs/source/customizations/custom-binary.mdx @@ -20,7 +20,7 @@ import ElasticNotice from '../../shared/elastic-notice.mdx'; To compile the Apollo Router, you need to have the following installed: -* [Rust 1.71.1 or later](https://www.rust-lang.org/tools/install) +* [Rust 1.72.0 or later](https://www.rust-lang.org/tools/install) * [Node.js 16.9.1 or later](https://nodejs.org/en/download/) * [CMake 3.5.1 or later](https://cmake.org/download/) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index d502368c84..4bfc48e551 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] # renovate-automation: rustc version -channel = "1.71.1" -components = [ "rustfmt", "clippy" ] +channel = "1.72.0" +components = ["rustfmt", "clippy"]