diff --git a/juniper_codegen/src/common/diagnostic.rs b/juniper_codegen/src/common/diagnostic.rs index 15a8d0ef..15f2b0cf 100644 --- a/juniper_codegen/src/common/diagnostic.rs +++ b/juniper_codegen/src/common/diagnostic.rs @@ -255,7 +255,7 @@ mod polyfill { } thread_local! { - static ENTERED_ENTRY_POINT: Cell = Cell::new(0); + static ENTERED_ENTRY_POINT: Cell = const { Cell::new(0) }; } /// This is the entry point for a macro to support [`Diagnostic`]s. @@ -312,7 +312,7 @@ mod polyfill { } thread_local! { - static ERR_STORAGE: RefCell> = RefCell::new(Vec::new()); + static ERR_STORAGE: RefCell> = const { RefCell::new(Vec::new()) }; } /// Emits the provided [`Diagnostic`], while not aborting macro execution. diff --git a/juniper_codegen/src/scalar_value/mod.rs b/juniper_codegen/src/scalar_value/mod.rs index 1ec0b179..f590678c 100644 --- a/juniper_codegen/src/scalar_value/mod.rs +++ b/juniper_codegen/src/scalar_value/mod.rs @@ -450,14 +450,14 @@ enum Field { Named(syn::Field), /// Unnamed [`Field`]. - Unnamed(syn::Field), + Unnamed, } impl ToTokens for Field { fn to_tokens(&self, tokens: &mut TokenStream) { match self { Self::Named(f) => f.ident.to_tokens(tokens), - Self::Unnamed(_) => tokens.append(Literal::u8_unsuffixed(0)), + Self::Unnamed => tokens.append(Literal::u8_unsuffixed(0)), } } } @@ -470,9 +470,7 @@ impl TryFrom for Field { syn::Fields::Named(mut f) if f.named.len() == 1 => { Ok(Self::Named(f.named.pop().unwrap().into_value())) } - syn::Fields::Unnamed(mut f) if f.unnamed.len() == 1 => { - Ok(Self::Unnamed(f.unnamed.pop().unwrap().into_value())) - } + syn::Fields::Unnamed(f) if f.unnamed.len() == 1 => Ok(Self::Unnamed), _ => Err(ERR.custom_error(value.span(), "expected exactly 1 field")), } } @@ -483,7 +481,7 @@ impl Field { fn match_arg(&self) -> TokenStream { match self { Self::Named(_) => quote! { { #self: v } }, - Self::Unnamed(_) => quote! { (v) }, + Self::Unnamed => quote! { (v) }, } } } diff --git a/tests/integration/tests/codegen_enum_derive.rs b/tests/integration/tests/codegen_enum_derive.rs index c7b7481a..d7694ea6 100644 --- a/tests/integration/tests/codegen_enum_derive.rs +++ b/tests/integration/tests/codegen_enum_derive.rs @@ -900,7 +900,7 @@ mod bounded_generic_scalar { mod explicit_custom_context { use super::*; - struct CustomContext(prelude::String); + struct CustomContext(#[allow(dead_code)] prelude::String); impl juniper::Context for CustomContext {} diff --git a/tests/integration/tests/codegen_union_derive.rs b/tests/integration/tests/codegen_union_derive.rs index d7eff39b..011ea91e 100644 --- a/tests/integration/tests/codegen_union_derive.rs +++ b/tests/integration/tests/codegen_union_derive.rs @@ -1097,7 +1097,7 @@ mod external_resolver_enum_variant { enum Character { A(Human), #[graphql(with = Character::as_droid)] - B(Droid), + B(#[allow(dead_code)] Droid), } impl Character {