From 5a1d4172e205ba3779dd5b3084dec93a5838f782 Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Sat, 28 Feb 2026 11:22:10 +0100 Subject: [PATCH 01/13] Implicitly derive check trait name in `delegate_and_check_componenbts!` --- .../delegate_and_check_components.rs | 2 +- .../parse/delegate_and_check_components.rs | 34 +++++++++++++------ .../tests/delegate_and_check_components.rs | 2 -- crates/cgp-tests/src/tests/has_field/chain.rs | 1 - .../component_tests/abstract_types/basic.rs | 1 - .../component_tests/abstract_types/extend.rs | 1 - .../component_tests/cgp_component/constant.rs | 1 - .../cgp_impl/implicit_args/basic.rs | 1 - .../cgp_impl/implicit_args/import.rs | 1 - 9 files changed, 25 insertions(+), 19 deletions(-) diff --git a/crates/cgp-macro-lib/src/entrypoints/delegate_and_check_components.rs b/crates/cgp-macro-lib/src/entrypoints/delegate_and_check_components.rs index 00ca7393..d547edcb 100644 --- a/crates/cgp-macro-lib/src/entrypoints/delegate_and_check_components.rs +++ b/crates/cgp-macro-lib/src/entrypoints/delegate_and_check_components.rs @@ -55,7 +55,7 @@ pub fn delegate_and_check_components(body: TokenStream) -> syn::Result, } @@ -30,15 +31,29 @@ impl Parse for DelegateAndCheckSpec { Default::default() }; - let trait_name = input.parse()?; + let m_trait_name = if input.peek(Pound) { + let _: Pound = input.parse()?; + let attributes = input.call(Attribute::parse_outer)?; - let _: For = input.parse()?; + let [attribute]: [Attribute; 1] = attributes.try_into().map_err(|_| { + input.error("Expected exactly one attribute for the check trait name") + })?; - let context_type = input.parse()?; + let ident: Ident = attribute.parse_args()?; + Some(ident) + } else { + None + }; - let _: Semi = input.parse()?; + let context_type: Type = input.parse()?; - let provider_type = input.parse()?; + let trait_name = match m_trait_name { + Some(ident) => ident, + None => { + let context_type: SimpleType = parse2(context_type.to_token_stream())?; + Ident::new(&format!("CanUse{}", context_type.name), context_type.span()) + } + }; let entries = { let body; @@ -50,7 +65,6 @@ impl Parse for DelegateAndCheckSpec { impl_generics, trait_name, context_type, - provider_type, entries, }) } diff --git a/crates/cgp-tests/src/tests/delegate_and_check_components.rs b/crates/cgp-tests/src/tests/delegate_and_check_components.rs index e737e034..ad10f5e9 100644 --- a/crates/cgp-tests/src/tests/delegate_and_check_components.rs +++ b/crates/cgp-tests/src/tests/delegate_and_check_components.rs @@ -19,7 +19,6 @@ pub fn test_basic_delegate_and_check_components() { } delegate_and_check_components! { - CanUseMyContext for MyContext; MyContext { NameTypeProviderComponent: UseType, NameGetterComponent: UseField, @@ -45,7 +44,6 @@ pub fn test_generic_delegate_and_check_components() { delegate_and_check_components! { - CanUseMyContext for MyContext; MyContext { NameTypeProviderComponent: UseType, NameGetterComponent: UseField, diff --git a/crates/cgp-tests/src/tests/has_field/chain.rs b/crates/cgp-tests/src/tests/has_field/chain.rs index 51fb47c8..2d6119d9 100644 --- a/crates/cgp-tests/src/tests/has_field/chain.rs +++ b/crates/cgp-tests/src/tests/has_field/chain.rs @@ -109,7 +109,6 @@ fn test_deeply_nested_getter() { } delegate_and_check_components! { - CanUseMyContext for MyContext; MyContext { NameGetterComponent: WithProvider< ChainGetters, diff --git a/crates/cgp-tests/tests/component_tests/abstract_types/extend.rs b/crates/cgp-tests/tests/component_tests/abstract_types/extend.rs index 5c275841..33f00d79 100644 --- a/crates/cgp-tests/tests/component_tests/abstract_types/extend.rs +++ b/crates/cgp-tests/tests/component_tests/abstract_types/extend.rs @@ -37,7 +37,6 @@ pub struct Rectangle { } delegate_and_check_components! { - CanUseRectangle for Rectangle; Rectangle { ErrorTypeProviderComponent: UseType, diff --git a/crates/cgp-tests/tests/component_tests/cgp_component/constant.rs b/crates/cgp-tests/tests/component_tests/cgp_component/constant.rs index 2e018066..4587f613 100644 --- a/crates/cgp-tests/tests/component_tests/cgp_component/constant.rs +++ b/crates/cgp-tests/tests/component_tests/cgp_component/constant.rs @@ -16,7 +16,6 @@ pub fn test_component_with_const() { pub struct MyContext; delegate_and_check_components! { - CanUseMyContext for MyContext; MyContext { ConstantGetterComponent: UseConstant<42>, } diff --git a/crates/cgp-tests/tests/component_tests/cgp_impl/implicit_args/basic.rs b/crates/cgp-tests/tests/component_tests/cgp_impl/implicit_args/basic.rs index a80440a0..99d88075 100644 --- a/crates/cgp-tests/tests/component_tests/cgp_impl/implicit_args/basic.rs +++ b/crates/cgp-tests/tests/component_tests/cgp_impl/implicit_args/basic.rs @@ -19,7 +19,6 @@ pub struct Rectangle { } delegate_and_check_components! { - CanUseRectangle for Rectangle; Rectangle { AreaCalculatorComponent: RectangleArea, diff --git a/crates/cgp-tests/tests/component_tests/cgp_impl/implicit_args/import.rs b/crates/cgp-tests/tests/component_tests/cgp_impl/implicit_args/import.rs index d7692e2e..c946e12a 100644 --- a/crates/cgp-tests/tests/component_tests/cgp_impl/implicit_args/import.rs +++ b/crates/cgp-tests/tests/component_tests/cgp_impl/implicit_args/import.rs @@ -25,7 +25,6 @@ pub struct Rectangle { } delegate_and_check_components! { - CanUseRectangle for Rectangle; Rectangle { AreaCalculatorComponent: RectangleAreaCalculator, From 72b2b503504230f605d5bd9212e4f8f2ed92c680 Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Sat, 28 Feb 2026 11:28:21 +0100 Subject: [PATCH 02/13] Allow check trait name to be specified --- .../src/parse/delegate_and_check_components.rs | 13 +++++++++++-- .../src/tests/delegate_and_check_components.rs | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/crates/cgp-macro-lib/src/parse/delegate_and_check_components.rs b/crates/cgp-macro-lib/src/parse/delegate_and_check_components.rs index 8b4d590f..aad97d7a 100644 --- a/crates/cgp-macro-lib/src/parse/delegate_and_check_components.rs +++ b/crates/cgp-macro-lib/src/parse/delegate_and_check_components.rs @@ -32,13 +32,19 @@ impl Parse for DelegateAndCheckSpec { }; let m_trait_name = if input.peek(Pound) { - let _: Pound = input.parse()?; let attributes = input.call(Attribute::parse_outer)?; let [attribute]: [Attribute; 1] = attributes.try_into().map_err(|_| { input.error("Expected exactly one attribute for the check trait name") })?; + if !attribute.path().is_ident("check_trait") { + return Err(syn::Error::new( + attribute.span(), + "Expected `check_trait` attribute for specifying the check trait name", + )); + } + let ident: Ident = attribute.parse_args()?; Some(ident) } else { @@ -51,7 +57,10 @@ impl Parse for DelegateAndCheckSpec { Some(ident) => ident, None => { let context_type: SimpleType = parse2(context_type.to_token_stream())?; - Ident::new(&format!("CanUse{}", context_type.name), context_type.span()) + Ident::new( + &format!("__CanUse{}", context_type.name), + context_type.span(), + ) } }; diff --git a/crates/cgp-tests/src/tests/delegate_and_check_components.rs b/crates/cgp-tests/src/tests/delegate_and_check_components.rs index ad10f5e9..b43e2827 100644 --- a/crates/cgp-tests/src/tests/delegate_and_check_components.rs +++ b/crates/cgp-tests/src/tests/delegate_and_check_components.rs @@ -19,6 +19,7 @@ pub fn test_basic_delegate_and_check_components() { } delegate_and_check_components! { + #[check_trait(CheckMyContext)] MyContext { NameTypeProviderComponent: UseType, NameGetterComponent: UseField, From a40beb724b4bd3ca1d95e9b495119a8b7dfaafcc Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Sat, 28 Feb 2026 11:35:12 +0100 Subject: [PATCH 03/13] Add DelegateAndCheckKey --- .../delegate_and_check_components.rs | 7 +++--- .../parse/delegate_and_check_components.rs | 22 +++++++++++++++++-- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/crates/cgp-macro-lib/src/entrypoints/delegate_and_check_components.rs b/crates/cgp-macro-lib/src/entrypoints/delegate_and_check_components.rs index d547edcb..766a4266 100644 --- a/crates/cgp-macro-lib/src/entrypoints/delegate_and_check_components.rs +++ b/crates/cgp-macro-lib/src/entrypoints/delegate_and_check_components.rs @@ -19,7 +19,8 @@ pub fn delegate_and_check_components(body: TokenStream) -> syn::Result syn::Result, + pub keys: Punctuated, pub mode: DelegateMode, pub value: Type, } +#[derive(Clone)] +pub struct DelegateAndCheckKey { + pub component_type: Type, + pub check_generics: Option>, +} + impl Parse for DelegateAndCheckSpec { fn parse(input: ParseStream) -> syn::Result { let impl_generics = if input.peek(Lt) { @@ -86,7 +92,7 @@ impl Parse for DelegateAndCheckEntry { bracketed!(body in input); Punctuated::parse_terminated(&body)? } else { - let key: Type = input.parse()?; + let key: DelegateAndCheckKey = input.parse()?; Punctuated::from_iter(iter::once(key)) }; @@ -97,3 +103,15 @@ impl Parse for DelegateAndCheckEntry { Ok(Self { keys, mode, value }) } } + + +impl Parse for DelegateAndCheckKey { + fn parse(input: ParseStream) -> syn::Result { + let check_generics = None; + let component_type: Type = input.parse()?; + Ok(Self { + component_type, + check_generics, + }) + } +} \ No newline at end of file From 77164847a2afa3b1456728275997ceb372486615 Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Sat, 28 Feb 2026 11:43:50 +0100 Subject: [PATCH 04/13] Derive check_generics parameters --- .../delegate_and_check_components.rs | 20 ++++++++++---- .../parse/delegate_and_check_components.rs | 26 ++++++++++++++++--- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/crates/cgp-macro-lib/src/entrypoints/delegate_and_check_components.rs b/crates/cgp-macro-lib/src/entrypoints/delegate_and_check_components.rs index 766a4266..0ef7d924 100644 --- a/crates/cgp-macro-lib/src/entrypoints/delegate_and_check_components.rs +++ b/crates/cgp-macro-lib/src/entrypoints/delegate_and_check_components.rs @@ -19,14 +19,24 @@ pub fn delegate_and_check_components(body: TokenStream) -> syn::Result generics + .iter() + .map(|generic| CheckEntry { + component_type: component_type.clone(), + component_params: Some(generic.clone()), + span, + }) + .collect::>(), + None => vec![CheckEntry { + component_type: component_type.clone(), + component_params: None, + span, + }], } }) }) diff --git a/crates/cgp-macro-lib/src/parse/delegate_and_check_components.rs b/crates/cgp-macro-lib/src/parse/delegate_and_check_components.rs index 46aa5c00..33a5b9c0 100644 --- a/crates/cgp-macro-lib/src/parse/delegate_and_check_components.rs +++ b/crates/cgp-macro-lib/src/parse/delegate_and_check_components.rs @@ -26,7 +26,7 @@ pub struct DelegateAndCheckEntry { #[derive(Clone)] pub struct DelegateAndCheckKey { pub component_type: Type, - pub check_generics: Option>, + pub check_generics: Option>, } impl Parse for DelegateAndCheckSpec { @@ -104,14 +104,32 @@ impl Parse for DelegateAndCheckEntry { } } - impl Parse for DelegateAndCheckKey { fn parse(input: ParseStream) -> syn::Result { - let check_generics = None; + let check_generics = if input.peek(Pound) { + let attributes = input.call(Attribute::parse_outer)?; + + let [attribute]: [Attribute; 1] = attributes.try_into().map_err(|_| { + input.error("Expected exactly one attribute for the check generics") + })?; + + if !attribute.path().is_ident("check_generics") { + return Err(syn::Error::new( + attribute.span(), + "Expected `check_generics` attribute for specifying the check generics", + )); + } + + let check_generics = attribute.parse_args_with(Punctuated::parse_terminated)?; + Some(check_generics) + } else { + None + }; + let component_type: Type = input.parse()?; Ok(Self { component_type, check_generics, }) } -} \ No newline at end of file +} From e7f50d3aeab14a18cf6ce74f3b23b609427e1788 Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Sat, 28 Feb 2026 11:46:07 +0100 Subject: [PATCH 05/13] Test check_generics --- crates/cgp-tests/src/tests/check_components.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/cgp-tests/src/tests/check_components.rs b/crates/cgp-tests/src/tests/check_components.rs index 7bd60ba1..6d025e56 100644 --- a/crates/cgp-tests/src/tests/check_components.rs +++ b/crates/cgp-tests/src/tests/check_components.rs @@ -36,7 +36,7 @@ pub fn test_basic_check_components() { pub extra_dummy: (), } - delegate_components! { + delegate_and_check_components! { Context { [ FooTypeProviderComponent, @@ -44,7 +44,16 @@ pub fn test_basic_check_components() { ]: UseType<()>, [ + #[check_generics( + Index<0>, + Index<1>, + )] FooGetterAtComponent, + + #[check_generics( + (Index<0>, Index<1>), + (Index<1>, Index<0>), + )] BarGetterAtComponent, ]: UseField, From 4641946f62f66f17f2907030bf51edf6bb6c6f98 Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Sat, 28 Feb 2026 13:09:10 +0100 Subject: [PATCH 06/13] Rename `#[check_generics]` to `#[check_params]` --- .../src/parse/delegate_and_check_components.rs | 10 +++++----- crates/cgp-tests/src/tests/check_components.rs | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/cgp-macro-lib/src/parse/delegate_and_check_components.rs b/crates/cgp-macro-lib/src/parse/delegate_and_check_components.rs index 33a5b9c0..4f5dcc30 100644 --- a/crates/cgp-macro-lib/src/parse/delegate_and_check_components.rs +++ b/crates/cgp-macro-lib/src/parse/delegate_and_check_components.rs @@ -109,14 +109,14 @@ impl Parse for DelegateAndCheckKey { let check_generics = if input.peek(Pound) { let attributes = input.call(Attribute::parse_outer)?; - let [attribute]: [Attribute; 1] = attributes.try_into().map_err(|_| { - input.error("Expected exactly one attribute for the check generics") - })?; + let [attribute]: [Attribute; 1] = attributes + .try_into() + .map_err(|_| input.error("Expected exactly one `#[check_params]` attribute"))?; - if !attribute.path().is_ident("check_generics") { + if !attribute.path().is_ident("check_params") { return Err(syn::Error::new( attribute.span(), - "Expected `check_generics` attribute for specifying the check generics", + "Expected `check_params` attribute for specifying the check generics", )); } diff --git a/crates/cgp-tests/src/tests/check_components.rs b/crates/cgp-tests/src/tests/check_components.rs index 6d025e56..1950de4b 100644 --- a/crates/cgp-tests/src/tests/check_components.rs +++ b/crates/cgp-tests/src/tests/check_components.rs @@ -44,13 +44,13 @@ pub fn test_basic_check_components() { ]: UseType<()>, [ - #[check_generics( + #[check_params( Index<0>, Index<1>, )] FooGetterAtComponent, - #[check_generics( + #[check_params( (Index<0>, Index<1>), (Index<1>, Index<0>), )] From 5b18e3572a12d457d16efa1d6600513e9a31cb0e Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Sat, 28 Feb 2026 13:14:30 +0100 Subject: [PATCH 07/13] Support `#[skip_check]` --- .../src/parse/delegate_and_check_components.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/crates/cgp-macro-lib/src/parse/delegate_and_check_components.rs b/crates/cgp-macro-lib/src/parse/delegate_and_check_components.rs index 4f5dcc30..35a22d25 100644 --- a/crates/cgp-macro-lib/src/parse/delegate_and_check_components.rs +++ b/crates/cgp-macro-lib/src/parse/delegate_and_check_components.rs @@ -111,16 +111,19 @@ impl Parse for DelegateAndCheckKey { let [attribute]: [Attribute; 1] = attributes .try_into() - .map_err(|_| input.error("Expected exactly one `#[check_params]` attribute"))?; + .map_err(|_| input.error("Expected exactly one key attribute"))?; - if !attribute.path().is_ident("check_params") { + let check_generics = if attribute.path().is_ident("check_params") { + attribute.parse_args_with(Punctuated::parse_terminated)? + } else if attribute.path().is_ident("skip_check") { + Punctuated::new() + } else { return Err(syn::Error::new( attribute.span(), - "Expected `check_params` attribute for specifying the check generics", + "Expected either `#[skip_check]` or `#[check_params]` attribute for specifying the check generics", )); - } + }; - let check_generics = attribute.parse_args_with(Punctuated::parse_terminated)?; Some(check_generics) } else { None From c05bba5344817d119d67ba81e2d6e94990a0aff8 Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Sat, 28 Feb 2026 13:24:20 +0100 Subject: [PATCH 08/13] Support outer `#[check_params]` for list of component keys --- .../delegate_and_check_components.rs | 4 +- .../parse/delegate_and_check_components.rs | 62 ++++++++++++------- .../cgp-tests/src/tests/check_components.rs | 5 ++ 3 files changed, 45 insertions(+), 26 deletions(-) diff --git a/crates/cgp-macro-lib/src/entrypoints/delegate_and_check_components.rs b/crates/cgp-macro-lib/src/entrypoints/delegate_and_check_components.rs index 0ef7d924..18727ac7 100644 --- a/crates/cgp-macro-lib/src/entrypoints/delegate_and_check_components.rs +++ b/crates/cgp-macro-lib/src/entrypoints/delegate_and_check_components.rs @@ -23,8 +23,8 @@ pub fn delegate_and_check_components(body: TokenStream) -> syn::Result generics + match &key.check_params { + Some(check_params) => check_params .iter() .map(|generic| CheckEntry { component_type: component_type.clone(), diff --git a/crates/cgp-macro-lib/src/parse/delegate_and_check_components.rs b/crates/cgp-macro-lib/src/parse/delegate_and_check_components.rs index 35a22d25..35260019 100644 --- a/crates/cgp-macro-lib/src/parse/delegate_and_check_components.rs +++ b/crates/cgp-macro-lib/src/parse/delegate_and_check_components.rs @@ -26,7 +26,7 @@ pub struct DelegateAndCheckEntry { #[derive(Clone)] pub struct DelegateAndCheckKey { pub component_type: Type, - pub check_generics: Option>, + pub check_params: Option>, } impl Parse for DelegateAndCheckSpec { @@ -87,7 +87,9 @@ impl Parse for DelegateAndCheckSpec { impl Parse for DelegateAndCheckEntry { fn parse(input: ParseStream) -> syn::Result { - let keys = if input.peek(Bracket) { + let check_params = parse_check_params(&input)?; + + let mut keys = if input.peek(Bracket) { let body; bracketed!(body in input); Punctuated::parse_terminated(&body)? @@ -96,6 +98,14 @@ impl Parse for DelegateAndCheckEntry { Punctuated::from_iter(iter::once(key)) }; + if let Some(check_params) = check_params { + for key in &mut keys { + key.check_params + .get_or_insert_default() + .extend(check_params.clone()); + } + } + let mode = input.parse()?; let value = input.parse()?; @@ -106,33 +116,37 @@ impl Parse for DelegateAndCheckEntry { impl Parse for DelegateAndCheckKey { fn parse(input: ParseStream) -> syn::Result { - let check_generics = if input.peek(Pound) { - let attributes = input.call(Attribute::parse_outer)?; + let check_params = parse_check_params(&input)?; - let [attribute]: [Attribute; 1] = attributes - .try_into() - .map_err(|_| input.error("Expected exactly one key attribute"))?; + let component_type: Type = input.parse()?; + Ok(Self { + component_type, + check_params, + }) + } +} - let check_generics = if attribute.path().is_ident("check_params") { - attribute.parse_args_with(Punctuated::parse_terminated)? - } else if attribute.path().is_ident("skip_check") { - Punctuated::new() - } else { - return Err(syn::Error::new( - attribute.span(), - "Expected either `#[skip_check]` or `#[check_params]` attribute for specifying the check generics", - )); - }; +pub fn parse_check_params(input: &ParseStream) -> syn::Result>> { + if input.peek(Pound) { + let attributes = input.call(Attribute::parse_outer)?; - Some(check_generics) + let [attribute]: [Attribute; 1] = attributes + .try_into() + .map_err(|_| input.error("Expected exactly one key attribute"))?; + + let check_params = if attribute.path().is_ident("check_params") { + attribute.parse_args_with(Punctuated::parse_terminated)? + } else if attribute.path().is_ident("skip_check") { + Punctuated::new() } else { - None + return Err(syn::Error::new( + attribute.span(), + "Expected either `#[skip_check]` or `#[check_params]` attribute for specifying the check generics", + )); }; - let component_type: Type = input.parse()?; - Ok(Self { - component_type, - check_generics, - }) + Ok(Some(check_params)) + } else { + Ok(None) } } diff --git a/crates/cgp-tests/src/tests/check_components.rs b/crates/cgp-tests/src/tests/check_components.rs index 1950de4b..d4fdfddf 100644 --- a/crates/cgp-tests/src/tests/check_components.rs +++ b/crates/cgp-tests/src/tests/check_components.rs @@ -43,6 +43,11 @@ pub fn test_basic_check_components() { BarTypeProviderComponent, ]: UseType<()>, + + #[check_params( + (Index<5>, Index<6>), + (Index<7>, Index<8>), + )] [ #[check_params( Index<0>, From f8bb6e799ad100de9cb6cd41260ffd76b8b1ff50 Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Sat, 28 Feb 2026 13:29:18 +0100 Subject: [PATCH 09/13] Use `DelegateValue` to parse entry value --- .../src/entrypoints/delegate_and_check_components.rs | 6 ++---- .../src/parse/delegate_and_check_components.rs | 4 ++-- crates/cgp-tests/src/tests/use_delegate/getter.rs | 11 ++++++++++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/crates/cgp-macro-lib/src/entrypoints/delegate_and_check_components.rs b/crates/cgp-macro-lib/src/entrypoints/delegate_and_check_components.rs index 18727ac7..3d5cc2ca 100644 --- a/crates/cgp-macro-lib/src/entrypoints/delegate_and_check_components.rs +++ b/crates/cgp-macro-lib/src/entrypoints/delegate_and_check_components.rs @@ -9,7 +9,7 @@ use crate::check_components::derive_check_components; use crate::delegate_components::impl_delegate_components; use crate::parse::{ CheckComponents, CheckEntries, CheckEntry, DelegateAndCheckSpec, DelegateEntry, DelegateKey, - DelegateValue, ImplGenerics, + ImplGenerics, }; pub fn delegate_and_check_components(body: TokenStream) -> syn::Result { @@ -55,11 +55,9 @@ pub fn delegate_and_check_components(body: TokenStream) -> syn::Result, pub mode: DelegateMode, - pub value: Type, + pub value: DelegateValue, } #[derive(Clone)] diff --git a/crates/cgp-tests/src/tests/use_delegate/getter.rs b/crates/cgp-tests/src/tests/use_delegate/getter.rs index 2ba7317e..7a2d2e51 100644 --- a/crates/cgp-tests/src/tests/use_delegate/getter.rs +++ b/crates/cgp-tests/src/tests/use_delegate/getter.rs @@ -34,14 +34,23 @@ pub fn test_derive_delegate() { pub bar: String, } - delegate_components! { + delegate_and_check_components! { MyContext { + #[check_params( + (Index<1>, Index<0>), + (Index<0>, Index<1>), + )] FooTypeProviderAtComponent: UseDelegate< new FooTypes { Index<1>: UseType, Index<0>: UseType, } >, + + #[check_params( + (Index<1>, Index<0>), + (Index<0>, Index<1>), + )] FooGetterAtComponent: UseDelegate< new FooGetters { Index<1>: UseField, From 3174800cbfec311712abc8d7cbe48fe50d1b4e5d Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Sat, 28 Feb 2026 13:34:36 +0100 Subject: [PATCH 10/13] Use `Attribute` to parse `#[check_providers]` --- .../src/parse/check_components.rs | 21 ++++++++----------- .../parse/delegate_and_check_components.rs | 2 +- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/crates/cgp-macro-lib/src/parse/check_components.rs b/crates/cgp-macro-lib/src/parse/check_components.rs index 56cc6d10..48165251 100644 --- a/crates/cgp-macro-lib/src/parse/check_components.rs +++ b/crates/cgp-macro-lib/src/parse/check_components.rs @@ -3,7 +3,7 @@ use syn::parse::{Parse, ParseStream}; use syn::punctuated::Punctuated; use syn::spanned::Spanned; use syn::token::{Bracket, Colon, Comma, For, Lt, Pound, Where}; -use syn::{Ident, Type, WhereClause, braced, bracketed, parenthesized}; +use syn::{Attribute, Ident, Type, WhereClause, braced, bracketed}; use crate::parse::ImplGenerics; @@ -50,24 +50,21 @@ impl Parse for CheckComponentsSpecs { impl Parse for CheckComponents { fn parse(input: ParseStream) -> syn::Result { let check_provider = if input.peek(Pound) { - let _: Pound = input.parse()?; + let attributes = input.call(Attribute::parse_outer)?; - let content; - bracketed!(content in input); + let [attribute]: [Attribute; 1] = attributes + .try_into() + .map_err(|_| input.error("Expected exactly one attribute "))?; - let command: Ident = content.parse()?; - if command != "check_providers" { + if !attribute.path().is_ident("check_providers") { return Err(syn::Error::new( - command.span(), - "expected `check_providers` attribute", + attribute.span(), + "Expected `#[check_providers]` attribute", )); } - let raw_providers; - parenthesized!(raw_providers in content); - let provider_types: Punctuated = - Punctuated::parse_terminated(&raw_providers)?; + attribute.parse_args_with(Punctuated::parse_terminated)?; Some(provider_types.into_iter().collect()) } else { diff --git a/crates/cgp-macro-lib/src/parse/delegate_and_check_components.rs b/crates/cgp-macro-lib/src/parse/delegate_and_check_components.rs index b45f967f..3bb3fbec 100644 --- a/crates/cgp-macro-lib/src/parse/delegate_and_check_components.rs +++ b/crates/cgp-macro-lib/src/parse/delegate_and_check_components.rs @@ -47,7 +47,7 @@ impl Parse for DelegateAndCheckSpec { if !attribute.path().is_ident("check_trait") { return Err(syn::Error::new( attribute.span(), - "Expected `check_trait` attribute for specifying the check trait name", + "Expected `#[check_trait]` attribute for specifying the check trait name", )); } From ac112116816dff9680d3d8c2f6e3e3d3c598b454 Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Sat, 28 Feb 2026 13:44:37 +0100 Subject: [PATCH 11/13] Better handle `#[check_providers]` --- .../src/check_components/derive.rs | 8 ++- .../delegate_and_check_components.rs | 2 +- .../src/parse/check_components.rs | 61 ++++++++++++------- 3 files changed, 46 insertions(+), 25 deletions(-) diff --git a/crates/cgp-macro-lib/src/check_components/derive.rs b/crates/cgp-macro-lib/src/check_components/derive.rs index 91ce6dc2..bc1bbb16 100644 --- a/crates/cgp-macro-lib/src/check_components/derive.rs +++ b/crates/cgp-macro-lib/src/check_components/derive.rs @@ -1,12 +1,14 @@ use quote::quote; +use syn::punctuated::Punctuated; +use syn::token::Comma; use syn::{ItemImpl, ItemTrait, Type, parse2}; use crate::check_components::override_span; use crate::parse::{CheckComponents, CheckEntry}; pub fn derive_check_components(spec: &CheckComponents) -> syn::Result<(ItemTrait, Vec)> { - if let Some(providers) = &spec.check_provider { - return derive_check_provider(spec, providers); + if let Some(check_providers) = &spec.check_providers { + return derive_check_provider(spec, check_providers); } let mut item_impls = Vec::new(); @@ -49,7 +51,7 @@ pub fn derive_check_components(spec: &CheckComponents) -> syn::Result<(ItemTrait pub fn derive_check_provider( spec: &CheckComponents, - providers: &[Type], + providers: &Punctuated, ) -> syn::Result<(ItemTrait, Vec)> { let mut item_impls = Vec::new(); let unit: Type = parse2(quote!(()))?; diff --git a/crates/cgp-macro-lib/src/entrypoints/delegate_and_check_components.rs b/crates/cgp-macro-lib/src/entrypoints/delegate_and_check_components.rs index 3d5cc2ca..7a8fcd07 100644 --- a/crates/cgp-macro-lib/src/entrypoints/delegate_and_check_components.rs +++ b/crates/cgp-macro-lib/src/entrypoints/delegate_and_check_components.rs @@ -67,7 +67,7 @@ pub fn delegate_and_check_components(body: TokenStream) -> syn::Result>, + pub check_providers: Option>, pub impl_generics: ImplGenerics, pub trait_name: Ident, pub context_type: Type, @@ -49,26 +50,26 @@ impl Parse for CheckComponentsSpecs { impl Parse for CheckComponents { fn parse(input: ParseStream) -> syn::Result { - let check_provider = if input.peek(Pound) { - let attributes = input.call(Attribute::parse_outer)?; + let mut check_providers: Option> = None; - let [attribute]: [Attribute; 1] = attributes - .try_into() - .map_err(|_| input.error("Expected exactly one attribute "))?; + if input.peek(Pound) { + let attributes = input.call(Attribute::parse_outer)?; - if !attribute.path().is_ident("check_providers") { - return Err(syn::Error::new( - attribute.span(), - "Expected `#[check_providers]` attribute", - )); + for attribute in attributes { + if attribute.path().is_ident("check_providers") { + let provider_types: Punctuated = + attribute.parse_args_with(Punctuated::parse_terminated)?; + + check_providers + .get_or_insert_default() + .extend(provider_types); + } else { + return Err(syn::Error::new( + attribute.span(), + format!("Invalid attribute {}", attribute.to_token_stream()), + )); + } } - - let provider_types: Punctuated = - attribute.parse_args_with(Punctuated::parse_terminated)?; - - Some(provider_types.into_iter().collect()) - } else { - None }; let impl_generics = if input.peek(Lt) { @@ -77,12 +78,30 @@ impl Parse for CheckComponents { Default::default() }; - let trait_name = input.parse()?; - + let trait_name: Ident = input.parse()?; let _: For = input.parse()?; let context_type: Type = input.parse()?; + // let (trait_name, context_type) = { + // let trait_name: Ident = input.parse()?; + + // if input.peek(For) { + // let _: For = input.parse()?; + + // let context_type: Type = input.parse()?; + // (trait_name, context_type) + // } else { + // let context_type = trait_name; + // let trait_name = Ident::new( + // &format!("__CanUse{}", context_type), + // context_type.span(), + // ); + + // (trait_name, context_type) + // } + // }; + let where_clause = if input.peek(Where) { input.parse()? } else { @@ -98,7 +117,7 @@ impl Parse for CheckComponents { let entries: CheckEntries = content.parse()?; Ok(Self { - check_provider, + check_providers, impl_generics, trait_name, context_type, From 345a199026c1b212e236a1c61b6b19906fd76876 Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Sat, 28 Feb 2026 13:56:46 +0100 Subject: [PATCH 12/13] Use `#[check_trait]` syntax in `check_components!` --- .../src/parse/check_components.rs | 47 ++++++++++--------- .../parse/delegate_and_check_components.rs | 44 +++++++++-------- .../cgp-tests/src/tests/check_components.rs | 12 +++-- .../src/tests/use_delegate/getter.rs | 5 +- .../component_tests/abstract_types/foreign.rs | 2 +- .../abstract_types/self_referential.rs | 2 +- .../component_tests/cgp_component/constant.rs | 2 +- .../component_tests/cgp_component/lifetime.rs | 2 +- .../cgp_impl/implicit_args/generics.rs | 2 +- .../extensible_data_tests/variants/shape.rs | 2 +- crates/cgp-tests/tests/handler_tests/pipe.rs | 4 +- .../preset_tests/basic/consumer_delegate.rs | 2 +- .../tests/preset_tests/basic/contexts.rs | 2 +- .../generics/consumer_delegate.rs | 7 +-- .../tests/preset_tests/generics/contexts.rs | 7 +-- .../generics_inheritance/contexts.rs | 6 +-- .../preset_tests/inheritance/contexts.rs | 2 +- .../nested_inheritance/contexts.rs | 2 +- .../tests/preset_tests/wrapped/context.rs | 2 +- 19 files changed, 82 insertions(+), 72 deletions(-) diff --git a/crates/cgp-macro-lib/src/parse/check_components.rs b/crates/cgp-macro-lib/src/parse/check_components.rs index 9ae106dc..74d636c6 100644 --- a/crates/cgp-macro-lib/src/parse/check_components.rs +++ b/crates/cgp-macro-lib/src/parse/check_components.rs @@ -3,10 +3,10 @@ use quote::ToTokens; use syn::parse::{Parse, ParseStream}; use syn::punctuated::Punctuated; use syn::spanned::Spanned; -use syn::token::{Bracket, Colon, Comma, For, Lt, Pound, Where}; -use syn::{Attribute, Ident, Type, WhereClause, braced, bracketed}; +use syn::token::{Bracket, Colon, Comma, Lt, Pound, Where}; +use syn::{Attribute, Ident, Type, WhereClause, braced, bracketed, parse2}; -use crate::parse::ImplGenerics; +use crate::parse::{ImplGenerics, SimpleType}; pub struct CheckComponentsSpecs { pub specs: Vec, @@ -51,6 +51,7 @@ impl Parse for CheckComponentsSpecs { impl Parse for CheckComponents { fn parse(input: ParseStream) -> syn::Result { let mut check_providers: Option> = None; + let mut m_check_trait_name: Option = None; if input.peek(Pound) { let attributes = input.call(Attribute::parse_outer)?; @@ -63,6 +64,17 @@ impl Parse for CheckComponents { check_providers .get_or_insert_default() .extend(provider_types); + } else if attribute.path().is_ident("check_trait") { + let check_trait_name: Ident = attribute.parse_args()?; + + if m_check_trait_name.is_some() { + return Err(syn::Error::new( + attribute.span(), + "Multiple `#[check_trait]` attributes found. Expected at most one.", + )); + } + + m_check_trait_name = Some(check_trait_name); } else { return Err(syn::Error::new( attribute.span(), @@ -78,29 +90,18 @@ impl Parse for CheckComponents { Default::default() }; - let trait_name: Ident = input.parse()?; - let _: For = input.parse()?; - let context_type: Type = input.parse()?; - // let (trait_name, context_type) = { - // let trait_name: Ident = input.parse()?; - - // if input.peek(For) { - // let _: For = input.parse()?; - - // let context_type: Type = input.parse()?; - // (trait_name, context_type) - // } else { - // let context_type = trait_name; - // let trait_name = Ident::new( - // &format!("__CanUse{}", context_type), - // context_type.span(), - // ); + let trait_name = if let Some(check_trait_name) = m_check_trait_name { + check_trait_name + } else { + let context_type: SimpleType = parse2(context_type.to_token_stream())?; - // (trait_name, context_type) - // } - // }; + Ident::new( + &format!("__CanUse{}", context_type.name), + context_type.span(), + ) + }; let where_clause = if input.peek(Where) { input.parse()? diff --git a/crates/cgp-macro-lib/src/parse/delegate_and_check_components.rs b/crates/cgp-macro-lib/src/parse/delegate_and_check_components.rs index 3bb3fbec..33b38f9a 100644 --- a/crates/cgp-macro-lib/src/parse/delegate_and_check_components.rs +++ b/crates/cgp-macro-lib/src/parse/delegate_and_check_components.rs @@ -37,25 +37,7 @@ impl Parse for DelegateAndCheckSpec { Default::default() }; - let m_trait_name = if input.peek(Pound) { - let attributes = input.call(Attribute::parse_outer)?; - - let [attribute]: [Attribute; 1] = attributes.try_into().map_err(|_| { - input.error("Expected exactly one attribute for the check trait name") - })?; - - if !attribute.path().is_ident("check_trait") { - return Err(syn::Error::new( - attribute.span(), - "Expected `#[check_trait]` attribute for specifying the check trait name", - )); - } - - let ident: Ident = attribute.parse_args()?; - Some(ident) - } else { - None - }; + let m_trait_name = parse_check_trait_name(input)?; let context_type: Type = input.parse()?; @@ -126,7 +108,29 @@ impl Parse for DelegateAndCheckKey { } } -pub fn parse_check_params(input: &ParseStream) -> syn::Result>> { +pub fn parse_check_trait_name(input: ParseStream) -> syn::Result> { + if input.peek(Pound) { + let attributes = input.call(Attribute::parse_outer)?; + + let [attribute]: [Attribute; 1] = attributes + .try_into() + .map_err(|_| input.error("Expected exactly one attribute for the check trait name"))?; + + if !attribute.path().is_ident("check_trait") { + return Err(syn::Error::new( + attribute.span(), + "Expected `#[check_trait]` attribute for specifying the check trait name", + )); + } + + let ident: Ident = attribute.parse_args()?; + Ok(Some(ident)) + } else { + Ok(None) + } +} + +pub fn parse_check_params(input: ParseStream) -> syn::Result>> { if input.peek(Pound) { let attributes = input.call(Attribute::parse_outer)?; diff --git a/crates/cgp-tests/src/tests/check_components.rs b/crates/cgp-tests/src/tests/check_components.rs index d4fdfddf..f32036d1 100644 --- a/crates/cgp-tests/src/tests/check_components.rs +++ b/crates/cgp-tests/src/tests/check_components.rs @@ -66,7 +66,8 @@ pub fn test_basic_check_components() { } check_components! { - CanUseContext for Context { + #[check_trait(CanUseContext)] + Context { FooTypeProviderComponent, BarTypeProviderComponent, FooGetterAtComponent: [ @@ -77,7 +78,8 @@ pub fn test_basic_check_components() { Index<3>, } - CanUseContext2 for Context { + #[check_trait(CanUseContext2)] + Context { BarGetterAtComponent: [ (Index<0>, Index<1>), (Index<1>, Index<0>), @@ -93,11 +95,12 @@ pub fn test_basic_check_components() { ] } + #[check_trait(CanUseDummyField)] #[check_providers( UseField, UseField, )] - CanUseDummyField for Context { + Context { FooGetterAtComponent: [ Index<0>, Index<1>, @@ -169,8 +172,7 @@ pub fn test_generic_check_components() { } check_components! { - <'a, I> - CanUseContext for Context + <'a, I> Context where I: Clone, { diff --git a/crates/cgp-tests/src/tests/use_delegate/getter.rs b/crates/cgp-tests/src/tests/use_delegate/getter.rs index 7a2d2e51..01ebf26d 100644 --- a/crates/cgp-tests/src/tests/use_delegate/getter.rs +++ b/crates/cgp-tests/src/tests/use_delegate/getter.rs @@ -61,7 +61,8 @@ pub fn test_derive_delegate() { } check_components! { - CanUseMyContext for MyContext { + #[check_trait(CanUseMyContext)] + MyContext { FooGetterAtComponent: [ (Index<1>, Index<0>), (Index<0>, Index<1>), @@ -104,7 +105,7 @@ pub fn test_derive_delegate2() { } check_components! { - CanUseMyContext for MyContext { + MyContext { FooGetterAtComponent: [ (Index<1>, Index<0>), (Index<0>, Index<1>), diff --git a/crates/cgp-tests/tests/component_tests/abstract_types/foreign.rs b/crates/cgp-tests/tests/component_tests/abstract_types/foreign.rs index 7fe7bbde..2818e32d 100644 --- a/crates/cgp-tests/tests/component_tests/abstract_types/foreign.rs +++ b/crates/cgp-tests/tests/component_tests/abstract_types/foreign.rs @@ -48,7 +48,7 @@ delegate_components! { } check_components! { - CanUseRectangle for Rectangle { + Rectangle { AreaCalculatorComponent: Types, } } diff --git a/crates/cgp-tests/tests/component_tests/abstract_types/self_referential.rs b/crates/cgp-tests/tests/component_tests/abstract_types/self_referential.rs index ee7112b4..ee96d510 100644 --- a/crates/cgp-tests/tests/component_tests/abstract_types/self_referential.rs +++ b/crates/cgp-tests/tests/component_tests/abstract_types/self_referential.rs @@ -17,7 +17,7 @@ delegate_components! { } check_components! { - CanUseApp for App { + App { ScalarTypeProviderComponent, } } diff --git a/crates/cgp-tests/tests/component_tests/cgp_component/constant.rs b/crates/cgp-tests/tests/component_tests/cgp_component/constant.rs index 4587f613..1f8e018c 100644 --- a/crates/cgp-tests/tests/component_tests/cgp_component/constant.rs +++ b/crates/cgp-tests/tests/component_tests/cgp_component/constant.rs @@ -55,7 +55,7 @@ pub fn test_component_with_generic_const() { } check_components! { - CanUseMyContext for MyContext { + MyContext { ConstantGetterComponent, } } diff --git a/crates/cgp-tests/tests/component_tests/cgp_component/lifetime.rs b/crates/cgp-tests/tests/component_tests/cgp_component/lifetime.rs index e3730a6f..af0e4439 100644 --- a/crates/cgp-tests/tests/component_tests/cgp_component/lifetime.rs +++ b/crates/cgp-tests/tests/component_tests/cgp_component/lifetime.rs @@ -34,7 +34,7 @@ delegate_components! { } check_components! { - <'a> CanUseApp for App<'a> { + <'a> App<'a> { ReferenceGetterComponent: (Life<'a>, str), } diff --git a/crates/cgp-tests/tests/component_tests/cgp_impl/implicit_args/generics.rs b/crates/cgp-tests/tests/component_tests/cgp_impl/implicit_args/generics.rs index 2eb47f51..52709142 100644 --- a/crates/cgp-tests/tests/component_tests/cgp_impl/implicit_args/generics.rs +++ b/crates/cgp-tests/tests/component_tests/cgp_impl/implicit_args/generics.rs @@ -31,7 +31,7 @@ delegate_components! { } check_components! { - CanUseRectangle for Rectangle { + Rectangle { AreaCalculatorComponent: f64, } } diff --git a/crates/cgp-tests/tests/extensible_data_tests/variants/shape.rs b/crates/cgp-tests/tests/extensible_data_tests/variants/shape.rs index 252f8739..83c07bb5 100644 --- a/crates/cgp-tests/tests/extensible_data_tests/variants/shape.rs +++ b/crates/cgp-tests/tests/extensible_data_tests/variants/shape.rs @@ -205,7 +205,7 @@ delegate_components! { } check_components! { - CanUseApp for App { + App { ComputerComponent: [ ((), Shape), ((), ShapePlus), diff --git a/crates/cgp-tests/tests/handler_tests/pipe.rs b/crates/cgp-tests/tests/handler_tests/pipe.rs index 538d661b..29fb2a97 100644 --- a/crates/cgp-tests/tests/handler_tests/pipe.rs +++ b/crates/cgp-tests/tests/handler_tests/pipe.rs @@ -57,7 +57,7 @@ pub fn test_pipe_computers() { check_components! { - CanUseMyContext for MyContext { + MyContext { ComputerComponent: (Tag, u64), } } @@ -126,7 +126,7 @@ pub fn test_pipe_handlers() { check_components! { - CanUseMyContext for MyContext { + MyContext { HandlerComponent: (Tag, u64), } } diff --git a/crates/cgp-tests/tests/preset_tests/basic/consumer_delegate.rs b/crates/cgp-tests/tests/preset_tests/basic/consumer_delegate.rs index 396d18f6..12130a7f 100644 --- a/crates/cgp-tests/tests/preset_tests/basic/consumer_delegate.rs +++ b/crates/cgp-tests/tests/preset_tests/basic/consumer_delegate.rs @@ -19,7 +19,7 @@ impl HasBar for MyContext { } check_components! { - CanUseMyContext for MyContext { + MyContext { FooTypeProviderComponent, BarTypeProviderComponent, FooGetterComponent, diff --git a/crates/cgp-tests/tests/preset_tests/basic/contexts.rs b/crates/cgp-tests/tests/preset_tests/basic/contexts.rs index 56e222af..e9a03f01 100644 --- a/crates/cgp-tests/tests/preset_tests/basic/contexts.rs +++ b/crates/cgp-tests/tests/preset_tests/basic/contexts.rs @@ -19,7 +19,7 @@ delegate_components! { } check_components! { - CanUseMyContext for MyContext { + MyContext { FooTypeProviderComponent, BarTypeProviderComponent, FooGetterComponent, diff --git a/crates/cgp-tests/tests/preset_tests/generics/consumer_delegate.rs b/crates/cgp-tests/tests/preset_tests/generics/consumer_delegate.rs index 06eae6e4..55bd3295 100644 --- a/crates/cgp-tests/tests/preset_tests/generics/consumer_delegate.rs +++ b/crates/cgp-tests/tests/preset_tests/generics/consumer_delegate.rs @@ -13,7 +13,8 @@ pub struct MyContext { } check_components! { - CanUseMyContext for MyContext { + #[check_trait(CanUseMyContext)] + MyContext { FooTypeProviderComponent, BarTypeProviderComponent, BarGetterComponent, @@ -21,8 +22,8 @@ check_components! { } check_components! { - - CanUseFooGetter for MyContext { + #[check_trait(CanUseFooGetter)] + MyContext { FooGetterComponent>: Index, } } diff --git a/crates/cgp-tests/tests/preset_tests/generics/contexts.rs b/crates/cgp-tests/tests/preset_tests/generics/contexts.rs index 06eae6e4..55bd3295 100644 --- a/crates/cgp-tests/tests/preset_tests/generics/contexts.rs +++ b/crates/cgp-tests/tests/preset_tests/generics/contexts.rs @@ -13,7 +13,8 @@ pub struct MyContext { } check_components! { - CanUseMyContext for MyContext { + #[check_trait(CanUseMyContext)] + MyContext { FooTypeProviderComponent, BarTypeProviderComponent, BarGetterComponent, @@ -21,8 +22,8 @@ check_components! { } check_components! { - - CanUseFooGetter for MyContext { + #[check_trait(CanUseFooGetter)] + MyContext { FooGetterComponent>: Index, } } diff --git a/crates/cgp-tests/tests/preset_tests/generics_inheritance/contexts.rs b/crates/cgp-tests/tests/preset_tests/generics_inheritance/contexts.rs index d6548df8..84248ef6 100644 --- a/crates/cgp-tests/tests/preset_tests/generics_inheritance/contexts.rs +++ b/crates/cgp-tests/tests/preset_tests/generics_inheritance/contexts.rs @@ -13,15 +13,15 @@ pub struct MyContext { } check_components! { - CanUseMyContext for MyContext { + MyContext { FooTypeProviderComponent, BarTypeProviderComponent, } } check_components! { - - CanUseFooGetter for MyContext { + #[check_trait(CanUseFooGetter)] + MyContext { [ FooGetterComponent, BarGetterComponent, diff --git a/crates/cgp-tests/tests/preset_tests/inheritance/contexts.rs b/crates/cgp-tests/tests/preset_tests/inheritance/contexts.rs index a7c994db..cda5816c 100644 --- a/crates/cgp-tests/tests/preset_tests/inheritance/contexts.rs +++ b/crates/cgp-tests/tests/preset_tests/inheritance/contexts.rs @@ -13,7 +13,7 @@ pub struct MyContext { } check_components! { - CanUseMyContext for MyContext { + MyContext { FooTypeProviderComponent, BarTypeProviderComponent, FooGetterComponent, diff --git a/crates/cgp-tests/tests/preset_tests/nested_inheritance/contexts.rs b/crates/cgp-tests/tests/preset_tests/nested_inheritance/contexts.rs index 5cca37b7..da718ab4 100644 --- a/crates/cgp-tests/tests/preset_tests/nested_inheritance/contexts.rs +++ b/crates/cgp-tests/tests/preset_tests/nested_inheritance/contexts.rs @@ -15,7 +15,7 @@ pub struct MyContext { } check_components! { - CanUseMyContext for MyContext { + MyContext { FooTypeProviderComponent, BarTypeProviderComponent, FooGetterComponent, diff --git a/crates/cgp-tests/tests/preset_tests/wrapped/context.rs b/crates/cgp-tests/tests/preset_tests/wrapped/context.rs index 93f0bec2..c6ea5526 100644 --- a/crates/cgp-tests/tests/preset_tests/wrapped/context.rs +++ b/crates/cgp-tests/tests/preset_tests/wrapped/context.rs @@ -17,7 +17,7 @@ delegate_components! { } check_components! { - CanUseMyContext for MyContext { + MyContext { ErrorRaiserComponent: [ BoxError, Infallible, From c4faf9bae52a3a939a81819616126e95fcf5786e Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Sat, 28 Feb 2026 13:59:03 +0100 Subject: [PATCH 13/13] Fix clippy --- .../cgp-macro-lib/src/parse/delegate_and_check_components.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/cgp-macro-lib/src/parse/delegate_and_check_components.rs b/crates/cgp-macro-lib/src/parse/delegate_and_check_components.rs index 33b38f9a..118d0f5e 100644 --- a/crates/cgp-macro-lib/src/parse/delegate_and_check_components.rs +++ b/crates/cgp-macro-lib/src/parse/delegate_and_check_components.rs @@ -69,7 +69,7 @@ impl Parse for DelegateAndCheckSpec { impl Parse for DelegateAndCheckEntry { fn parse(input: ParseStream) -> syn::Result { - let check_params = parse_check_params(&input)?; + let check_params = parse_check_params(input)?; let mut keys = if input.peek(Bracket) { let body; @@ -98,7 +98,7 @@ impl Parse for DelegateAndCheckEntry { impl Parse for DelegateAndCheckKey { fn parse(input: ParseStream) -> syn::Result { - let check_params = parse_check_params(&input)?; + let check_params = parse_check_params(input)?; let component_type: Type = input.parse()?; Ok(Self {