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 dependencies #52

Merged
merged 4 commits into from
Jan 5, 2025
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
15 changes: 7 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions crates/cgp-async-macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
syn = { version = "2.0.95", features = [ "full" ] }
quote = "1.0.38"
proc-macro2 = "1.0.92"
39 changes: 20 additions & 19 deletions crates/cgp-async-macro/src/impl_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
8 changes: 4 additions & 4 deletions crates/cgp-component-macro-lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
}
}
}
}
Expand All @@ -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
});
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
}
}
}
}
Expand Down
15 changes: 8 additions & 7 deletions crates/cgp-component-macro-lib/src/for_each_replace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
};

Expand Down
2 changes: 1 addition & 1 deletion crates/cgp-error-std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ description = """
"""

[dependencies]
cgp-core = { version = "0.2.0", default-features = false }
cgp-core = { version = "0.2.0", default-features = false }
7 changes: 3 additions & 4 deletions crates/cgp-field-macro-lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "1.81"
channel = "1.83"
profile = "default"
Loading