diff --git a/juniper/src/executor/mod.rs b/juniper/src/executor/mod.rs index 6cf83769..2026f97b 100644 --- a/juniper/src/executor/mod.rs +++ b/juniper/src/executor/mod.rs @@ -4,6 +4,7 @@ use std::{ borrow::Cow, cmp::Ordering, collections::{hash_map, HashMap}, + convert, fmt::{Debug, Display}, sync::{Arc, RwLock}, }; @@ -1297,14 +1298,12 @@ impl<'r, S: 'r> Registry<'r, S> { T: resolve::TypeName + resolve::InputValueOwned + resolve::ScalarToken, TI: ?Sized, 'ti: 'r, - F: FnOnce(&mut ScalarMeta<'r, S>), + F: FnOnce(ScalarMeta<'r, S>) -> ScalarMeta<'r, S>, S: Clone, { self.entry_type::(type_info) .or_insert_with(move || { - let mut scalar = ScalarMeta::new_reworked::(T::type_name(type_info)); - customize(&mut scalar); - scalar.into_meta() + customize(ScalarMeta::new_reworked::(T::type_name(type_info))).into_meta() }) .clone() } @@ -1326,9 +1325,7 @@ impl<'r, S: 'r> Registry<'r, S> { 'ti: 'r, S: Clone, { - // TODO: Use `drop` instead of `|_| {}` once Rust's inference becomes - // better for HRTB closures. - self.register_scalar_unsized_with::(type_info, |_| {}) + self.register_scalar_unsized_with::(type_info, convert::identity) } /// Builds a [`ScalarMeta`] information for the specified non-[`Sized`] @@ -1351,14 +1348,12 @@ impl<'r, S: 'r> Registry<'r, S> { T: resolve::TypeName + resolve::InputValueAsRef + resolve::ScalarToken + ?Sized, TI: ?Sized, 'ti: 'r, - F: FnOnce(&mut ScalarMeta<'r, S>), + F: FnOnce(ScalarMeta<'r, S>) -> ScalarMeta<'r, S>, S: Clone, { self.entry_type::(type_info) .or_insert_with(move || { - let mut scalar = ScalarMeta::new_unsized::(T::type_name(type_info)); - customize(&mut scalar); - scalar.into_meta() + customize(ScalarMeta::new_unsized::(T::type_name(type_info))).into_meta() }) .clone() } diff --git a/juniper_codegen/src/graphql_scalar/mod.rs b/juniper_codegen/src/graphql_scalar/mod.rs index 35b16865..e7a9e1a1 100644 --- a/juniper_codegen/src/graphql_scalar/mod.rs +++ b/juniper_codegen/src/graphql_scalar/mod.rs @@ -529,9 +529,10 @@ impl Definition { let predicates = &mut generics.make_where_clause().predicates; predicates.push(parse_quote! { #sv: Clone }); predicates.push(parse_quote! { - Self: ::juniper::resolve::TypeName<#inf, #bh> - + ::juniper::resolve::ScalarToken<#sv, #bh> - + ::juniper::resolve::InputValueOwned<#sv, #bh> + ::juniper::behavior::Coerce: + ::juniper::resolve::TypeName<#inf, #bh> + + ::juniper::resolve::ScalarToken<#sv, #bh> + + ::juniper::resolve::InputValueOwned<#sv, #bh> }); let (impl_gens, _, where_clause) = generics.split_for_impl(); @@ -561,7 +562,7 @@ impl Definition { ::juniper::behavior::Coerce, _, _, >(type_info, |meta| { meta#description - #specified_by_url; + #specified_by_url }) } }