Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion juniper_codegen/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand All @@ -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



Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion juniper_codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
7 changes: 5 additions & 2 deletions juniper_codegen/src/common/parse/downcaster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ pub(crate) fn output_type(ret_ty: &syn::ReturnType) -> Result<syn::Type, Span> {
};

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()),
};

Expand Down Expand Up @@ -66,7 +68,8 @@ pub(crate) fn output_type(ret_ty: &syn::ReturnType) -> Result<syn::Type, Span> {
pub(crate) fn context_ty(sig: &syn::Signature) -> Result<Option<syn::Type>, 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());
}
}
Expand Down
6 changes: 3 additions & 3 deletions juniper_codegen/src/common/parse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion juniper_codegen/src/graphql_object/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion juniper_codegen/src/scalar_value/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ impl TryFrom<syn::Fields> for Field {
fn try_from(value: syn::Fields) -> Result<Self, Self::Error> {
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")),
Expand Down
Loading