@@ -2717,8 +2717,9 @@ unsafe impl SystemParam for FilteredResourcesMut<'_, '_> {
2717
2717
mod tests {
2718
2718
use super :: * ;
2719
2719
use crate :: {
2720
- self as bevy_ecs, // Necessary for the `SystemParam` Derive when used inside `bevy_ecs`.
2721
- system:: assert_is_system,
2720
+ self as bevy_ecs,
2721
+ prelude:: Component ,
2722
+ system:: { assert_is_system, IntoSystem , System } ,
2722
2723
} ;
2723
2724
use core:: cell:: RefCell ;
2724
2725
@@ -2949,4 +2950,132 @@ mod tests {
2949
2950
let _query: Query < ( ) > = p. downcast_mut_inner ( ) . unwrap ( ) ;
2950
2951
let _query: Query < ( ) > = p. downcast ( ) . unwrap ( ) ;
2951
2952
}
2953
+
2954
+ #[ derive( Component , Resource ) ]
2955
+ struct Foo ;
2956
+
2957
+ fn check_conflict < M > ( system : impl IntoSystem < ( ) , ( ) , M > ) {
2958
+ let mut world = World :: new ( ) ;
2959
+ let mut system = IntoSystem :: into_system ( system) ;
2960
+ system. initialize ( & mut world) ;
2961
+ }
2962
+
2963
+ #[ test]
2964
+ #[ should_panic]
2965
+ fn conflict_mut_world_multiple ( ) {
2966
+ fn system ( _: & mut World , _: & mut World ) { }
2967
+ check_conflict ( system) ;
2968
+ }
2969
+
2970
+ #[ test]
2971
+ #[ should_panic]
2972
+ fn conflict_mut_world_deferred_world ( ) {
2973
+ fn system ( _: & mut World , _: DeferredWorld ) { }
2974
+ check_conflict ( system) ;
2975
+ }
2976
+
2977
+ #[ test]
2978
+ #[ should_panic]
2979
+ fn conflict_mut_world_query ( ) {
2980
+ fn system ( _: & mut World , _: Query < & Foo > ) { }
2981
+ check_conflict ( system) ;
2982
+ }
2983
+
2984
+ #[ test]
2985
+ #[ should_panic]
2986
+ fn conflict_query_mut_world ( ) {
2987
+ fn system ( _: Query < & Foo > , _: & mut World ) { }
2988
+ check_conflict ( system) ;
2989
+ }
2990
+
2991
+ #[ test]
2992
+ #[ should_panic]
2993
+ fn conflict_mut_world_resource ( ) {
2994
+ fn system ( _: & mut World , _: Res < Foo > ) { }
2995
+ check_conflict ( system) ;
2996
+ }
2997
+
2998
+ #[ test]
2999
+ #[ should_panic]
3000
+ fn conflict_resource_mut_world ( ) {
3001
+ fn system ( _: Res < Foo > , _: & mut World ) { }
3002
+ check_conflict ( system) ;
3003
+ }
3004
+
3005
+ #[ test]
3006
+ fn no_conflict_mut_world_local ( ) {
3007
+ fn system ( _: & mut World , _: Local < u32 > ) { }
3008
+ check_conflict ( system) ;
3009
+ }
3010
+
3011
+ #[ test]
3012
+ fn no_conflict_mut_world_query_state ( ) {
3013
+ fn system ( _: & mut World , _: & mut QueryState < & Foo > ) { }
3014
+ check_conflict ( system) ;
3015
+ }
3016
+
3017
+ #[ test]
3018
+ fn no_conflict_mut_world_system_state ( ) {
3019
+ fn system ( _: & mut World , _: & mut SystemState < Query < & Foo > > ) { }
3020
+ check_conflict ( system) ;
3021
+ }
3022
+
3023
+ #[ test]
3024
+ fn no_conflict_mut_world_system_state_recursive ( ) {
3025
+ fn system ( _: & mut World , _: & mut SystemState < & mut SystemState < Query < & Foo > > > ) { }
3026
+ check_conflict ( system) ;
3027
+ }
3028
+
3029
+ #[ test]
3030
+ #[ should_panic]
3031
+ fn conflict_deferred_world_multiple ( ) {
3032
+ fn system ( _: DeferredWorld , _: DeferredWorld ) { }
3033
+ check_conflict ( system) ;
3034
+ }
3035
+
3036
+ #[ test]
3037
+ #[ should_panic]
3038
+ fn conflict_deferred_world_query ( ) {
3039
+ fn system ( _: DeferredWorld , _: Query < & Foo > ) { }
3040
+ check_conflict ( system) ;
3041
+ }
3042
+
3043
+ #[ test]
3044
+ #[ should_panic]
3045
+ fn conflict_query_deferred_world ( ) {
3046
+ fn system ( _: Query < & Foo > , _: DeferredWorld ) { }
3047
+ check_conflict ( system) ;
3048
+ }
3049
+
3050
+ #[ test]
3051
+ #[ should_panic]
3052
+ fn conflict_deferred_world_resource ( ) {
3053
+ fn system ( _: DeferredWorld , _: Res < Foo > ) { }
3054
+ check_conflict ( system) ;
3055
+ }
3056
+
3057
+ #[ test]
3058
+ #[ should_panic]
3059
+ fn conflict_resource_deferred_world ( ) {
3060
+ fn system ( _: Res < Foo > , _: DeferredWorld ) { }
3061
+ check_conflict ( system) ;
3062
+ }
3063
+
3064
+ #[ test]
3065
+ fn no_conflict_deferred_world_local ( ) {
3066
+ fn system ( _: DeferredWorld , _: Local < u32 > ) { }
3067
+ check_conflict ( system) ;
3068
+ }
3069
+
3070
+ #[ test]
3071
+ fn no_conflict_deferred_world_query_state ( ) {
3072
+ fn system ( _: DeferredWorld , _: & mut QueryState < & Foo > ) { }
3073
+ check_conflict ( system) ;
3074
+ }
3075
+
3076
+ #[ test]
3077
+ fn no_conflict_deferred_world_system_state ( ) {
3078
+ fn system ( _: DeferredWorld , _: & mut SystemState < Query < & Foo > > ) { }
3079
+ check_conflict ( system) ;
3080
+ }
2952
3081
}
0 commit comments