@@ -20,6 +20,11 @@ use godot_ffi as sys;
20
20
///
21
21
/// Normally, you don't need to implement this trait yourself; use [`#[derive(GodotClass)]`](../register/derive.GodotClass.html) instead.
22
22
// Above intra-doc link to the derive-macro only works as HTML, not as symbol link.
23
+ #[ diagnostic:: on_unimplemented(
24
+ message = "Only classes registered with Godot are allowed in this context" ,
25
+ note = "you can use `#[derive(GodotClass)]` to register your own structs with Godot" ,
26
+ note = "see also: https://godot-rust.github.io/book/register/classes.html"
27
+ ) ]
23
28
pub trait GodotClass : Bounds + ' static
24
29
where
25
30
Self : Sized ,
@@ -206,6 +211,12 @@ pub trait IndexEnum: EngineEnum {
206
211
///
207
212
/// Gives direct access to the containing `Gd<Self>` from `Self`.
208
213
// Possible alternative for builder APIs, although even less ergonomic: Base<T> could be Base<T, Self> and return Gd<Self>.
214
+ #[ diagnostic:: on_unimplemented(
215
+ message = "Class `{Self}` requires a `Base<T>` field" ,
216
+ label = "missing field `_base: Base<...>`" ,
217
+ note = "A base field is required to access the base from within `self`, or when using script virtual functions" ,
218
+ note = "see also: https://godot-rust.github.io/book/register/classes.html#the-base-field"
219
+ ) ]
209
220
pub trait WithBaseField : GodotClass + Bounds < Declarer = bounds:: DeclUser > {
210
221
/// Returns the `Gd` pointer containing this object.
211
222
///
@@ -243,7 +254,7 @@ pub trait WithBaseField: GodotClass + Bounds<Declarer = bounds::DeclUser> {
243
254
/// # unsafe impl ExtensionLibrary for Test {}
244
255
/// ```
245
256
///
246
- /// However we cannot call methods that require `&mut Base`, such as
257
+ /// However, we cannot call methods that require `&mut Base`, such as
247
258
/// [`Node::add_child()`](crate::engine::Node::add_child).
248
259
///
249
260
/// ```compile_fail
@@ -423,6 +434,13 @@ pub mod cap {
423
434
/// This trait is not manually implemented, and you cannot call any methods. You can use it as a bound, but typically you'd use
424
435
/// it indirectly through [`Gd::default()`][crate::obj::Gd::default()]. Note that `Gd::default()` has an additional requirement on
425
436
/// being reference-counted, meaning not every `GodotDefault` class can automatically be used with `Gd::default()`.
437
+ #[ diagnostic:: on_unimplemented(
438
+ message = "Class `{Self}` requires either an `init` constructor, or explicit opt-out" ,
439
+ label = "needs `init`" ,
440
+ note = "To provide a default constructor, use `#[class(init)]` or implement an `init` method" ,
441
+ note = "To opt out, use `#[class(no_init)]`" ,
442
+ note = "see also: https://godot-rust.github.io/book/register/constructors.html"
443
+ ) ]
426
444
pub trait GodotDefault : GodotClass {
427
445
/// Provides a default smart pointer instance.
428
446
///
0 commit comments