diff --git a/examples/virtual_methods/cat.rs b/examples/virtual_methods/cat.rs index dbc9b83ef371..c07269288384 100644 --- a/examples/virtual_methods/cat.rs +++ b/examples/virtual_methods/cat.rs @@ -96,19 +96,7 @@ impl Default for Cat { /// /// By convention we still create an empty `CatImpl` trait, this allows us to add /// 'protected' cat methods only available to be called by other Cats later. -pub trait CatImpl: PetImpl -where - ::Type: IsA, - ::Type: IsA, - ::Type: IsA, -{ -} +pub trait CatImpl: PetImpl + ObjectSubclass> {} /// To make this class subclassable we need to implement IsSubclassable -unsafe impl IsSubclassable for Cat -where - ::Type: IsA, - ::Type: IsA, - ::Type: IsA, -{ -} +unsafe impl IsSubclassable for Cat {} diff --git a/examples/virtual_methods/pet.rs b/examples/virtual_methods/pet.rs index d78a3b988806..28feac0e63a0 100644 --- a/examples/virtual_methods/pet.rs +++ b/examples/virtual_methods/pet.rs @@ -125,11 +125,7 @@ pub trait PetExt: IsA { impl> PetExt for T {} /// The `PetImpl` trait contains overridable virtual function definitions for [`Pet`] objects. -pub trait PetImpl: ObjectImpl -where - ::Type: IsA, - ::Type: IsA, -{ +pub trait PetImpl: ObjectImpl + ObjectSubclass> { /// Default implementation of a virtual method. /// /// This always calls into the implementation of the parent class so that if @@ -152,11 +148,7 @@ where /// The `PetImplExt` trait contains non-overridable methods for subclasses to use. /// /// These are supposed to be called only from inside implementations of `Pet` subclasses. -pub trait PetImplExt: PetImpl -where - ::Type: IsA, - ::Type: IsA, -{ +pub trait PetImplExt: PetImpl { /// Chains up to the parent implementation of [`PetImpl::pet`] fn parent_pet(&self) -> bool { let data = Self::type_data(); @@ -177,19 +169,10 @@ where } /// The `PetImplExt` trait is implemented for all subclasses that have [`Pet`] in the class hierarchy -impl PetImplExt for T -where - ::Type: IsA, - ::Type: IsA, -{ -} +impl PetImplExt for T {} /// To make this class subclassable we need to implement IsSubclassable -unsafe impl IsSubclassable for Pet -where - ::Type: IsA, - ::Type: IsA, -{ +unsafe impl IsSubclassable for Pet { /// Override the virtual method function pointers in subclasses to call directly into the /// `PetImpl` of the subclass. /// diff --git a/examples/virtual_methods/purrable.rs b/examples/virtual_methods/purrable.rs index f23d00e4beb1..66e542295f7a 100644 --- a/examples/virtual_methods/purrable.rs +++ b/examples/virtual_methods/purrable.rs @@ -82,11 +82,7 @@ pub trait PurrableExt: IsA { impl> PurrableExt for T {} /// The `PurrableImpl` trait contains virtual function definitions for [`Purrable`] objects. -pub trait PurrableImpl: ObjectImpl -where - ::Type: IsA, - ::Type: IsA, -{ +pub trait PurrableImpl: ObjectImpl + ObjectSubclass> { /// Return the current purring status. /// /// The default implementation chains up to the parent implementation, @@ -100,11 +96,7 @@ where /// The `PurrableImplExt` trait contains non-overridable methods for subclasses to use. /// /// These are supposed to be called only from inside implementations of `Pet` subclasses. -pub trait PurrableImplExt: PurrableImpl -where - ::Type: IsA, - ::Type: IsA, -{ +pub trait PurrableImplExt: PurrableImpl { /// Chains up to the parent implementation of [`PurrableExt::is_purring`] fn parent_is_purring(&self) -> bool { let data = Self::type_data(); @@ -117,19 +109,10 @@ where } /// The `PurrableImplExt` trait is implemented for all classes that implement [`Purrable`]. -impl PurrableImplExt for T -where - ::Type: IsA, - ::Type: IsA, -{ -} +impl PurrableImplExt for T {} /// To make this interface implementable we need to implement [`IsImplementable`] -unsafe impl IsImplementable for Purrable -where - ::Type: IsA, - ::Type: IsA, -{ +unsafe impl IsImplementable for Purrable { fn interface_init(iface: &mut glib::Interface) { let klass = iface.as_mut(); diff --git a/gdk-pixbuf/src/subclass/pixbuf_animation.rs b/gdk-pixbuf/src/subclass/pixbuf_animation.rs index ae08ed4ede66..5f378bfafdae 100644 --- a/gdk-pixbuf/src/subclass/pixbuf_animation.rs +++ b/gdk-pixbuf/src/subclass/pixbuf_animation.rs @@ -13,11 +13,7 @@ use glib::{prelude::*, subclass::prelude::*, translate::*}; use crate::{ffi, Pixbuf, PixbufAnimation, PixbufAnimationIter}; -pub trait PixbufAnimationImpl: ObjectImpl -where - ::Type: IsA, - ::Type: IsA, -{ +pub trait PixbufAnimationImpl: ObjectImpl + ObjectSubclass> { fn is_static_image(&self) -> bool { self.parent_is_static_image() } @@ -35,11 +31,7 @@ where } } -pub trait PixbufAnimationImplExt: ObjectSubclass + PixbufAnimationImpl -where - ::Type: IsA, - ::Type: IsA, -{ +pub trait PixbufAnimationImplExt: PixbufAnimationImpl { fn parent_is_static_image(&self) -> bool { unsafe { let data = Self::type_data(); @@ -119,18 +111,9 @@ where } } -impl PixbufAnimationImplExt for T -where - ::Type: IsA, - ::Type: IsA, -{ -} +impl PixbufAnimationImplExt for T {} -unsafe impl IsSubclassable for PixbufAnimation -where - ::Type: IsA, - ::Type: IsA, -{ +unsafe impl IsSubclassable for PixbufAnimation { fn class_init(class: &mut ::glib::Class) { Self::parent_class_init::(class); @@ -144,11 +127,7 @@ where unsafe extern "C" fn animation_is_static_image( ptr: *mut ffi::GdkPixbufAnimation, -) -> glib::ffi::gboolean -where - ::Type: IsA, - ::Type: IsA, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); @@ -159,10 +138,7 @@ unsafe extern "C" fn animation_get_size( ptr: *mut ffi::GdkPixbufAnimation, width_ptr: *mut libc::c_int, height_ptr: *mut libc::c_int, -) where - ::Type: IsA, - ::Type: IsA, -{ +) { if width_ptr.is_null() && height_ptr.is_null() { return; } @@ -181,11 +157,7 @@ unsafe extern "C" fn animation_get_size( unsafe extern "C" fn animation_get_static_image( ptr: *mut ffi::GdkPixbufAnimation, -) -> *mut ffi::GdkPixbuf -where - ::Type: IsA, - ::Type: IsA, -{ +) -> *mut ffi::GdkPixbuf { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); @@ -215,11 +187,7 @@ where unsafe extern "C" fn animation_get_iter( ptr: *mut ffi::GdkPixbufAnimation, start_time_ptr: *const glib::ffi::GTimeVal, -) -> *mut ffi::GdkPixbufAnimationIter -where - ::Type: IsA, - ::Type: IsA, -{ +) -> *mut ffi::GdkPixbufAnimationIter { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); diff --git a/gdk-pixbuf/src/subclass/pixbuf_animation_iter.rs b/gdk-pixbuf/src/subclass/pixbuf_animation_iter.rs index d3a104a2e8b8..9660678754f7 100644 --- a/gdk-pixbuf/src/subclass/pixbuf_animation_iter.rs +++ b/gdk-pixbuf/src/subclass/pixbuf_animation_iter.rs @@ -12,10 +12,8 @@ use glib::{prelude::*, subclass::prelude::*, translate::*}; use crate::{ffi, Pixbuf, PixbufAnimationIter}; -pub trait PixbufAnimationIterImpl: ObjectImpl -where - ::Type: IsA, - ::Type: IsA, +pub trait PixbufAnimationIterImpl: + ObjectImpl + ObjectSubclass> { // rustdoc-stripper-ignore-next /// Time in milliseconds, returning `None` implies showing the same pixbuf forever. @@ -36,11 +34,7 @@ where } } -pub trait PixbufAnimationIterImplExt: ObjectSubclass + PixbufAnimationIterImpl -where - ::Type: IsA, - ::Type: IsA, -{ +pub trait PixbufAnimationIterImplExt: PixbufAnimationIterImpl { fn parent_delay_time(&self) -> Option { unsafe { let data = Self::type_data(); @@ -124,18 +118,9 @@ where } } -impl PixbufAnimationIterImplExt for T -where - ::Type: IsA, - ::Type: IsA, -{ -} +impl PixbufAnimationIterImplExt for T {} -unsafe impl IsSubclassable for PixbufAnimationIter -where - ::Type: IsA, - ::Type: IsA, -{ +unsafe impl IsSubclassable for PixbufAnimationIter { fn class_init(class: &mut ::glib::Class) { Self::parent_class_init::(class); @@ -149,11 +134,7 @@ where unsafe extern "C" fn animation_iter_get_delay_time( ptr: *mut ffi::GdkPixbufAnimationIter, -) -> i32 -where - ::Type: IsA, - ::Type: IsA, -{ +) -> i32 { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); @@ -162,11 +143,7 @@ where unsafe extern "C" fn animation_iter_get_pixbuf( ptr: *mut ffi::GdkPixbufAnimationIter, -) -> *mut ffi::GdkPixbuf -where - ::Type: IsA, - ::Type: IsA, -{ +) -> *mut ffi::GdkPixbuf { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); @@ -182,11 +159,7 @@ where unsafe extern "C" fn animation_iter_on_currently_loading_frame( ptr: *mut ffi::GdkPixbufAnimationIter, -) -> glib::ffi::gboolean -where - ::Type: IsA, - ::Type: IsA, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); @@ -196,11 +169,7 @@ where unsafe extern "C" fn animation_iter_advance( ptr: *mut ffi::GdkPixbufAnimationIter, current_time_ptr: *const glib::ffi::GTimeVal, -) -> glib::ffi::gboolean -where - ::Type: IsA, - ::Type: IsA, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); diff --git a/gdk-pixbuf/src/subclass/pixbuf_loader.rs b/gdk-pixbuf/src/subclass/pixbuf_loader.rs index a1b7b0d12175..508b9d5e9ee5 100644 --- a/gdk-pixbuf/src/subclass/pixbuf_loader.rs +++ b/gdk-pixbuf/src/subclass/pixbuf_loader.rs @@ -7,11 +7,7 @@ use glib::{prelude::*, subclass::prelude::*, translate::*}; use crate::{ffi, PixbufLoader}; -pub trait PixbufLoaderImpl: ObjectImpl -where - ::Type: IsA, - ::Type: IsA, -{ +pub trait PixbufLoaderImpl: ObjectImpl + ObjectSubclass> { fn size_prepared(&self, width: i32, height: i32) { self.parent_size_prepared(width, height) } @@ -29,11 +25,7 @@ where } } -pub trait PixbufLoaderImplExt: ObjectSubclass + PixbufLoaderImpl -where - ::Type: IsA, - ::Type: IsA, -{ +pub trait PixbufLoaderImplExt: PixbufLoaderImpl { fn parent_size_prepared(&self, width: i32, height: i32) { unsafe { let data = Self::type_data(); @@ -99,18 +91,9 @@ where } } -impl PixbufLoaderImplExt for T -where - ::Type: IsA, - ::Type: IsA, -{ -} +impl PixbufLoaderImplExt for T {} -unsafe impl IsSubclassable for PixbufLoader -where - ::Type: IsA, - ::Type: IsA, -{ +unsafe impl IsSubclassable for PixbufLoader { fn class_init(class: &mut ::glib::Class) { Self::parent_class_init::(class); @@ -126,21 +109,14 @@ unsafe extern "C" fn loader_size_prepared( ptr: *mut ffi::GdkPixbufLoader, width: i32, height: i32, -) where - ::Type: IsA, - ::Type: IsA, -{ +) { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); imp.size_prepared(width, height) } -unsafe extern "C" fn loader_area_prepared(ptr: *mut ffi::GdkPixbufLoader) -where - ::Type: IsA, - ::Type: IsA, -{ +unsafe extern "C" fn loader_area_prepared(ptr: *mut ffi::GdkPixbufLoader) { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); @@ -153,21 +129,14 @@ unsafe extern "C" fn loader_area_updated( y: i32, width: i32, height: i32, -) where - ::Type: IsA, - ::Type: IsA, -{ +) { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); imp.area_updated(x, y, width, height) } -unsafe extern "C" fn loader_closed(ptr: *mut ffi::GdkPixbufLoader) -where - ::Type: IsA, - ::Type: IsA, -{ +unsafe extern "C" fn loader_closed(ptr: *mut ffi::GdkPixbufLoader) { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); diff --git a/gio/src/subclass/action_group.rs b/gio/src/subclass/action_group.rs index 69fd5168ef65..8620b0c01e4a 100644 --- a/gio/src/subclass/action_group.rs +++ b/gio/src/subclass/action_group.rs @@ -6,11 +6,7 @@ use glib::{prelude::*, subclass::prelude::*, translate::*, GString, Quark, Varia use crate::{ffi, ActionGroup}; -pub trait ActionGroupImpl: ObjectImpl -where - ::Type: IsA, - ::Type: IsA, -{ +pub trait ActionGroupImpl: ObjectImpl + ObjectSubclass> { fn action_added(&self, action_name: &str) { self.parent_action_added(action_name); } @@ -77,11 +73,7 @@ where )>; } -pub trait ActionGroupImplExt: ObjectSubclass + ActionGroupImpl -where - ::Type: IsA, - ::Type: IsA, -{ +pub trait ActionGroupImplExt: ActionGroupImpl { fn parent_action_added(&self, action_name: &str) { unsafe { let type_data = Self::type_data(); @@ -344,18 +336,9 @@ where } } -impl ActionGroupImplExt for T -where - ::Type: IsA, - ::Type: IsA, -{ -} +impl ActionGroupImplExt for T {} -unsafe impl IsImplementable for ActionGroup -where - ::Type: IsA, - ::Type: IsA, -{ +unsafe impl IsImplementable for ActionGroup { fn interface_init(iface: &mut glib::Interface) { let iface = iface.as_mut(); @@ -379,11 +362,7 @@ where unsafe extern "C" fn action_group_has_action( action_group: *mut ffi::GActionGroup, action_nameptr: *const libc::c_char, -) -> glib::ffi::gboolean -where - ::Type: IsA, - ::Type: IsA, -{ +) -> glib::ffi::gboolean { let instance = &*(action_group as *mut T::Instance); let action_name = GString::from_glib_borrow(action_nameptr); let imp = instance.imp(); @@ -394,11 +373,7 @@ where unsafe extern "C" fn action_group_get_action_enabled( action_group: *mut ffi::GActionGroup, action_nameptr: *const libc::c_char, -) -> glib::ffi::gboolean -where - ::Type: IsA, - ::Type: IsA, -{ +) -> glib::ffi::gboolean { let instance = &*(action_group as *mut T::Instance); let imp = instance.imp(); let action_name = GString::from_glib_borrow(action_nameptr); @@ -419,11 +394,7 @@ impl Drop for PtrHolder { unsafe extern "C" fn action_group_get_action_parameter_type( action_group: *mut ffi::GActionGroup, action_nameptr: *const libc::c_char, -) -> *const glib::ffi::GVariantType -where - ::Type: IsA, - ::Type: IsA, -{ +) -> *const glib::ffi::GVariantType { let instance = &*(action_group as *mut T::Instance); let imp = instance.imp(); let action_name = GString::from_glib_borrow(action_nameptr); @@ -452,11 +423,7 @@ where unsafe extern "C" fn action_group_get_action_state_type( action_group: *mut ffi::GActionGroup, action_nameptr: *const libc::c_char, -) -> *const glib::ffi::GVariantType -where - ::Type: IsA, - ::Type: IsA, -{ +) -> *const glib::ffi::GVariantType { let instance = &*(action_group as *mut T::Instance); let imp = instance.imp(); let action_name = GString::from_glib_borrow(action_nameptr); @@ -485,11 +452,7 @@ where unsafe extern "C" fn action_group_get_action_state_hint( action_group: *mut ffi::GActionGroup, action_nameptr: *const libc::c_char, -) -> *mut glib::ffi::GVariant -where - ::Type: IsA, - ::Type: IsA, -{ +) -> *mut glib::ffi::GVariant { let instance = &*(action_group as *mut T::Instance); let imp = instance.imp(); let action_name = GString::from_glib_borrow(action_nameptr); @@ -517,11 +480,7 @@ where unsafe extern "C" fn action_group_get_action_state( action_group: *mut ffi::GActionGroup, action_nameptr: *const libc::c_char, -) -> *mut glib::ffi::GVariant -where - ::Type: IsA, - ::Type: IsA, -{ +) -> *mut glib::ffi::GVariant { let instance = &*(action_group as *mut T::Instance); let imp = instance.imp(); let action_name = GString::from_glib_borrow(action_nameptr); @@ -548,10 +507,7 @@ unsafe extern "C" fn action_group_change_action_state( action_group: *mut ffi::GActionGroup, action_nameptr: *const libc::c_char, stateptr: *mut glib::ffi::GVariant, -) where - ::Type: IsA, - ::Type: IsA, -{ +) { let instance = &*(action_group as *mut T::Instance); let imp = instance.imp(); let action_name = GString::from_glib_borrow(action_nameptr); @@ -564,10 +520,7 @@ unsafe extern "C" fn action_group_activate_action( action_group: *mut ffi::GActionGroup, action_nameptr: *const libc::c_char, parameterptr: *mut glib::ffi::GVariant, -) where - ::Type: IsA, - ::Type: IsA, -{ +) { let instance = &*(action_group as *mut T::Instance); let imp = instance.imp(); let action_name = GString::from_glib_borrow(action_nameptr); @@ -579,10 +532,7 @@ unsafe extern "C" fn action_group_activate_action( unsafe extern "C" fn action_group_action_added( action_group: *mut ffi::GActionGroup, action_nameptr: *const libc::c_char, -) where - ::Type: IsA, - ::Type: IsA, -{ +) { let instance = &*(action_group as *mut T::Instance); let imp = instance.imp(); let action_name = GString::from_glib_borrow(action_nameptr); @@ -593,10 +543,7 @@ unsafe extern "C" fn action_group_action_added( unsafe extern "C" fn action_group_action_removed( action_group: *mut ffi::GActionGroup, action_nameptr: *const libc::c_char, -) where - ::Type: IsA, - ::Type: IsA, -{ +) { let instance = &*(action_group as *mut T::Instance); let imp = instance.imp(); let action_name = GString::from_glib_borrow(action_nameptr); @@ -608,10 +555,7 @@ unsafe extern "C" fn action_group_action_enabled_changed( action_group: *mut ffi::GActionGroup, action_nameptr: *const libc::c_char, enabled: glib::ffi::gboolean, -) where - ::Type: IsA, - ::Type: IsA, -{ +) { let instance = &*(action_group as *mut T::Instance); let imp = instance.imp(); let action_name = GString::from_glib_borrow(action_nameptr); @@ -623,10 +567,7 @@ unsafe extern "C" fn action_group_action_state_changed( action_group: *mut ffi::GActionGroup, action_nameptr: *const libc::c_char, stateptr: *mut glib::ffi::GVariant, -) where - ::Type: IsA, - ::Type: IsA, -{ +) { let instance = &*(action_group as *mut T::Instance); let imp = instance.imp(); let action_name = GString::from_glib_borrow(action_nameptr); @@ -637,11 +578,7 @@ unsafe extern "C" fn action_group_action_state_changed( unsafe extern "C" fn action_group_list_actions( action_group: *mut ffi::GActionGroup, -) -> *mut *mut libc::c_char -where - ::Type: IsA, - ::Type: IsA, -{ +) -> *mut *mut libc::c_char { let instance = &*(action_group as *mut T::Instance); let imp = instance.imp(); @@ -667,11 +604,7 @@ unsafe extern "C" fn action_group_query_action( state_type: *mut *const glib::ffi::GVariantType, state_hint: *mut *mut glib::ffi::GVariant, state: *mut *mut glib::ffi::GVariant, -) -> glib::ffi::gboolean -where - ::Type: IsA, - ::Type: IsA, -{ +) -> glib::ffi::gboolean { let instance = &*(action_group as *mut T::Instance); let imp = instance.imp(); let action_name = GString::from_glib_borrow(action_nameptr); diff --git a/gio/src/subclass/action_map.rs b/gio/src/subclass/action_map.rs index 6a30d68ec107..6088a1c805c8 100644 --- a/gio/src/subclass/action_map.rs +++ b/gio/src/subclass/action_map.rs @@ -6,21 +6,13 @@ use glib::{prelude::*, subclass::prelude::*, translate::*, GString, Quark}; use crate::{ffi, Action, ActionMap}; -pub trait ActionMapImpl: ObjectImpl -where - ::Type: IsA, - ::Type: IsA, -{ +pub trait ActionMapImpl: ObjectImpl + ObjectSubclass> { fn lookup_action(&self, action_name: &str) -> Option; fn add_action(&self, action: &Action); fn remove_action(&self, action_name: &str); } -pub trait ActionMapImplExt: ObjectSubclass + ActionMapImpl -where - ::Type: IsA, - ::Type: IsA, -{ +pub trait ActionMapImplExt: ActionMapImpl { fn parent_lookup_action(&self, name: &str) -> Option { unsafe { let type_data = Self::type_data(); @@ -71,18 +63,9 @@ where } } -impl ActionMapImplExt for T -where - ::Type: IsA, - ::Type: IsA, -{ -} +impl ActionMapImplExt for T {} -unsafe impl IsImplementable for ActionMap -where - ::Type: IsA, - ::Type: IsA, -{ +unsafe impl IsImplementable for ActionMap { fn interface_init(iface: &mut glib::Interface) { let iface = iface.as_mut(); @@ -95,11 +78,7 @@ where unsafe extern "C" fn action_map_lookup_action( action_map: *mut ffi::GActionMap, action_nameptr: *const libc::c_char, -) -> *mut ffi::GAction -where - ::Type: IsA, - ::Type: IsA, -{ +) -> *mut ffi::GAction { let instance = &*(action_map as *mut T::Instance); let action_name = GString::from_glib_borrow(action_nameptr); let imp = instance.imp(); @@ -129,10 +108,7 @@ where unsafe extern "C" fn action_map_add_action( action_map: *mut ffi::GActionMap, actionptr: *mut ffi::GAction, -) where - ::Type: IsA, - ::Type: IsA, -{ +) { let instance = &*(action_map as *mut T::Instance); let imp = instance.imp(); let action: Borrowed = from_glib_borrow(actionptr); @@ -143,10 +119,7 @@ unsafe extern "C" fn action_map_add_action( unsafe extern "C" fn action_map_remove_action( action_map: *mut ffi::GActionMap, action_nameptr: *const libc::c_char, -) where - ::Type: IsA, - ::Type: IsA, -{ +) { let instance = &*(action_map as *mut T::Instance); let imp = instance.imp(); let action_name = GString::from_glib_borrow(action_nameptr); diff --git a/gio/src/subclass/application.rs b/gio/src/subclass/application.rs index bee49e117bed..12800875764c 100644 --- a/gio/src/subclass/application.rs +++ b/gio/src/subclass/application.rs @@ -64,11 +64,7 @@ impl From for Vec { } } -pub trait ApplicationImpl: ObjectImpl -where - ::Type: IsA, - ::Type: IsA, -{ +pub trait ApplicationImpl: ObjectImpl + ObjectSubclass> { fn activate(&self) { self.parent_activate() } @@ -114,11 +110,7 @@ where } } -pub trait ApplicationImplExt: ObjectSubclass + ApplicationImpl -where - ::Type: IsA, - ::Type: IsA, -{ +pub trait ApplicationImplExt: ApplicationImpl { fn parent_activate(&self) { unsafe { let data = Self::type_data(); @@ -274,18 +266,9 @@ where } } -impl ApplicationImplExt for T -where - ::Type: IsA, - ::Type: IsA, -{ -} +impl ApplicationImplExt for T {} -unsafe impl IsSubclassable for Application -where - ::Type: IsA, - ::Type: IsA, -{ +unsafe impl IsSubclassable for Application { fn class_init(class: &mut ::glib::Class) { Self::parent_class_init::(class); @@ -304,11 +287,7 @@ where } } -unsafe extern "C" fn application_activate(ptr: *mut ffi::GApplication) -where - ::Type: IsA, - ::Type: IsA, -{ +unsafe extern "C" fn application_activate(ptr: *mut ffi::GApplication) { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); @@ -318,10 +297,7 @@ where unsafe extern "C" fn application_after_emit( ptr: *mut ffi::GApplication, platform_data: *mut glib::ffi::GVariant, -) where - ::Type: IsA, - ::Type: IsA, -{ +) { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); @@ -330,10 +306,7 @@ unsafe extern "C" fn application_after_emit( unsafe extern "C" fn application_before_emit( ptr: *mut ffi::GApplication, platform_data: *mut glib::ffi::GVariant, -) where - ::Type: IsA, - ::Type: IsA, -{ +) { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); @@ -342,11 +315,7 @@ unsafe extern "C" fn application_before_emit( unsafe extern "C" fn application_command_line( ptr: *mut ffi::GApplication, command_line: *mut ffi::GApplicationCommandLine, -) -> i32 -where - ::Type: IsA, - ::Type: IsA, -{ +) -> i32 { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); @@ -356,11 +325,7 @@ unsafe extern "C" fn application_local_command_line( ptr: *mut ffi::GApplication, arguments: *mut *mut *mut c_char, exit_status: *mut i32, -) -> glib::ffi::gboolean -where - ::Type: IsA, - ::Type: IsA, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); @@ -381,51 +346,32 @@ unsafe extern "C" fn application_open( files: *mut *mut ffi::GFile, num_files: i32, hint: *const c_char, -) where - ::Type: IsA, - ::Type: IsA, -{ +) { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); let files: Vec = FromGlibContainer::from_glib_none_num(files, num_files as usize); imp.open(files.as_slice(), &glib::GString::from_glib_borrow(hint)) } -unsafe extern "C" fn application_quit_mainloop(ptr: *mut ffi::GApplication) -where - ::Type: IsA, - ::Type: IsA, -{ +unsafe extern "C" fn application_quit_mainloop(ptr: *mut ffi::GApplication) { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); imp.quit_mainloop() } -unsafe extern "C" fn application_run_mainloop(ptr: *mut ffi::GApplication) -where - ::Type: IsA, - ::Type: IsA, -{ +unsafe extern "C" fn application_run_mainloop(ptr: *mut ffi::GApplication) { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); imp.run_mainloop() } -unsafe extern "C" fn application_shutdown(ptr: *mut ffi::GApplication) -where - ::Type: IsA, - ::Type: IsA, -{ +unsafe extern "C" fn application_shutdown(ptr: *mut ffi::GApplication) { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); imp.shutdown() } -unsafe extern "C" fn application_startup(ptr: *mut ffi::GApplication) -where - ::Type: IsA, - ::Type: IsA, -{ +unsafe extern "C" fn application_startup(ptr: *mut ffi::GApplication) { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); @@ -435,11 +381,7 @@ where unsafe extern "C" fn application_handle_local_options( ptr: *mut ffi::GApplication, options: *mut glib::ffi::GVariantDict, -) -> c_int -where - ::Type: IsA, - ::Type: IsA, -{ +) -> c_int { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); diff --git a/gio/src/subclass/async_initable.rs b/gio/src/subclass/async_initable.rs index 07e36151f943..d6f2a5ca9294 100644 --- a/gio/src/subclass/async_initable.rs +++ b/gio/src/subclass/async_initable.rs @@ -8,11 +8,7 @@ use crate::{ ffi, AsyncInitable, AsyncResult, Cancellable, CancellableFuture, GioFutureResult, LocalTask, }; -pub trait AsyncInitableImpl: ObjectImpl -where - ::Type: IsA, - ::Type: IsA, -{ +pub trait AsyncInitableImpl: ObjectImpl + ObjectSubclass> { fn init_future( &self, io_priority: glib::Priority, @@ -21,11 +17,7 @@ where } } -pub trait AsyncInitableImplExt: ObjectSubclass + AsyncInitableImpl -where - ::Type: IsA, - ::Type: IsA, -{ +pub trait AsyncInitableImplExt: AsyncInitableImpl { fn parent_init_future( &self, io_priority: glib::Priority, @@ -39,15 +31,13 @@ where .init_async .expect("no parent \"init_async\" implementation"); - unsafe extern "C" fn parent_init_future_callback( + unsafe extern "C" fn parent_init_future_callback< + T: ObjectSubclass>, + >( source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, - ) where - T: AsyncInitableImpl, - ::Type: IsA, - ::Type: IsA, - { + ) { let type_data = T::type_data(); let parent_iface = type_data.as_ref().parent_interface::() as *const ffi::GAsyncInitableIface; @@ -88,18 +78,9 @@ where } } -impl AsyncInitableImplExt for T -where - ::Type: IsA, - ::Type: IsA, -{ -} +impl AsyncInitableImplExt for T {} -unsafe impl IsImplementable for AsyncInitable -where - ::Type: IsA, - ::Type: IsA, -{ +unsafe impl IsImplementable for AsyncInitable { fn interface_init(iface: &mut glib::Interface) { let iface = iface.as_mut(); iface.init_async = Some(async_initable_init_async::); @@ -113,10 +94,7 @@ unsafe extern "C" fn async_initable_init_async( cancellable: *mut ffi::GCancellable, callback: ffi::GAsyncReadyCallback, user_data: glib::ffi::gpointer, -) where - ::Type: IsA, - ::Type: IsA, -{ +) { let instance = &*(initable as *mut T::Instance); let imp = instance.imp(); let cancellable = Option::::from_glib_none(cancellable); diff --git a/gio/src/subclass/initable.rs b/gio/src/subclass/initable.rs index 4c83a6a89667..f9a643653cd0 100644 --- a/gio/src/subclass/initable.rs +++ b/gio/src/subclass/initable.rs @@ -6,21 +6,13 @@ use glib::{prelude::*, subclass::prelude::*, translate::*, Error}; use crate::{ffi, Cancellable, Initable}; -pub trait InitableImpl: ObjectImpl -where - ::Type: IsA, - ::Type: IsA, -{ +pub trait InitableImpl: ObjectImpl + ObjectSubclass> { fn init(&self, cancellable: Option<&Cancellable>) -> Result<(), Error> { self.parent_init(cancellable) } } -pub trait InitableImplExt: ObjectSubclass + InitableImpl -where - ::Type: IsA, - ::Type: IsA, -{ +pub trait InitableImplExt: InitableImpl { fn parent_init(&self, cancellable: Option<&Cancellable>) -> Result<(), Error> { unsafe { let type_data = Self::type_data(); @@ -47,18 +39,9 @@ where } } -impl InitableImplExt for T -where - ::Type: IsA, - ::Type: IsA, -{ -} +impl InitableImplExt for T {} -unsafe impl IsImplementable for Initable -where - ::Type: IsA, - ::Type: IsA, -{ +unsafe impl IsImplementable for Initable { fn interface_init(iface: &mut glib::Interface) { let iface = iface.as_mut(); iface.init = Some(initable_init::); @@ -69,11 +52,7 @@ unsafe extern "C" fn initable_init( initable: *mut ffi::GInitable, cancellable: *mut ffi::GCancellable, error: *mut *mut glib::ffi::GError, -) -> glib::ffi::gboolean -where - ::Type: IsA, - ::Type: IsA, -{ +) -> glib::ffi::gboolean { let instance = &*(initable as *mut T::Instance); let imp = instance.imp(); diff --git a/gio/src/subclass/input_stream.rs b/gio/src/subclass/input_stream.rs index 67295120e520..3862a64e5556 100644 --- a/gio/src/subclass/input_stream.rs +++ b/gio/src/subclass/input_stream.rs @@ -6,11 +6,7 @@ use glib::{prelude::*, subclass::prelude::*, translate::*, Error}; use crate::{ffi, Cancellable, InputStream}; -pub trait InputStreamImpl: ObjectImpl + Send -where - ::Type: IsA, - ::Type: IsA, -{ +pub trait InputStreamImpl: Send + ObjectImpl + ObjectSubclass> { fn read(&self, buffer: &mut [u8], cancellable: Option<&Cancellable>) -> Result { self.parent_read(buffer, cancellable) } @@ -24,11 +20,7 @@ where } } -pub trait InputStreamImplExt: ObjectSubclass + InputStreamImpl -where - ::Type: IsA, - ::Type: IsA, -{ +pub trait InputStreamImplExt: InputStreamImpl { fn parent_read( &self, buffer: &mut [u8], @@ -106,18 +98,9 @@ where } } -impl InputStreamImplExt for T -where - ::Type: IsA, - ::Type: IsA, -{ -} +impl InputStreamImplExt for T {} -unsafe impl IsSubclassable for InputStream -where - ::Type: IsA, - ::Type: IsA, -{ +unsafe impl IsSubclassable for InputStream { fn class_init(class: &mut ::glib::Class) { Self::parent_class_init::(class); @@ -134,11 +117,7 @@ unsafe extern "C" fn stream_read( count: usize, cancellable: *mut ffi::GCancellable, err: *mut *mut glib::ffi::GError, -) -> isize -where - ::Type: IsA, - ::Type: IsA, -{ +) -> isize { debug_assert!(count <= isize::MAX as usize); let instance = &*(ptr as *mut T::Instance); @@ -172,11 +151,7 @@ unsafe extern "C" fn stream_close( ptr: *mut ffi::GInputStream, cancellable: *mut ffi::GCancellable, err: *mut *mut glib::ffi::GError, -) -> glib::ffi::gboolean -where - ::Type: IsA, - ::Type: IsA, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); @@ -200,11 +175,7 @@ unsafe extern "C" fn stream_skip( count: usize, cancellable: *mut ffi::GCancellable, err: *mut *mut glib::ffi::GError, -) -> isize -where - ::Type: IsA, - ::Type: IsA, -{ +) -> isize { debug_assert!(count <= isize::MAX as usize); let instance = &*(ptr as *mut T::Instance); diff --git a/gio/src/subclass/io_stream.rs b/gio/src/subclass/io_stream.rs index 193ab49a979e..670d4e48cba1 100644 --- a/gio/src/subclass/io_stream.rs +++ b/gio/src/subclass/io_stream.rs @@ -6,11 +6,7 @@ use glib::{prelude::*, subclass::prelude::*, translate::*, Error}; use crate::{ffi, Cancellable, IOStream, InputStream, OutputStream}; -pub trait IOStreamImpl: ObjectImpl + Send -where - ::Type: IsA, - ::Type: IsA, -{ +pub trait IOStreamImpl: Send + ObjectImpl + ObjectSubclass> { fn input_stream(&self) -> InputStream { self.parent_input_stream() } @@ -24,11 +20,7 @@ where } } -pub trait IOStreamImplExt: ObjectSubclass + IOStreamImpl -where - ::Type: IsA, - ::Type: IsA, -{ +pub trait IOStreamImplExt: IOStreamImpl { fn parent_input_stream(&self) -> InputStream { unsafe { let data = Self::type_data(); @@ -73,18 +65,9 @@ where } } -impl IOStreamImplExt for T -where - ::Type: IsA, - ::Type: IsA, -{ -} +impl IOStreamImplExt for T {} -unsafe impl IsSubclassable for IOStream -where - ::Type: IsA, - ::Type: IsA, -{ +unsafe impl IsSubclassable for IOStream { fn class_init(class: &mut ::glib::Class) { Self::parent_class_init::(class); @@ -97,11 +80,7 @@ where unsafe extern "C" fn stream_get_input_stream( ptr: *mut ffi::GIOStream, -) -> *mut ffi::GInputStream -where - ::Type: IsA, - ::Type: IsA, -{ +) -> *mut ffi::GInputStream { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); @@ -128,11 +107,7 @@ where unsafe extern "C" fn stream_get_output_stream( ptr: *mut ffi::GIOStream, -) -> *mut ffi::GOutputStream -where - ::Type: IsA, - ::Type: IsA, -{ +) -> *mut ffi::GOutputStream { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); @@ -161,11 +136,7 @@ unsafe extern "C" fn stream_close( ptr: *mut ffi::GIOStream, cancellable: *mut ffi::GCancellable, err: *mut *mut glib::ffi::GError, -) -> glib::ffi::gboolean -where - ::Type: IsA, - ::Type: IsA, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); diff --git a/gio/src/subclass/list_model.rs b/gio/src/subclass/list_model.rs index ebe0d4b7f9f5..5e3d7944e675 100644 --- a/gio/src/subclass/list_model.rs +++ b/gio/src/subclass/list_model.rs @@ -6,11 +6,7 @@ use glib::{prelude::*, subclass::prelude::*, translate::*}; use crate::{ffi, ListModel}; -pub trait ListModelImpl: ObjectImpl -where - ::Type: IsA, - ::Type: IsA, -{ +pub trait ListModelImpl: ObjectImpl + ObjectSubclass> { #[doc(alias = "get_item_type")] fn item_type(&self) -> glib::Type; #[doc(alias = "get_n_items")] @@ -19,11 +15,7 @@ where fn item(&self, position: u32) -> Option; } -pub trait ListModelImplExt: ObjectSubclass + ListModelImpl -where - ::Type: IsA, - ::Type: IsA, -{ +pub trait ListModelImplExt: ListModelImpl { fn parent_item_type(&self) -> glib::Type { unsafe { let type_data = Self::type_data(); @@ -69,18 +61,9 @@ where } } -impl ListModelImplExt for T -where - ::Type: IsA, - ::Type: IsA, -{ -} +impl ListModelImplExt for T {} -unsafe impl IsImplementable for ListModel -where - ::Type: IsA, - ::Type: IsA, -{ +unsafe impl IsImplementable for ListModel { fn interface_init(iface: &mut glib::Interface) { let iface = iface.as_mut(); @@ -92,11 +75,7 @@ where unsafe extern "C" fn list_model_get_item_type( list_model: *mut ffi::GListModel, -) -> glib::ffi::GType -where - ::Type: IsA, - ::Type: IsA, -{ +) -> glib::ffi::GType { let instance = &*(list_model as *mut T::Instance); let imp = instance.imp(); @@ -125,11 +104,7 @@ where unsafe extern "C" fn list_model_get_n_items( list_model: *mut ffi::GListModel, -) -> u32 -where - ::Type: IsA, - ::Type: IsA, -{ +) -> u32 { let instance = &*(list_model as *mut T::Instance); let imp = instance.imp(); @@ -139,11 +114,7 @@ where unsafe extern "C" fn list_model_get_item( list_model: *mut ffi::GListModel, position: u32, -) -> *mut glib::gobject_ffi::GObject -where - ::Type: IsA, - ::Type: IsA, -{ +) -> *mut glib::gobject_ffi::GObject { let instance = &*(list_model as *mut T::Instance); let imp = instance.imp(); diff --git a/gio/src/subclass/output_stream.rs b/gio/src/subclass/output_stream.rs index 11e1de18b707..bfcfa51381a7 100644 --- a/gio/src/subclass/output_stream.rs +++ b/gio/src/subclass/output_stream.rs @@ -6,11 +6,7 @@ use glib::{prelude::*, subclass::prelude::*, translate::*, Error}; use crate::{ffi, Cancellable, InputStream, OutputStream, OutputStreamSpliceFlags}; -pub trait OutputStreamImpl: ObjectImpl + Send -where - ::Type: IsA, - ::Type: IsA, -{ +pub trait OutputStreamImpl: Send + ObjectImpl + ObjectSubclass> { fn write(&self, buffer: &[u8], cancellable: Option<&Cancellable>) -> Result { self.parent_write(buffer, cancellable) } @@ -33,11 +29,7 @@ where } } -pub trait OutputStreamImplExt: ObjectSubclass + OutputStreamImpl -where - ::Type: IsA, - ::Type: IsA, -{ +pub trait OutputStreamImplExt: OutputStreamImpl { fn parent_write( &self, buffer: &[u8], @@ -153,18 +145,9 @@ where } } -impl OutputStreamImplExt for T -where - ::Type: IsA, - ::Type: IsA, -{ -} +impl OutputStreamImplExt for T {} -unsafe impl IsSubclassable for OutputStream -where - ::Type: IsA, - ::Type: IsA, -{ +unsafe impl IsSubclassable for OutputStream { fn class_init(class: &mut ::glib::Class) { Self::parent_class_init::(class); @@ -182,11 +165,7 @@ unsafe extern "C" fn stream_write( count: usize, cancellable: *mut ffi::GCancellable, err: *mut *mut glib::ffi::GError, -) -> isize -where - ::Type: IsA, - ::Type: IsA, -{ +) -> isize { debug_assert!(count <= isize::MAX as usize); let instance = &*(ptr as *mut T::Instance); @@ -220,11 +199,7 @@ unsafe extern "C" fn stream_close( ptr: *mut ffi::GOutputStream, cancellable: *mut ffi::GCancellable, err: *mut *mut glib::ffi::GError, -) -> glib::ffi::gboolean -where - ::Type: IsA, - ::Type: IsA, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); @@ -247,11 +222,7 @@ unsafe extern "C" fn stream_flush( ptr: *mut ffi::GOutputStream, cancellable: *mut ffi::GCancellable, err: *mut *mut glib::ffi::GError, -) -> glib::ffi::gboolean -where - ::Type: IsA, - ::Type: IsA, -{ +) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); @@ -276,11 +247,7 @@ unsafe extern "C" fn stream_splice( flags: ffi::GOutputStreamSpliceFlags, cancellable: *mut ffi::GCancellable, err: *mut *mut glib::ffi::GError, -) -> isize -where - ::Type: IsA, - ::Type: IsA, -{ +) -> isize { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); diff --git a/gio/src/subclass/seekable.rs b/gio/src/subclass/seekable.rs index d713e20302c0..fd38737ea32b 100644 --- a/gio/src/subclass/seekable.rs +++ b/gio/src/subclass/seekable.rs @@ -6,11 +6,7 @@ use glib::{prelude::*, subclass::prelude::*, translate::*, Error, SeekType}; use crate::{ffi, Cancellable, Seekable}; -pub trait SeekableImpl: ObjectImpl + Send -where - ::Type: IsA, - ::Type: IsA, -{ +pub trait SeekableImpl: Send + ObjectImpl + ObjectSubclass> { fn tell(&self) -> i64; fn can_seek(&self) -> bool; fn seek( @@ -23,11 +19,7 @@ where fn truncate(&self, offset: i64, cancellable: Option<&Cancellable>) -> Result<(), Error>; } -pub trait SeekableImplExt: ObjectSubclass + SeekableImpl -where - ::Type: IsA, - ::Type: IsA, -{ +pub trait SeekableImplExt: SeekableImpl { fn parent_tell(&self) -> i64 { unsafe { let type_data = Self::type_data(); @@ -128,18 +120,9 @@ where } } -impl SeekableImplExt for T -where - ::Type: IsA, - ::Type: IsA, -{ -} +impl SeekableImplExt for T {} -unsafe impl IsImplementable for Seekable -where - ::Type: IsA, - ::Type: IsA, -{ +unsafe impl IsImplementable for Seekable { fn interface_init(iface: &mut glib::Interface) { let iface = iface.as_mut(); @@ -151,11 +134,7 @@ where } } -unsafe extern "C" fn seekable_tell(seekable: *mut ffi::GSeekable) -> i64 -where - ::Type: IsA, - ::Type: IsA, -{ +unsafe extern "C" fn seekable_tell(seekable: *mut ffi::GSeekable) -> i64 { let instance = &*(seekable as *mut T::Instance); let imp = instance.imp(); @@ -164,11 +143,7 @@ where unsafe extern "C" fn seekable_can_seek( seekable: *mut ffi::GSeekable, -) -> glib::ffi::gboolean -where - ::Type: IsA, - ::Type: IsA, -{ +) -> glib::ffi::gboolean { let instance = &*(seekable as *mut T::Instance); let imp = instance.imp(); @@ -181,11 +156,7 @@ unsafe extern "C" fn seekable_seek( type_: glib::ffi::GSeekType, cancellable: *mut ffi::GCancellable, err: *mut *mut glib::ffi::GError, -) -> glib::ffi::gboolean -where - ::Type: IsA, - ::Type: IsA, -{ +) -> glib::ffi::gboolean { let instance = &*(seekable as *mut T::Instance); let imp = instance.imp(); @@ -208,11 +179,7 @@ where unsafe extern "C" fn seekable_can_truncate( seekable: *mut ffi::GSeekable, -) -> glib::ffi::gboolean -where - ::Type: IsA, - ::Type: IsA, -{ +) -> glib::ffi::gboolean { let instance = &*(seekable as *mut T::Instance); let imp = instance.imp(); @@ -224,11 +191,7 @@ unsafe extern "C" fn seekable_truncate( offset: i64, cancellable: *mut ffi::GCancellable, err: *mut *mut glib::ffi::GError, -) -> glib::ffi::gboolean -where - ::Type: IsA, - ::Type: IsA, -{ +) -> glib::ffi::gboolean { let instance = &*(seekable as *mut T::Instance); let imp = instance.imp(); diff --git a/gio/src/subclass/socket_control_message.rs b/gio/src/subclass/socket_control_message.rs index 230604e08a47..e81a857e5b26 100644 --- a/gio/src/subclass/socket_control_message.rs +++ b/gio/src/subclass/socket_control_message.rs @@ -4,10 +4,8 @@ use glib::{prelude::*, subclass::prelude::*, translate::*}; use crate::{ffi, SocketControlMessage}; -pub trait SocketControlMessageImpl: ObjectImpl -where - ::Type: IsA, - ::Type: IsA, +pub trait SocketControlMessageImpl: + ObjectImpl + ObjectSubclass> { fn level(&self) -> i32 { self.parent_level() @@ -30,11 +28,7 @@ where } } -pub trait SocketControlMessageImplExt: ObjectSubclass + SocketControlMessageImpl -where - ::Type: IsA, - ::Type: IsA, -{ +pub trait SocketControlMessageImplExt: SocketControlMessageImpl { fn parent_level(&self) -> i32 { unsafe { let data = Self::type_data(); @@ -116,18 +110,9 @@ where } } -impl SocketControlMessageImplExt for T -where - ::Type: IsA, - ::Type: IsA, -{ -} +impl SocketControlMessageImplExt for T {} -unsafe impl IsSubclassable for SocketControlMessage -where - ::Type: IsA, - ::Type: IsA, -{ +unsafe impl IsSubclassable for SocketControlMessage { fn class_init(class: &mut ::glib::Class) { Self::parent_class_init::(class); @@ -142,11 +127,7 @@ where unsafe extern "C" fn socket_control_message_get_level( ptr: *mut ffi::GSocketControlMessage, -) -> i32 -where - ::Type: IsA, - ::Type: IsA, -{ +) -> i32 { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); @@ -155,11 +136,7 @@ where unsafe extern "C" fn socket_control_message_get_type( ptr: *mut ffi::GSocketControlMessage, -) -> i32 -where - ::Type: IsA, - ::Type: IsA, -{ +) -> i32 { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); @@ -168,11 +145,7 @@ where unsafe extern "C" fn socket_control_message_get_size( ptr: *mut ffi::GSocketControlMessage, -) -> usize -where - ::Type: IsA, - ::Type: IsA, -{ +) -> usize { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); @@ -182,10 +155,7 @@ where unsafe extern "C" fn socket_control_message_serialize( ptr: *mut ffi::GSocketControlMessage, data: glib::ffi::gpointer, -) where - ::Type: IsA, - ::Type: IsA, -{ +) { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); @@ -199,11 +169,7 @@ unsafe extern "C" fn socket_control_message_deserialize *mut ffi::GSocketControlMessage -where - ::Type: IsA, - ::Type: IsA, -{ +) -> *mut ffi::GSocketControlMessage { let data = std::slice::from_raw_parts(data as *mut u8, size); T::deserialize(level, type_, data).into_glib_ptr() diff --git a/glib-macros/tests/object_subclass_dynamic.rs b/glib-macros/tests/object_subclass_dynamic.rs index 2b5a0bae9d8c..c825cef9c838 100644 --- a/glib-macros/tests/object_subclass_dynamic.rs +++ b/glib-macros/tests/object_subclass_dynamic.rs @@ -28,10 +28,8 @@ mod static_ { type Interface = MyStaticInterfaceClass; } - pub trait MyStaticInterfaceImpl: ObjectImpl + ObjectSubclass - where - ::Type: IsA, - ::Type: IsA, + pub trait MyStaticInterfaceImpl: + ObjectImpl + ObjectSubclass> { } @@ -50,10 +48,8 @@ mod static_ { impl MyStaticInterfaceImpl for MyStaticType {} - pub trait MyStaticTypeImpl: ObjectImpl + ObjectSubclass - where - ::Type: IsA, - ::Type: IsA, + pub trait MyStaticTypeImpl: + ObjectImpl + ObjectSubclass> { } } @@ -63,24 +59,14 @@ mod static_ { pub struct MyStaticInterface(ObjectInterface); } - unsafe impl IsImplementable for MyStaticInterface - where - ::Type: IsA, - ::Type: IsA, - { - } + unsafe impl IsImplementable for MyStaticInterface {} // an object subclass to register as a static type and that implements `MyStaticInterface`. glib::wrapper! { pub struct MyStaticType(ObjectSubclass) @implements MyStaticInterface; } - unsafe impl IsSubclassable for MyStaticType - where - ::Type: IsA, - ::Type: IsA, - { - } + unsafe impl IsSubclassable for MyStaticType {} } use static_::{ @@ -115,9 +101,8 @@ mod module { type Interface = MyModuleInterfaceClass; } - pub trait MyModuleInterfaceImpl: ObjectImpl + ObjectSubclass - where - ::Type: IsA, + pub trait MyModuleInterfaceImpl: + ObjectImpl + ObjectSubclass> { } @@ -163,10 +148,8 @@ mod module { type Interface = MyModuleInterfaceLazyClass; } - pub trait MyModuleInterfaceLazyImpl: ObjectImpl + ObjectSubclass - where - ::Type: IsA, - ::Type: IsA, + pub trait MyModuleInterfaceLazyImpl: + ObjectImpl + ObjectSubclass> { } @@ -235,12 +218,7 @@ mod module { pub struct MyModuleInterface(ObjectInterface) @requires MyStaticInterface; } - unsafe impl IsImplementable for MyModuleInterface - where - ::Type: IsA, - ::Type: IsA, - { - } + unsafe impl IsImplementable for MyModuleInterface {} // an object subclass to register as a dynamic type and that extends `MyStaticType` and that implements `MyStaticInterface` and `MyModuleInterface`. glib::wrapper! { @@ -252,12 +230,7 @@ mod module { pub struct MyModuleInterfaceLazy(ObjectInterface) @requires MyStaticInterface; } - unsafe impl IsImplementable for MyModuleInterfaceLazy - where - ::Type: IsA, - ::Type: IsA, - { - } + unsafe impl IsImplementable for MyModuleInterfaceLazy {} // an object subclass to lazy register as a dynamic type and that extends `MyStaticType` that implements `MyStaticInterface` and `MyModuleInterfaceLazy`. glib::wrapper! { @@ -374,10 +347,8 @@ pub mod plugin { type Interface = MyPluginInterfaceClass; } - pub trait MyPluginInterfaceImpl: ObjectImpl + ObjectSubclass - where - ::Type: IsA, - ::Type: IsA, + pub trait MyPluginInterfaceImpl: + ObjectImpl + ObjectSubclass> { } @@ -423,10 +394,8 @@ pub mod plugin { type Interface = MyPluginInterfaceLazyClass; } - pub trait MyPluginInterfaceLazyImpl: ObjectImpl + ObjectSubclass - where - ::Type: IsA, - ::Type: IsA, + pub trait MyPluginInterfaceLazyImpl: + ObjectImpl + ObjectSubclass> { } @@ -449,10 +418,7 @@ pub mod plugin { impl MyStaticInterfaceImpl for MyPluginTypeLazy {} - impl MyPluginInterfaceLazyImpl for MyPluginTypeLazy where - ::Type: IsA - { - } + impl MyPluginInterfaceLazyImpl for MyPluginTypeLazy {} // impl for a type plugin (must implement `glib::TypePlugin`). #[derive(Default)] @@ -601,12 +567,7 @@ pub mod plugin { pub struct MyPluginInterface(ObjectInterface) @requires MyStaticInterface; } - unsafe impl IsImplementable for MyPluginInterface - where - ::Type: IsA, - ::Type: IsA, - { - } + unsafe impl IsImplementable for MyPluginInterface {} // an object subclass to register as a dynamic type and that extends `MyStaticType` and that implements `MyStaticInterface` and `MyPluginInterface`. glib::wrapper! { @@ -618,12 +579,7 @@ pub mod plugin { pub struct MyPluginInterfaceLazy(ObjectInterface) @requires MyStaticInterface; } - unsafe impl IsImplementable for MyPluginInterfaceLazy - where - ::Type: IsA, - ::Type: IsA, - { - } + unsafe impl IsImplementable for MyPluginInterfaceLazy {} // an object subclass to lazy register as a dynamic type and that extends `MyStaticType` that implements `MyStaticInterface` and `MyPluginInterfaceLazy`. glib::wrapper! { diff --git a/glib-macros/tests/properties.rs b/glib-macros/tests/properties.rs index 80d5fb43e913..e4ca1da704bd 100644 --- a/glib-macros/tests/properties.rs +++ b/glib-macros/tests/properties.rs @@ -42,10 +42,7 @@ mod base { pub struct Base(ObjectSubclass); } - unsafe impl IsSubclassable for Base where - ::Type: IsA - { - } + unsafe impl IsSubclassable for Base {} } #[cfg(test)] diff --git a/glib/src/gobject/dynamic_object.rs b/glib/src/gobject/dynamic_object.rs index 36648b5af720..2639f5ef27a2 100644 --- a/glib/src/gobject/dynamic_object.rs +++ b/glib/src/gobject/dynamic_object.rs @@ -41,11 +41,9 @@ pub trait DynamicObjectRegisterExt: AsRef + sealed::Sealed + 'static ) -> crate::types::Type; } -impl + ObjectSubclassIsExt> DynamicObjectRegisterExt for O +impl + IsA + ObjectSubclassIsExt> DynamicObjectRegisterExt for O where O::Subclass: TypePluginRegisterImpl, - ::Type: IsA, - ::Type: IsA, { fn add_dynamic_interface( &self, diff --git a/glib/src/subclass/object.rs b/glib/src/subclass/object.rs index 95f2cbf5f258..312a28b891a0 100644 --- a/glib/src/subclass/object.rs +++ b/glib/src/subclass/object.rs @@ -19,10 +19,7 @@ use crate::{ /// /// This allows overriding the virtual methods of `glib::Object`. Except for /// `finalize` as implementing `Drop` would allow the same behavior. -pub trait ObjectImpl: ObjectSubclass -where - ::Type: IsA, -{ +pub trait ObjectImpl: ObjectSubclass> { // rustdoc-stripper-ignore-next /// Properties installed for this type. fn properties() -> &'static [ParamSpec] { @@ -95,9 +92,7 @@ unsafe extern "C" fn property( id: u32, value: *mut gobject_ffi::GValue, pspec: *mut gobject_ffi::GParamSpec, -) where - ::Type: IsA, -{ +) { let instance = &*(obj as *mut T::Instance); let imp = instance.imp(); @@ -121,9 +116,7 @@ unsafe extern "C" fn set_property( id: u32, value: *mut gobject_ffi::GValue, pspec: *mut gobject_ffi::GParamSpec, -) where - ::Type: IsA, -{ +) { let instance = &*(obj as *mut T::Instance); let imp = instance.imp(); imp.set_property( @@ -133,10 +126,7 @@ unsafe extern "C" fn set_property( ); } -unsafe extern "C" fn constructed(obj: *mut gobject_ffi::GObject) -where - ::Type: IsA, -{ +unsafe extern "C" fn constructed(obj: *mut gobject_ffi::GObject) { let instance = &*(obj as *mut T::Instance); let imp = instance.imp(); @@ -146,9 +136,7 @@ where unsafe extern "C" fn notify( obj: *mut gobject_ffi::GObject, pspec: *mut gobject_ffi::GParamSpec, -) where - ::Type: IsA, -{ +) { let instance = &*(obj as *mut T::Instance); let imp = instance.imp(); imp.notify(&from_glib_borrow(pspec)); @@ -158,18 +146,13 @@ unsafe extern "C" fn dispatch_properties_changed( obj: *mut gobject_ffi::GObject, n_pspecs: u32, pspecs: *mut *mut gobject_ffi::GParamSpec, -) where - ::Type: IsA, -{ +) { let instance = &*(obj as *mut T::Instance); let imp = instance.imp(); imp.dispatch_properties_changed(Slice::from_glib_borrow_num(pspecs, n_pspecs as _)); } -unsafe extern "C" fn dispose(obj: *mut gobject_ffi::GObject) -where - ::Type: IsA, -{ +unsafe extern "C" fn dispose(obj: *mut gobject_ffi::GObject) { let instance = &*(obj as *mut T::Instance); let imp = instance.imp(); @@ -230,10 +213,7 @@ pub unsafe trait ObjectClassSubclassExt: Sized + 'static { unsafe impl ObjectClassSubclassExt for crate::Class {} -unsafe impl IsSubclassable for Object -where - ::Type: IsA, -{ +unsafe impl IsSubclassable for Object { fn class_init(class: &mut crate::Class) { let klass = class.as_mut(); klass.set_property = Some(set_property::); @@ -273,10 +253,7 @@ where fn instance_init(_instance: &mut super::InitializingObject) {} } -pub trait ObjectImplExt: ObjectSubclass + ObjectImpl -where - ::Type: IsA, -{ +pub trait ObjectImplExt: ObjectImpl { // rustdoc-stripper-ignore-next /// Chain up to the parent class' implementation of `glib::Object::constructed()`. #[inline] @@ -339,7 +316,7 @@ where } } -impl ObjectImplExt for T where ::Type: IsA {} +impl ObjectImplExt for T {} #[cfg(test)] mod test { diff --git a/glib/src/subclass/type_module.rs b/glib/src/subclass/type_module.rs index 7382957df4ab..762bc9672024 100644 --- a/glib/src/subclass/type_module.rs +++ b/glib/src/subclass/type_module.rs @@ -2,11 +2,7 @@ use crate::{ffi, gobject_ffi, prelude::*, subclass::prelude::*, translate::*, Object, TypeModule}; -pub trait TypeModuleImpl: ObjectImpl -where - ::Type: IsA, - ::Type: IsA, -{ +pub trait TypeModuleImpl: ObjectImpl + ObjectSubclass + IsA> { // rustdoc-stripper-ignore-next /// Loads the module, registers one or more object subclasses using /// [`register_dynamic_type`] and registers one or more object interfaces @@ -25,20 +21,12 @@ where fn unload(&self); } -pub trait TypeModuleImplExt: ObjectSubclass + TypeModuleImpl -where - ::Type: IsA, - ::Type: IsA, -{ +pub trait TypeModuleImplExt: TypeModuleImpl { fn parent_load(&self) -> bool; fn parent_unload(&self); } -impl TypeModuleImplExt for T -where - ::Type: IsA, - ::Type: IsA, -{ +impl TypeModuleImplExt for T { fn parent_load(&self) -> bool { unsafe { let data = T::type_data(); @@ -70,11 +58,7 @@ where } } -unsafe impl IsSubclassable for TypeModule -where - ::Type: IsA, - ::Type: IsA, -{ +unsafe impl IsSubclassable for TypeModule { fn class_init(class: &mut crate::Class) { Self::parent_class_init::(class); @@ -86,11 +70,7 @@ where unsafe extern "C" fn load( type_module: *mut gobject_ffi::GTypeModule, -) -> ffi::gboolean -where - ::Type: IsA, - ::Type: IsA, -{ +) -> ffi::gboolean { let instance = &*(type_module as *mut T::Instance); let imp = instance.imp(); @@ -110,11 +90,7 @@ where res.into_glib() } -unsafe extern "C" fn unload(type_module: *mut gobject_ffi::GTypeModule) -where - ::Type: IsA, - ::Type: IsA, -{ +unsafe extern "C" fn unload(type_module: *mut gobject_ffi::GTypeModule) { let instance = &*(type_module as *mut T::Instance); let imp = instance.imp(); diff --git a/glib/src/subclass/type_plugin.rs b/glib/src/subclass/type_plugin.rs index 04fd1bb4035d..78e2c2e6b544 100644 --- a/glib/src/subclass/type_plugin.rs +++ b/glib/src/subclass/type_plugin.rs @@ -6,11 +6,7 @@ use crate::{ Object, Type, TypeFlags, TypeInfo, TypePlugin, TypeValueTable, }; -pub trait TypePluginImpl: ObjectImpl -where - ::Type: IsA, - ::Type: IsA, -{ +pub trait TypePluginImpl: ObjectImpl + ObjectSubclass + IsA> { fn use_plugin(&self) { self.parent_use_plugin(); } @@ -28,11 +24,7 @@ where } } -pub trait TypePluginImplExt: ObjectSubclass + TypePluginImpl -where - ::Type: IsA, - ::Type: IsA, -{ +pub trait TypePluginImplExt: TypePluginImpl { fn parent_use_plugin(&self); fn parent_unuse_plugin(&self); fn parent_complete_type_info(&self, type_: Type) -> (TypeInfo, TypeValueTable); @@ -43,11 +35,7 @@ where ) -> InterfaceInfo; } -impl TypePluginImplExt for T -where - ::Type: IsA, - ::Type: IsA, -{ +impl TypePluginImplExt for T { fn parent_use_plugin(&self) { unsafe { let type_data = Self::type_data(); @@ -125,11 +113,7 @@ where } } -unsafe impl IsImplementable for TypePlugin -where - ::Type: IsA, - ::Type: IsA, -{ +unsafe impl IsImplementable for TypePlugin { fn interface_init(iface: &mut Interface) { let iface = iface.as_mut(); @@ -140,22 +124,14 @@ where } } -unsafe extern "C" fn use_plugin(type_plugin: *mut gobject_ffi::GTypePlugin) -where - ::Type: IsA, - ::Type: IsA, -{ +unsafe extern "C" fn use_plugin(type_plugin: *mut gobject_ffi::GTypePlugin) { let instance = &*(type_plugin as *mut T::Instance); let imp = instance.imp(); imp.use_plugin(); } -unsafe extern "C" fn unuse_plugin(type_plugin: *mut gobject_ffi::GTypePlugin) -where - ::Type: IsA, - ::Type: IsA, -{ +unsafe extern "C" fn unuse_plugin(type_plugin: *mut gobject_ffi::GTypePlugin) { let instance = &*(type_plugin as *mut T::Instance); let imp = instance.imp(); @@ -167,10 +143,7 @@ unsafe extern "C" fn complete_type_info( gtype: ffi::GType, info_ptr: *mut gobject_ffi::GTypeInfo, value_table_ptr: *mut gobject_ffi::GTypeValueTable, -) where - ::Type: IsA, - ::Type: IsA, -{ +) { assert!(!info_ptr.is_null()); assert!(!value_table_ptr.is_null()); let instance = &*(type_plugin as *mut T::Instance); @@ -190,10 +163,7 @@ unsafe extern "C" fn complete_interface_info( instance_gtype: ffi::GType, interface_gtype: ffi::GType, info_ptr: *mut gobject_ffi::GInterfaceInfo, -) where - ::Type: IsA, - ::Type: IsA, -{ +) { assert!(!info_ptr.is_null()); let instance = &*(type_plugin as *mut T::Instance); let imp = instance.imp(); @@ -205,10 +175,8 @@ unsafe extern "C" fn complete_interface_info( *info = info_; } -pub trait TypePluginRegisterImpl: ObjectImpl + TypePluginImpl -where - ::Type: IsA, - ::Type: IsA, +pub trait TypePluginRegisterImpl: + TypePluginImpl + ObjectSubclass + IsA> { fn add_dynamic_interface( &self, diff --git a/glib/tests/subclass_compiletest/04-auto-send-sync-with-send-sync-parent.rs b/glib/tests/subclass_compiletest/04-auto-send-sync-with-send-sync-parent.rs index 22e63f5e4298..f253f1d06983 100644 --- a/glib/tests/subclass_compiletest/04-auto-send-sync-with-send-sync-parent.rs +++ b/glib/tests/subclass_compiletest/04-auto-send-sync-with-send-sync-parent.rs @@ -19,16 +19,15 @@ glib::wrapper! { pub struct TestParent(ObjectSubclass); } -pub trait TestParentImpl: glib::subclass::prelude::ObjectImpl + Send + Sync -where - ::Type: glib::prelude::IsA, +pub trait TestParentImpl: + Send + + Sync + + glib::subclass::prelude::ObjectImpl + + glib::subclass::prelude::ObjectSubclass> { } -unsafe impl glib::subclass::prelude::IsSubclassable for TestParent where - ::Type: glib::prelude::IsA -{ -} +unsafe impl glib::subclass::prelude::IsSubclassable for TestParent {} impl Default for TestParent { fn default() -> Self { diff --git a/glib/tests/subclass_compiletest/05-no-auto-send-sync-with-non-send-sync-parent.rs b/glib/tests/subclass_compiletest/05-no-auto-send-sync-with-non-send-sync-parent.rs index 72114287d8cb..c85a822ef229 100644 --- a/glib/tests/subclass_compiletest/05-no-auto-send-sync-with-non-send-sync-parent.rs +++ b/glib/tests/subclass_compiletest/05-no-auto-send-sync-with-non-send-sync-parent.rs @@ -20,16 +20,13 @@ glib::wrapper! { pub struct TestParent(ObjectSubclass); } -pub trait TestParentImpl: glib::subclass::prelude::ObjectImpl -where - ::Type: glib::prelude::IsA, +pub trait TestParentImpl: + glib::subclass::prelude::ObjectImpl + + glib::subclass::prelude::ObjectSubclass> { } -unsafe impl glib::subclass::prelude::IsSubclassable for TestParent where - ::Type: glib::prelude::IsA -{ -} +unsafe impl glib::subclass::prelude::IsSubclassable for TestParent {} impl Default for TestParent { fn default() -> Self { diff --git a/glib/tests/subclass_compiletest/05-no-auto-send-sync-with-non-send-sync-parent.stderr b/glib/tests/subclass_compiletest/05-no-auto-send-sync-with-non-send-sync-parent.stderr index b51e1bfed782..25d8f3d9a3b8 100644 --- a/glib/tests/subclass_compiletest/05-no-auto-send-sync-with-non-send-sync-parent.stderr +++ b/glib/tests/subclass_compiletest/05-no-auto-send-sync-with-non-send-sync-parent.stderr @@ -1,7 +1,7 @@ error[E0277]: `RefCell` cannot be shared between threads safely - --> tests/subclass_compiletest/05-no-auto-send-sync-with-non-send-sync-parent.rs:73:11 + --> tests/subclass_compiletest/05-no-auto-send-sync-with-non-send-sync-parent.rs:70:11 | -73 | check(&obj); +70 | check(&obj); | ----- ^^^^ `RefCell` cannot be shared between threads safely | | | required by a bound introduced by this call @@ -21,12 +21,12 @@ note: required because it appears within the type `TestParent` | ^^^^^^^^^^ = note: required for `TypedObjectRef` to implement `Send` note: required because it appears within the type `TestObject` - --> tests/subclass_compiletest/05-no-auto-send-sync-with-non-send-sync-parent.rs:60:16 + --> tests/subclass_compiletest/05-no-auto-send-sync-with-non-send-sync-parent.rs:57:16 | -60 | pub struct TestObject(ObjectSubclass) @extends TestParent; +57 | pub struct TestObject(ObjectSubclass) @extends TestParent; | ^^^^^^^^^^ note: required by a bound in `main::check` - --> tests/subclass_compiletest/05-no-auto-send-sync-with-non-send-sync-parent.rs:70:17 + --> tests/subclass_compiletest/05-no-auto-send-sync-with-non-send-sync-parent.rs:67:17 | -70 | fn check(_obj: &T) {} +67 | fn check(_obj: &T) {} | ^^^^ required by this bound in `check` diff --git a/glib/tests/subclass_compiletest/06-no-auto-send-sync-with-non-send-sync-ffi-parent.rs b/glib/tests/subclass_compiletest/06-no-auto-send-sync-with-non-send-sync-ffi-parent.rs index 566b8c834907..7d811c272376 100644 --- a/glib/tests/subclass_compiletest/06-no-auto-send-sync-with-non-send-sync-ffi-parent.rs +++ b/glib/tests/subclass_compiletest/06-no-auto-send-sync-with-non-send-sync-ffi-parent.rs @@ -7,14 +7,14 @@ glib::wrapper! { } } -pub trait InitiallyUnownedImpl: glib::subclass::prelude::ObjectImpl -where - ::Type: glib::prelude::IsA, +pub trait InitiallyUnownedImpl: + glib::subclass::prelude::ObjectImpl + + glib::subclass::prelude::ObjectSubclass> { } -unsafe impl glib::subclass::prelude::IsSubclassable for InitiallyUnowned where - ::Type: glib::prelude::IsA +unsafe impl glib::subclass::prelude::IsSubclassable + for InitiallyUnowned { }