File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -266,6 +266,13 @@ fn process_godot_fns(
266
266
267
267
match attr. ty {
268
268
ItemAttrType :: Func ( func, rpc_info) => {
269
+ if rpc_info. is_some ( ) && is_secondary_impl {
270
+ return bail ! (
271
+ & function,
272
+ "#[rpc] is currently not supported in secondary impl blocks" ,
273
+ ) ?;
274
+ }
275
+
269
276
let external_attributes = function. attributes . clone ( ) ;
270
277
271
278
// Transforms the following.
Original file line number Diff line number Diff line change @@ -932,6 +932,38 @@ pub fn derive_godot_class(input: TokenStream) -> TokenStream {
932
932
/// pub fn two(&self) { }
933
933
/// }
934
934
/// ```
935
+ ///
936
+ /// `#[signal]` and `#[rpc]` attributes are not currently supported in secondary `impl` blocks.
937
+ ///
938
+ ///```compile_fail
939
+ /// # use godot::prelude::*;
940
+ /// # #[derive(GodotClass)]
941
+ /// # #[class(init, base=Node)]
942
+ /// # pub struct MyNode { base: Base<Node> }
943
+ /// # // Without primary `impl` block the compilation will always fail (no matter if #[signal] attribute is present or not)
944
+ /// # #[godot_api]
945
+ /// # impl MyNode {}
946
+ /// #[godot_api(secondary)]
947
+ /// impl MyNode {
948
+ /// #[signal]
949
+ /// fn my_signal();
950
+ /// }
951
+ /// ```
952
+ ///
953
+ ///```compile_fail
954
+ /// # use godot::prelude::*;
955
+ /// # #[derive(GodotClass)]
956
+ /// # #[class(init, base=Node)]
957
+ /// # pub struct MyNode { base: Base<Node> }
958
+ /// # // Without primary `impl` block the compilation will always fail (no matter if #[rpc] attribute is present or not).
959
+ /// # #[godot_api]
960
+ /// # impl MyNode {}
961
+ /// #[godot_api(secondary)]
962
+ /// impl MyNode {
963
+ /// #[rpc]
964
+ /// fn foo(&mut self) {}
965
+ /// }
966
+ /// ```
935
967
#[ doc(
936
968
alias = "func" ,
937
969
alias = "rpc" ,
You can’t perform that action at this time.
0 commit comments