From 9649fa87098f0b7d342a9cbe4191189b122af6ff Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Jul 2026 14:23:33 +0000 Subject: [PATCH 1/3] Update syn requirement from 2.0 to 3.0 Updates the requirements on [syn](https://github.com/dtolnay/syn) to permit the latest version. - [Release notes](https://github.com/dtolnay/syn/releases) - [Commits](https://github.com/dtolnay/syn/compare/2.0.0...3.0.2) --- updated-dependencies: - dependency-name: syn dependency-version: 3.0.2 dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- juniper_codegen/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/juniper_codegen/Cargo.toml b/juniper_codegen/Cargo.toml index 8d53b2207..0232ccd56 100644 --- a/juniper_codegen/Cargo.toml +++ b/juniper_codegen/Cargo.toml @@ -25,7 +25,7 @@ proc-macro = true derive_more = { version = "2.0", features = ["as_ref", "deref", "display"] } proc-macro2 = "1.0.4" quote = "1.0.9" -syn = { version = "2.0", features = ["extra-traits", "full", "visit", "visit-mut"] } +syn = { version = "3.0", features = ["extra-traits", "full", "visit", "visit-mut"] } url = "2.0" [dev-dependencies] From 2a1c14055457f8d8cc97d242d55e9f37b24d9bdc Mon Sep 17 00:00:00 2001 From: Kai Ren Date: Sun, 30 Aug 2026 10:03:03 +0200 Subject: [PATCH 2/3] Migrate code --- juniper_codegen/src/common/parse/downcaster.rs | 7 +++++-- juniper_codegen/src/common/parse/mod.rs | 6 +++--- juniper_codegen/src/graphql_object/attr.rs | 2 +- juniper_codegen/src/scalar_value/mod.rs | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/juniper_codegen/src/common/parse/downcaster.rs b/juniper_codegen/src/common/parse/downcaster.rs index 4a951d92f..2e0229345 100644 --- a/juniper_codegen/src/common/parse/downcaster.rs +++ b/juniper_codegen/src/common/parse/downcaster.rs @@ -22,7 +22,9 @@ pub(crate) fn output_type(ret_ty: &syn::ReturnType) -> Result { }; let path = match ret_ty.unparenthesized() { - syn::Type::Path(syn::TypePath { qself: None, path }) => path, + syn::Type::Path(syn::TypePath { + qself: None, path, .. + }) => path, _ => return Err(ret_ty.span()), }; @@ -66,7 +68,8 @@ pub(crate) fn output_type(ret_ty: &syn::ReturnType) -> Result { pub(crate) fn context_ty(sig: &syn::Signature) -> Result, Span> { match sig.receiver() { Some(rcv) => { - if rcv.reference.is_none() || rcv.mutability.is_some() { + // Only `&self` is expected in method's signature. + if !matches!(rcv.kind, syn::ReceiverKind::Reference(_, _, None)) { return Err(rcv.span()); } } diff --git a/juniper_codegen/src/common/parse/mod.rs b/juniper_codegen/src/common/parse/mod.rs index 487e0552c..f8b25a2a6 100644 --- a/juniper_codegen/src/common/parse/mod.rs +++ b/juniper_codegen/src/common/parse/mod.rs @@ -157,8 +157,8 @@ impl TypeExt for syn::Type { } } syn::PathArguments::Parenthesized(args) => { - for ty in args.inputs.iter_mut() { - ty.lifetimes_iter_mut(func) + for arg in args.inputs.iter_mut() { + arg.ty.lifetimes_iter_mut(func) } if let syn::ReturnType::Type(_, ty) = &mut args.output { (*ty).lifetimes_iter_mut(func) @@ -213,7 +213,7 @@ impl TypeExt for syn::Type { T::Path(ty) => iter_path(&mut ty.path, func), // These types unlikely will be used as GraphQL types. - T::BareFn(_) | T::Infer(_) | T::Macro(_) | T::Never(_) | T::Verbatim(_) => {} + T::FnPtr(_) | T::Infer(_) | T::Macro(_) | T::Never(_) | T::Verbatim(_) => {} // Following the `syn` idiom for exhaustive matching on `Type`: // https://docs.rs/syn/2.0.38/src/syn/ty.rs.html#64-79 diff --git a/juniper_codegen/src/graphql_object/attr.rs b/juniper_codegen/src/graphql_object/attr.rs index e4a92d40e..f79347ce3 100644 --- a/juniper_codegen/src/graphql_object/attr.rs +++ b/juniper_codegen/src/graphql_object/attr.rs @@ -187,7 +187,7 @@ fn parse_field( if let Some(arg) = method.sig.inputs.first() { match arg { syn::FnArg::Receiver(rcv) => { - if rcv.reference.is_none() || rcv.mutability.is_some() { + if !matches!(rcv.kind, syn::ReceiverKind::Reference(_, _, None)) { return err_invalid_method_receiver(rcv); } } diff --git a/juniper_codegen/src/scalar_value/mod.rs b/juniper_codegen/src/scalar_value/mod.rs index 48745192d..5e6f594a3 100644 --- a/juniper_codegen/src/scalar_value/mod.rs +++ b/juniper_codegen/src/scalar_value/mod.rs @@ -429,7 +429,7 @@ impl TryFrom for Field { fn try_from(value: syn::Fields) -> Result { match value { syn::Fields::Named(mut f) if f.named.len() == 1 => { - Ok(Self::Named(Box::new(f.named.pop().unwrap().into_value()))) + Ok(Self::Named(Box::new(f.named.pop().unwrap()))) } syn::Fields::Unnamed(f) if f.unnamed.len() == 1 => Ok(Self::Unnamed), _ => Err(ERR.custom_error(value.span(), "expected exactly 1 field")), From 8b6bbb221233fe80740c2c2e67fd31648ef9474d Mon Sep 17 00:00:00 2001 From: Kai Ren Date: Sun, 30 Aug 2026 10:06:29 +0200 Subject: [PATCH 3/3] Add CHANGELOG --- juniper_codegen/CHANGELOG.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/juniper_codegen/CHANGELOG.md b/juniper_codegen/CHANGELOG.md index b1bcd67f1..242585b9c 100644 --- a/juniper_codegen/CHANGELOG.md +++ b/juniper_codegen/CHANGELOG.md @@ -18,6 +18,10 @@ All user visible changes to `juniper_codegen` crate will be documented in this f - Placing `#[graphql(deprecated)]` attribute on method arguments in `#[graphql_object]` and `#[graphql_interface]` macros. - Support of `#[graphql(rename_all = "snake_case")]` attribute. ([#1354]) +### Changed + +- Migrated to [3.0][syn-3.0] version of [`syn`] crate. ([#1389]) + ### Fixed - Memory leak caused by incorrect error handling in `#[graphql_subscription]` macro expansion. ([#1371]) @@ -29,9 +33,11 @@ All user visible changes to `juniper_codegen` crate will be documented in this f [#1348]: /../../pull/1348 [#1354]: /../../pull/1354 [#1371]: /../../pull/1371 +[#1389]: /../../pull/1389 [graphql/graphql-spec#525]: https://github.com/graphql/graphql-spec/pull/525 [graphql/graphql-spec#805]: https://github.com/graphql/graphql-spec/pull/805 [graphql/graphql-spec#825]: https://github.com/graphql/graphql-spec/pull/825 +[syn-3.0]: https://github.com/dtolnay/syn/releases/tag/3.0.0 @@ -111,7 +117,7 @@ All user visible changes to `juniper_codegen` crate will be documented in this f ### Changed -- Migrated to 2 version of `syn` crate. ([#1157]) +- Migrated to [2.0][syn-2.0] version of [`syn`] crate. ([#1157]) ### Fixed @@ -133,10 +139,12 @@ All user visible changes to `juniper_codegen` crate will be documented in this f [#1054]: /../../pull/1054 [#1157]: /../../pull/1157 [#1245]: /../../pull/1245 +[syn-2.0]: https://github.com/dtolnay/syn/releases/tag/2.0.0 +[`syn`]: https://docs.rs/syn [MSRV]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-rust-version-field [orphan rules]: https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules [Semantic Versioning 2.0.0]: https://semver.org