@@ -450,46 +450,45 @@ fn make_oneditor_panic_inits(class_name: &Ident, all_fields: &[Field]) -> TokenS
450450 // Despite its name OnEditor shouldn't panic in the editor for tool classes.
451451 let is_in_editor = quote ! { <:: godot:: classes:: Engine as :: godot:: obj:: Singleton >:: singleton( ) . is_editor_hint( ) } ;
452452
453- let are_all_oneditor_fields_valid = quote ! { are_all_oneditor_fields_valid } ;
454-
455- // Informs the user which fields haven't been set, instead of panicking on the very first one. Useful for debugging.
456453 let on_editor_fields_checks = all_fields
457454 . iter ( )
458455 . filter ( |& field| field. is_oneditor )
459456 . map ( |field| {
460457 let field = & field. name ;
461- let warning_message =
462- format ! { "godot-rust: OnEditor field {field} hasn't been initialized." } ;
458+ let field_name_str = field. to_string ( ) ;
463459
464460 quote ! {
465461 if this. #field. is_invalid( ) {
466- :: godot:: global:: godot_warn!( #warning_message) ;
467- #are_all_oneditor_fields_valid = false ;
462+ uninitialized_fields. push( #field_name_str) ;
468463 }
469464 }
470465 } )
471466 . collect :: < Vec < _ > > ( ) ;
472467
473468 if !on_editor_fields_checks. is_empty ( ) {
469+ let class_name_str = class_name. to_string ( ) ;
470+
474471 quote ! {
475- // Triggers `clippy::useless_let_if_seq` lint if only one `#on_editor_fields_checks` is present.
476- #[ allow( clippy:: useless_let_if_seq) ]
477- fn __are_oneditor_fields_initalized( this: & #class_name) -> bool {
472+ fn __check_oneditor_fields( this: & #class_name) {
478473 // Early return for `#[class(tool)]`.
479474 if #is_in_editor {
480- return true ;
475+ return ;
481476 }
482477
483- let mut #are_all_oneditor_fields_valid : bool = true ;
478+ let mut uninitialized_fields : Vec < & str > = Vec :: new ( ) ;
484479
485480 #( #on_editor_fields_checks ) *
486481
487- #are_all_oneditor_fields_valid
482+ if !uninitialized_fields. is_empty( ) {
483+ panic!(
484+ "{}::ready(): OnEditor fields not initialized: {}" ,
485+ #class_name_str,
486+ uninitialized_fields. join( ", " ) ,
487+ ) ;
488+ }
488489 }
489490
490- if !__are_oneditor_fields_initalized( & self ) {
491- panic!( "OnEditor fields must be properly initialized before ready." )
492- }
491+ __check_oneditor_fields( & self ) ;
493492 }
494493 } else {
495494 TokenStream :: new ( )
0 commit comments