Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update syn requirement from 1.0.90 to 2.0.13 #1157

Merged
merged 16 commits into from
Nov 1, 2023
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
12 changes: 4 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,13 @@ jobs:
strategy:
fail-fast: false
matrix:
msrv: ["1.65.0"]
msrv: ["1.73.0"]
crate:
- juniper_codegen
- juniper
- juniper_subscriptions
- juniper_graphql_ws
#- juniper_actix
- juniper_actix
- juniper_hyper
#- juniper_iron
- juniper_rocket
Expand All @@ -156,10 +156,6 @@ jobs:
- ubuntu
- macOS
- windows
include:
- { msrv: "1.68.0", crate: "juniper_actix", os: "ubuntu" }
- { msrv: "1.68.0", crate: "juniper_actix", os: "macOS" }
- { msrv: "1.68.0", crate: "juniper_actix", os: "windows" }
runs-on: ${{ matrix.os }}-latest
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -217,10 +213,10 @@ jobs:
- beta
- nightly
exclude:
- crate: juniper_codegen_tests
toolchain: stable
- crate: juniper_codegen_tests
toolchain: beta
- crate: juniper_codegen_tests
toolchain: nightly
- crate: juniper_codegen_tests
os: macOS
- crate: juniper_codegen_tests
Expand Down
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ ifeq ($(shell rustup component list --toolchain=nightly \
rustup component add --toolchain=nightly rust-src
endif
endif
cargo $(if $(call eq,$(careful),yes),+nightly careful,\
$(if $(call eq,$(crate),juniper_codegen_tests),+nightly,)) \
cargo $(if $(call eq,$(careful),yes),+nightly careful,) \
test $(if $(call eq,$(crate),),--workspace,-p $(crate)) --all-features


Expand Down
4 changes: 2 additions & 2 deletions juniper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "juniper"
version = "0.16.0-dev"
edition = "2021"
rust-version = "1.65"
rust-version = "1.73"
description = "GraphQL server library."
license = "BSD-2-Clause"
authors = [
Expand Down Expand Up @@ -68,7 +68,7 @@ time = { version = "0.3", features = ["formatting", "macros", "parsing"], option
url = { version = "2.0", optional = true }
uuid = { version = "1.3", default-features = false, optional = true }

# Fixes for MSRV check.
# Fixes for `minimal-versions` check.
# TODO: Try remove on upgrade of `bigdecimal` crate.
num-bigint = { version = "0.4.2", optional = true }
# TODO: Try remove on upgrade of `chrono-tz` crate.
Expand Down
2 changes: 1 addition & 1 deletion juniper/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Juniper (GraphQL server library for Rust)
[![Crates.io](https://img.shields.io/crates/v/juniper.svg?maxAge=2592000)](https://crates.io/crates/juniper)
[![Documentation](https://docs.rs/juniper/badge.svg)](https://docs.rs/juniper)
[![CI](https://github.com/graphql-rust/juniper/workflows/CI/badge.svg?branch=master "CI")](https://github.com/graphql-rust/juniper/actions?query=workflow%3ACI+branch%3Amaster)
[![Rust 1.65+](https://img.shields.io/badge/rustc-1.65+-lightgray.svg "Rust 1.65+")](https://blog.rust-lang.org/2022/11/03/Rust-1.65.0.html)
[![Rust 1.73+](https://img.shields.io/badge/rustc-1.73+-lightgray.svg "Rust 1.73+")](https://blog.rust-lang.org/2023/10/05/Rust-1.73.0.html)

- [Juniper Book] ([current][Juniper Book] | [edge][Juniper Book edge])
- [Changelog](https://github.com/graphql-rust/juniper/blob/master/juniper/CHANGELOG.md)
Expand Down
5 changes: 5 additions & 0 deletions juniper_codegen/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ All user visible changes to `juniper_codegen` crate will be documented in this f

- `#[derive(GraphQLInterface)]` macro allowing using structs as GraphQL interfaces. ([#1026])

### Changed

- Migrated to 2 version of `syn` crate. ([#1157])

### Fixed

- All procedural macros expansion inside `macro_rules!`. ([#1054], [#1051])
Expand All @@ -56,6 +60,7 @@ All user visible changes to `juniper_codegen` crate will be documented in this f
[#1028]: /../../pull/1028
[#1051]: /../../issues/1051
[#1054]: /../../pull/1054
[#1157]: /../../pull/1157



Expand Down
5 changes: 2 additions & 3 deletions juniper_codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "juniper_codegen"
version = "0.16.0-dev"
edition = "2021"
rust-version = "1.65"
rust-version = "1.73"
description = "Code generation for `juniper` crate."
license = "BSD-2-Clause"
authors = [
Expand All @@ -22,10 +22,9 @@ exclude = ["/release.toml"]
proc-macro = true

[dependencies]
proc-macro-error = "1.0.2"
proc-macro2 = "1.0.4"
quote = "1.0.9"
syn = { version = "1.0.90", features = ["extra-traits", "full", "parsing", "visit", "visit-mut"], default-features = false }
syn = { version = "2.0", features = ["extra-traits", "full", "visit", "visit-mut"] }
url = "2.0"

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion juniper_codegen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![Crates.io](https://img.shields.io/crates/v/juniper_codegen.svg?maxAge=2592000)](https://crates.io/crates/juniper_codegen)
[![Documentation](https://docs.rs/juniper_codegen/badge.svg)](https://docs.rs/juniper_codegen)
[![CI](https://github.com/graphql-rust/juniper/workflows/CI/badge.svg?branch=master "CI")](https://github.com/graphql-rust/juniper/actions?query=workflow%3ACI+branch%3Amaster)
[![Rust 1.65+](https://img.shields.io/badge/rustc-1.65+-lightgray.svg "Rust 1.65+")](https://blog.rust-lang.org/2022/11/03/Rust-1.65.0.html)
[![Rust 1.73+](https://img.shields.io/badge/rustc-1.73+-lightgray.svg "Rust 1.73+")](https://blog.rust-lang.org/2023/10/05/Rust-1.73.0.html)

- [Changelog](https://github.com/graphql-rust/juniper/blob/master/juniper_codegen/CHANGELOG.md)

Expand Down
61 changes: 53 additions & 8 deletions juniper_codegen/src/common/deprecation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use proc_macro2::TokenStream;
use quote::{quote, ToTokens};
use syn::{
parse::{Parse, ParseStream},
punctuated::Punctuated,
spanned::Spanned as _,
token,
};
Expand All @@ -20,7 +21,7 @@ use crate::common::{parse::ParseBufferExt as _, SpanContainer};
/// [0]: https://spec.graphql.org/October2021#sec--deprecated
/// [1]: https://spec.graphql.org/October2021#sec-Language.Fields
/// [2]: https://spec.graphql.org/October2021#sec-Enum-Value
#[derive(Debug, Default)]
#[derive(Debug, Default, Eq, PartialEq)]
pub(crate) struct Directive {
/// Optional [reason][1] attached to this [deprecation][0].
///
Expand Down Expand Up @@ -52,16 +53,16 @@ impl Directive {
attrs: &[syn::Attribute],
) -> syn::Result<Option<SpanContainer<Self>>> {
for attr in attrs {
return Ok(match attr.parse_meta() {
Ok(syn::Meta::List(ref list)) if list.path.is_ident("deprecated") => {
return Ok(match &attr.meta {
syn::Meta::List(list) if list.path.is_ident("deprecated") => {
let directive = Self::parse_from_deprecated_meta_list(list)?;
Some(SpanContainer::new(
list.path.span(),
directive.reason.as_ref().map(|r| r.span()),
directive,
))
}
Ok(syn::Meta::Path(ref path)) if path.is_ident("deprecated") => {
syn::Meta::Path(path) if path.is_ident("deprecated") => {
Some(SpanContainer::new(path.span(), None, Self::default()))
}
_ => continue,
Expand All @@ -77,20 +78,24 @@ impl Directive {
///
/// If the `#[deprecated(note = ...)]` attribute has incorrect format.
fn parse_from_deprecated_meta_list(list: &syn::MetaList) -> syn::Result<Self> {
for meta in &list.nested {
if let syn::NestedMeta::Meta(syn::Meta::NameValue(nv)) = meta {
for meta in list.parse_args_with(Punctuated::<syn::Meta, token::Comma>::parse_terminated)? {
if let syn::Meta::NameValue(nv) = meta {
return if !nv.path.is_ident("note") {
Err(syn::Error::new(
nv.path.span(),
"unrecognized setting on #[deprecated(..)] attribute",
))
} else if let syn::Lit::Str(strlit) = &nv.lit {
} else if let syn::Expr::Lit(syn::ExprLit {
lit: syn::Lit::Str(strlit),
..
}) = &nv.value
{
Ok(Self {
reason: Some(strlit.clone()),
})
} else {
Err(syn::Error::new(
nv.lit.span(),
nv.value.span(),
"only strings are allowed for deprecation",
))
};
Expand All @@ -112,3 +117,43 @@ impl ToTokens for Directive {
.to_tokens(into);
}
}

#[cfg(test)]
mod parse_from_deprecated_attr_test {
use quote::quote;
use syn::parse_quote;

use super::Directive;

#[test]
fn single() {
let desc =
Directive::parse_from_deprecated_attr(&[parse_quote! { #[deprecated(note = "foo")] }])
.unwrap()
.unwrap()
.into_inner();
assert_eq!(
quote! { #desc }.to_string(),
quote! { .deprecated(::core::option::Option::Some("foo")) }.to_string(),
);
}

#[test]
fn no_reason() {
let desc = Directive::parse_from_deprecated_attr(&[parse_quote! { #[deprecated] }])
.unwrap()
.unwrap()
.into_inner();
assert_eq!(
quote! { #desc }.to_string(),
quote! { .deprecated(::core::option::Option::None) }.to_string(),
);
}

#[test]
fn not_deprecation() {
let desc =
Directive::parse_from_deprecated_attr(&[parse_quote! { #[blah = "foo"] }]).unwrap();
assert_eq!(desc, None);
}
}
17 changes: 12 additions & 5 deletions juniper_codegen/src/common/description.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@

use proc_macro2::TokenStream;
use quote::{quote, ToTokens};
use syn::parse::{Parse, ParseStream};
use syn::{
parse::{Parse, ParseStream},
spanned::Spanned as _,
};

use crate::common::SpanContainer;

Expand Down Expand Up @@ -36,16 +39,20 @@ impl Description {
) -> syn::Result<Option<SpanContainer<Self>>> {
let (mut first_span, mut descriptions) = (None, Vec::new());
for attr in attrs {
match attr.parse_meta() {
Ok(syn::Meta::NameValue(ref nv)) if nv.path.is_ident("doc") => {
if let syn::Lit::Str(strlit) = &nv.lit {
match attr.meta {
syn::Meta::NameValue(ref nv) if nv.path.is_ident("doc") => {
if let syn::Expr::Lit(syn::ExprLit {
lit: syn::Lit::Str(strlit),
..
}) = &nv.value
{
if first_span.is_none() {
first_span = Some(strlit.span());
}
descriptions.push(strlit.value());
} else {
return Err(syn::Error::new(
nv.lit.span(),
nv.value.span(),
"#[doc] attributes may only have a string literal",
));
}
Expand Down
Loading