@@ -59,13 +59,6 @@ pub struct ConfigDef {
59
59
pub consts_metadata : Vec < ConstMetadataDef > ,
60
60
/// Associated types metadata.
61
61
pub associated_types_metadata : Vec < AssociatedTypeMetadataDef > ,
62
- /// Whether the trait has the associated type `Event`, note that those bounds are
63
- /// checked:
64
- /// * `IsType<Self as frame_system::Config>::RuntimeEvent`
65
- /// * `From<Event>` or `From<Event<T>>` or `From<Event<T, I>>`
66
- pub has_event_type : bool ,
67
- /// Whether the supertrait `frame_system::Config` defines associated type `RuntimeEvent`.
68
- pub has_event_bound : bool ,
69
62
/// The where clause on trait definition but modified so `Self` is `T`.
70
63
pub where_clause : Option < syn:: WhereClause > ,
71
64
/// Whether a default sub-trait should be generated.
@@ -371,38 +364,6 @@ fn contains_type_info_bound(ty: &TraitItemType) -> bool {
371
364
} )
372
365
}
373
366
374
- /// Check that supertrait `Config` contains `RuntimeEvent` associated type bound with
375
- /// `From<Event<Self>>`.
376
- ///
377
- /// NOTE: Does not check if the supertrait path is valid system config path.
378
- ///
379
- /// ```rs
380
- /// pub trait Config: frame_system::Config {
381
- /// ```
382
- fn contains_runtime_event_associated_type_bound ( supertrait : & syn:: Path ) -> bool {
383
- if let Some ( args) = supertrait. segments . iter ( ) . find ( |s| s. ident == "Config" ) {
384
- if let syn:: PathArguments :: AngleBracketed ( args) = & args. arguments {
385
- for arg in & args. args {
386
- if let syn:: GenericArgument :: Constraint ( c) = arg {
387
- if c. ident != "RuntimeEvent" {
388
- continue ;
389
- }
390
-
391
- // Check `From<Event<Self>>` bound
392
- let from_event_bound = c
393
- . bounds
394
- . iter ( )
395
- . find_map ( |s| syn:: parse2 :: < FromEventParse > ( s. to_token_stream ( ) ) . ok ( ) ) ;
396
-
397
- return from_event_bound. is_some ( ) ;
398
- }
399
- }
400
- }
401
- }
402
-
403
- false
404
- }
405
-
406
367
impl ConfigDef {
407
368
pub fn try_from (
408
369
frame_system : & syn:: Path ,
@@ -444,16 +405,6 @@ impl ConfigDef {
444
405
false
445
406
} ;
446
407
447
- let has_event_bound = if is_frame_system {
448
- false
449
- } else {
450
- item. supertraits . iter ( ) . any ( |supertrait| {
451
- syn:: parse2 :: < syn:: Path > ( supertrait. to_token_stream ( ) )
452
- . map_or ( false , |b| contains_runtime_event_associated_type_bound ( & b) )
453
- } )
454
- } ;
455
-
456
- let mut has_event_type = false ;
457
408
let mut consts_metadata = vec ! [ ] ;
458
409
let mut associated_types_metadata = vec ! [ ] ;
459
410
let mut warnings = vec ! [ ] ;
@@ -464,7 +415,6 @@ impl ConfigDef {
464
415
} ;
465
416
for trait_item in & mut item. items {
466
417
let is_event = check_event_type ( frame_system, trait_item, has_instance) ?;
467
- has_event_type = has_event_type || is_event;
468
418
469
419
let mut already_no_default = false ;
470
420
let mut already_constant = false ;
@@ -480,7 +430,7 @@ impl ConfigDef {
480
430
if !type_event. attrs . iter ( ) . any ( |attr| attr == & allow_dep) {
481
431
let warning = Warning :: new_deprecated ( "RuntimeEvent" )
482
432
. old ( "have `RuntimeEvent` associated type in the pallet config" )
483
- . new ( "remove it or explicitly define it as an associated type bound in the system supertrait : \n
433
+ . new ( "remove it as it is redundant since associated bound gets appended automatically : \n
484
434
pub trait Config: frame_system::Config<RuntimeEvent: From<Event<Self>>> { }" )
485
435
. help_link ( "https://github.com/paritytech/polkadot-sdk/pull/7229" )
486
436
. span ( type_event. ident . span ( ) )
@@ -648,8 +598,6 @@ impl ConfigDef {
648
598
has_instance,
649
599
consts_metadata,
650
600
associated_types_metadata,
651
- has_event_type,
652
- has_event_bound,
653
601
where_clause,
654
602
default_sub_trait,
655
603
warnings,
@@ -774,52 +722,4 @@ mod tests {
774
722
let path = syn:: parse2 :: < syn:: Path > ( quote:: quote!( something:: Config ) ) . unwrap ( ) ;
775
723
assert ! ( !has_expected_system_config( path, & frame_system) ) ;
776
724
}
777
-
778
- #[ test]
779
- fn contains_runtime_event_associated_type_bound_no_bound ( ) {
780
- let supertrait = syn:: parse2 :: < syn:: Path > ( quote:: quote!( frame_system:: Config ) ) . unwrap ( ) ;
781
- assert ! ( !contains_runtime_event_associated_type_bound( & supertrait) ) ;
782
- }
783
-
784
- #[ test]
785
- fn contains_runtime_event_associated_type_bound_works ( ) {
786
- let supertrait = syn:: parse2 :: < syn:: Path > ( quote:: quote!( Config ) ) ;
787
- assert ! ( contains_runtime_event_associated_type_bound( & supertrait. unwrap( ) ) ) ;
788
- }
789
- #[ test]
790
- fn contains_runtime_event_associated_type_bound_works_interface ( ) {
791
- let supertrait = syn:: parse2 :: < syn:: Path > ( quote:: quote!(
792
- Config <RuntimeEvent : From <Event <Self , I >>>
793
- ) ) ;
794
- assert ! ( contains_runtime_event_associated_type_bound( & supertrait. unwrap( ) ) ) ;
795
- }
796
-
797
- #[ test]
798
- fn contains_runtime_event_associated_type_bound_works_full_path ( ) {
799
- let supertrait = syn:: parse2 :: < syn:: Path > ( quote:: quote!( frame_system:: Config ) ) ;
800
- assert ! ( contains_runtime_event_associated_type_bound( & supertrait. unwrap( ) ) ) ;
801
- }
802
-
803
- #[ test]
804
- fn contains_runtime_event_associated_type_bound_invalid_supertrait ( ) {
805
- let supertrait =
806
- syn:: parse2 :: < syn:: Path > ( quote:: quote!( SystemConfig <RuntimeEvent : From <Event <Self >>>) )
807
- . unwrap ( ) ;
808
- assert ! ( !contains_runtime_event_associated_type_bound( & supertrait) ) ;
809
- }
810
-
811
- #[ test]
812
- fn contains_runtime_event_associated_type_bound_invalid_assoc_type_name ( ) {
813
- let supertrait =
814
- syn:: parse2 :: < syn:: Path > ( quote:: quote!( Config <NonRuntimeEvent : From <Event <Self >>>) )
815
- . unwrap ( ) ;
816
- assert ! ( !contains_runtime_event_associated_type_bound( & supertrait) ) ;
817
- }
818
- #[ test]
819
- fn contains_runtime_event_associated_type_bound_invalid_trait_bound ( ) {
820
- let supertrait =
821
- syn:: parse2 :: < syn:: Path > ( quote:: quote!( Config <RuntimeEvent : TryFrom <Event <Self >>>) )
822
- . unwrap ( ) ;
823
- assert ! ( !contains_runtime_event_associated_type_bound( & supertrait) ) ;
824
- }
825
725
}
0 commit comments