diff --git a/Cargo.lock b/Cargo.lock index 1c4104f..ea0b199 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "anyhow" @@ -131,7 +131,6 @@ dependencies = [ name = "cgp-field-macro-lib" version = "0.2.0" dependencies = [ - "itertools", "prettyplease", "proc-macro2", "quote", @@ -202,9 +201,9 @@ checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" [[package]] name = "itertools" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" dependencies = [ "either", ] @@ -217,9 +216,9 @@ checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "prettyplease" -version = "0.2.25" +version = "0.2.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033" +checksum = "483f8c21f64f3ea09fe0f30f5d48c3e8eefe5dac9129f0075f76593b4c1da705" dependencies = [ "proc-macro2", "syn", @@ -236,9 +235,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.37" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" dependencies = [ "proc-macro2", ] diff --git a/Cargo.toml b/Cargo.toml index 7219b9b..966e02b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,7 @@ members = [ ] [workspace.package] -rust-version = "1.81" +rust-version = "1.83" edition = "2021" license = "Apache-2.0" repository = "https://github.com/contextgeneric/cgp" diff --git a/crates/cgp-async-macro/Cargo.toml b/crates/cgp-async-macro/Cargo.toml index a36897d..b95e03c 100644 --- a/crates/cgp-async-macro/Cargo.toml +++ b/crates/cgp-async-macro/Cargo.toml @@ -17,6 +17,6 @@ proc-macro = true [features] [dependencies] -syn = { version = "2.0.90", features = [ "full" ] } -quote = "1.0.33" -proc-macro2 = "1.0.92" \ No newline at end of file +syn = { version = "2.0.95", features = [ "full" ] } +quote = "1.0.38" +proc-macro2 = "1.0.92" \ No newline at end of file diff --git a/crates/cgp-async-macro/src/impl_async.rs b/crates/cgp-async-macro/src/impl_async.rs index 0749843..cc87add 100644 --- a/crates/cgp-async-macro/src/impl_async.rs +++ b/crates/cgp-async-macro/src/impl_async.rs @@ -3,29 +3,30 @@ use quote::ToTokens; use syn::{parse_quote, ItemTrait, ReturnType, TraitItem, Type}; pub fn impl_async(item: TokenStream) -> TokenStream { - if let Ok(mut target_trait) = syn::parse2::<ItemTrait>(item.clone()) { - for trait_item in target_trait.items.iter_mut() { - if let TraitItem::Fn(trait_fn) = trait_item { - if trait_fn.sig.asyncness.is_some() { - let return_type: Type = match &trait_fn.sig.output { - ReturnType::Default => { - parse_quote!(()) - } - ReturnType::Type(_, return_type) => return_type.as_ref().clone(), - }; + match syn::parse2::<ItemTrait>(item.clone()) { + Ok(mut target_trait) => { + for trait_item in target_trait.items.iter_mut() { + if let TraitItem::Fn(trait_fn) = trait_item { + if trait_fn.sig.asyncness.is_some() { + let return_type: Type = match &trait_fn.sig.output { + ReturnType::Default => { + parse_quote!(()) + } + ReturnType::Type(_, return_type) => return_type.as_ref().clone(), + }; - let impl_return: ReturnType = parse_quote! { - -> impl ::core::future::Future<Output = #return_type> + MaybeSend - }; + let impl_return: ReturnType = parse_quote! { + -> impl ::core::future::Future<Output = #return_type> + MaybeSend + }; - trait_fn.sig.output = impl_return; - trait_fn.sig.asyncness = None; + trait_fn.sig.output = impl_return; + trait_fn.sig.asyncness = None; + } } } - } - target_trait.to_token_stream() - } else { - item + target_trait.to_token_stream() + } + _ => item, } } diff --git a/crates/cgp-component-macro-lib/Cargo.toml b/crates/cgp-component-macro-lib/Cargo.toml index ff2a459..cb851ac 100644 --- a/crates/cgp-component-macro-lib/Cargo.toml +++ b/crates/cgp-component-macro-lib/Cargo.toml @@ -12,8 +12,8 @@ description = """ """ [dependencies] -syn = { version = "2.0.90", features = [ "full", "extra-traits" ] } -quote = "1.0.33" +syn = { version = "2.0.95", features = [ "full", "extra-traits" ] } +quote = "1.0.38" proc-macro2 = "1.0.92" -itertools = "0.13.0" -prettyplease = "0.2.25" +prettyplease = "0.2.27" +itertools = "0.14.0" diff --git a/crates/cgp-component-macro-lib/src/derive_component/consumer_impl.rs b/crates/cgp-component-macro-lib/src/derive_component/consumer_impl.rs index 0221d8a..7b4b7a8 100644 --- a/crates/cgp-component-macro-lib/src/derive_component/consumer_impl.rs +++ b/crates/cgp-component-macro-lib/src/derive_component/consumer_impl.rs @@ -54,14 +54,17 @@ pub fn derive_consumer_impl( let supertrait_constraints = consumer_trait.supertraits.clone(); if !supertrait_constraints.is_empty() { - if let Some(where_clause) = &mut impl_generics.where_clause { - where_clause.predicates.push(parse_quote! { - #context_type : #supertrait_constraints - }); - } else { - impl_generics.where_clause = Some(parse_quote! { - where #context_type : #supertrait_constraints - }); + match &mut impl_generics.where_clause { + Some(where_clause) => { + where_clause.predicates.push(parse_quote! { + #context_type : #supertrait_constraints + }); + } + _ => { + impl_generics.where_clause = Some(parse_quote! { + where #context_type : #supertrait_constraints + }); + } } } } @@ -75,20 +78,23 @@ pub fn derive_consumer_impl( #provider_name < #provider_generic_args > }; - if let Some(where_clause) = &mut impl_generics.where_clause { - where_clause.predicates.push(parse_quote! { - #context_type : #has_component_constraint - }); - - where_clause.predicates.push(parse_quote! { - #context_type :: Components : #provider_constraint - }); - } else { - impl_generics.where_clause = Some(parse_quote! { - where - #context_type : #has_component_constraint, + match &mut impl_generics.where_clause { + Some(where_clause) => { + where_clause.predicates.push(parse_quote! { + #context_type : #has_component_constraint + }); + + where_clause.predicates.push(parse_quote! { #context_type :: Components : #provider_constraint - }); + }); + } + _ => { + impl_generics.where_clause = Some(parse_quote! { + where + #context_type : #has_component_constraint, + #context_type :: Components : #provider_constraint + }); + } } } diff --git a/crates/cgp-component-macro-lib/src/derive_component/provider_impl.rs b/crates/cgp-component-macro-lib/src/derive_component/provider_impl.rs index d0631f3..e16be9b 100644 --- a/crates/cgp-component-macro-lib/src/derive_component/provider_impl.rs +++ b/crates/cgp-component-macro-lib/src/derive_component/provider_impl.rs @@ -56,20 +56,23 @@ pub fn derive_provider_impl( #provider_name < #provider_generic_args > }; - if let Some(where_clause) = &mut impl_generics.where_clause { - where_clause.predicates.push(parse_quote! { - #component_type : #delegate_constraint - }); - - where_clause.predicates.push(parse_quote! { - #component_type :: Delegate : #provider_constraint - }); - } else { - impl_generics.where_clause = Some(parse_quote! { - where - #component_type : #delegate_constraint, + match &mut impl_generics.where_clause { + Some(where_clause) => { + where_clause.predicates.push(parse_quote! { + #component_type : #delegate_constraint + }); + + where_clause.predicates.push(parse_quote! { #component_type :: Delegate : #provider_constraint - }); + }); + } + _ => { + impl_generics.where_clause = Some(parse_quote! { + where + #component_type : #delegate_constraint, + #component_type :: Delegate : #provider_constraint + }); + } } } diff --git a/crates/cgp-component-macro-lib/src/derive_component/provider_trait.rs b/crates/cgp-component-macro-lib/src/derive_component/provider_trait.rs index aed9446..518d44b 100644 --- a/crates/cgp-component-macro-lib/src/derive_component/provider_trait.rs +++ b/crates/cgp-component-macro-lib/src/derive_component/provider_trait.rs @@ -47,22 +47,25 @@ pub fn derive_provider_trait( provider_trait.supertraits = Punctuated::default(); if !context_constraints.is_empty() { - if let Some(where_clause) = &mut provider_trait.generics.where_clause { - let mut predicates = iter_parse_and_replace_self_type( - where_clause.predicates.clone(), - context_type, - &local_assoc_types, - )?; + match &mut provider_trait.generics.where_clause { + Some(where_clause) => { + let mut predicates = iter_parse_and_replace_self_type( + where_clause.predicates.clone(), + context_type, + &local_assoc_types, + )?; - predicates.push(parse_quote! { - #context_type : #context_constraints - }); + predicates.push(parse_quote! { + #context_type : #context_constraints + }); - where_clause.predicates = predicates; - } else { - provider_trait.generics.where_clause = Some(parse_quote! { - where #context_type : #context_constraints - }); + where_clause.predicates = predicates; + } + _ => { + provider_trait.generics.where_clause = Some(parse_quote! { + where #context_type : #context_constraints + }); + } } } } diff --git a/crates/cgp-component-macro-lib/src/for_each_replace.rs b/crates/cgp-component-macro-lib/src/for_each_replace.rs index 80c8349..f9e0fc2 100644 --- a/crates/cgp-component-macro-lib/src/for_each_replace.rs +++ b/crates/cgp-component-macro-lib/src/for_each_replace.rs @@ -29,15 +29,16 @@ impl Parse for ReplaceSpecs { let exclude: Vec<Type> = { let fork = input.fork(); - if let Ok(bracket) = parse_brackets(&fork) { - let types = <Punctuated<Type, Comma>>::parse_terminated(&bracket.content)?; + match parse_brackets(&fork) { + Ok(bracket) => { + let types = <Punctuated<Type, Comma>>::parse_terminated(&bracket.content)?; - input.advance_to(&fork); - Comma::parse(input)?; + input.advance_to(&fork); + Comma::parse(input)?; - types.into_iter().collect() - } else { - Vec::new() + types.into_iter().collect() + } + _ => Vec::new(), } }; diff --git a/crates/cgp-error-std/Cargo.toml b/crates/cgp-error-std/Cargo.toml index 5bb559a..6d609c2 100644 --- a/crates/cgp-error-std/Cargo.toml +++ b/crates/cgp-error-std/Cargo.toml @@ -12,4 +12,4 @@ description = """ """ [dependencies] -cgp-core = { version = "0.2.0", default-features = false } \ No newline at end of file +cgp-core = { version = "0.2.0", default-features = false } \ No newline at end of file diff --git a/crates/cgp-field-macro-lib/Cargo.toml b/crates/cgp-field-macro-lib/Cargo.toml index 32da9a5..befab76 100644 --- a/crates/cgp-field-macro-lib/Cargo.toml +++ b/crates/cgp-field-macro-lib/Cargo.toml @@ -12,8 +12,7 @@ description = """ """ [dependencies] -syn = { version = "2.0.90", features = [ "full" ] } -quote = "1.0.33" +syn = { version = "2.0.95", features = [ "full" ] } +quote = "1.0.38" proc-macro2 = "1.0.92" -itertools = "0.13.0" -prettyplease = "0.2.20" +prettyplease = "0.2.27" diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 6f4d5bc..2a53366 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.81" +channel = "1.83" profile = "default"