Skip to content

Commit ff441ba

Browse files
felinirabilelmoussaoui
authored andcommitted
glib: Add unimplemented diagnostic to IsA linking to the wrapper macro
1 parent 865f49a commit ff441ba

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

glib/src/object.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ pub unsafe trait ObjectType:
6363
///
6464
/// The trait can only be implemented if the appropriate `ToGlibPtr`
6565
/// implementations exist.
66+
#[diagnostic::on_unimplemented(
67+
message = "the trait `glib::object::IsA<{T}>` is not implemented for `{Self}`",
68+
label = "requires `{Self}` to be a GObject that can be statically cast to `{T}`",
69+
note = "if this is your own object, use the `glib::wrapper!` macro to implement this trait: https://gtk-rs.org/gtk-rs-core/stable/latest/docs/glib/macro.wrapper.html"
70+
)]
6671
pub unsafe trait IsA<T: ObjectType>:
6772
ObjectType + Into<T> + AsRef<T> + std::borrow::Borrow<T>
6873
{

0 commit comments

Comments
 (0)