File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed
godot-macros/src/class/data_models Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -244,7 +244,7 @@ pub trait IndexEnum: EngineEnum {
244
244
#[ diagnostic:: on_unimplemented(
245
245
message = "Class `{Self}` requires a `Base<T>` field" ,
246
246
label = "missing field `_base: Base<...>`" ,
247
- note = "A base field is required to access the base from within `self`, or when using script virtual functions" ,
247
+ note = "A base field is required to access the base from within `self`, for script- virtual functions or #[rpc] methods " ,
248
248
note = "see also: https://godot-rust.github.io/book/register/classes.html#the-base-field"
249
249
) ]
250
250
pub trait WithBaseField : GodotClass + Bounds < Declarer = bounds:: DeclUser > {
Original file line number Diff line number Diff line change @@ -74,7 +74,8 @@ pub fn make_rpc_registrations_fn(class_name: &Ident, funcs: &[FuncDefinition]) -
74
74
}
75
75
76
76
quote ! {
77
- #[ allow( clippy:: needless_update) ] // clippy complains about using `..RpcConfig::default()` if all fields are overridden
77
+ // Clippy complains about using `..RpcConfig::default()` if all fields are overridden.
78
+ #[ allow( clippy:: needless_update) ]
78
79
fn __register_rpcs( object: & mut dyn :: std:: any:: Any ) {
79
80
use :: std:: any:: Any ;
80
81
use :: godot:: register:: RpcConfig ;
@@ -83,10 +84,12 @@ pub fn make_rpc_registrations_fn(class_name: &Ident, funcs: &[FuncDefinition]) -
83
84
use :: godot:: classes:: Node ;
84
85
use :: godot:: obj:: { WithBaseField , Gd } ;
85
86
86
- let mut gd = object
87
- . downcast_mut:: <#class_name>( )
88
- . expect( "bad type erasure when registering RPCs" )
89
- . to_gd( ) ;
87
+ let this = object
88
+ . downcast_ref:: <#class_name>( )
89
+ . expect( "bad type erasure when registering RPCs" ) ;
90
+
91
+ // Use fully-qualified syntax, so that error message isn't just "no method named `to_gd` found".
92
+ let mut gd = :: godot:: obj:: WithBaseField :: to_gd( this) ;
90
93
91
94
let node = gd. upcast_mut:: <Node >( ) ;
92
95
#( #rpc_registrations ) *
You can’t perform that action at this time.
0 commit comments