Skip to content

Commit 739e2fa

Browse files
committed
Add newly required trait bounds from core
1 parent b6d56d7 commit 739e2fa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+2012
-843
lines changed

Cargo.lock

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/virtual_methods/base_button/mod.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ impl<O: IsA<BaseButton>> BaseButtonExt for O {}
6060
/// implement.
6161
///
6262
/// See `derived_button/imp.rs` for how to override virtual methods.
63-
pub trait BaseButtonImpl: ButtonImpl {
63+
pub trait BaseButtonImpl: ButtonImpl
64+
where
65+
<Self as ObjectSubclass>::Type: IsA<glib::Object>,
66+
{
6467
/// Default implementation of a virtual method.
6568
///
6669
/// This always calls into the implementation of the parent class so that if
@@ -85,7 +88,10 @@ pub trait BaseButtonImpl: ButtonImpl {
8588
///
8689
/// These are supposed to be called only from inside implementations of
8790
/// `BaseButton` subclasses.
88-
pub trait BaseButtonImplExt: BaseButtonImpl {
91+
pub trait BaseButtonImplExt: BaseButtonImpl
92+
where
93+
<Self as ObjectSubclass>::Type: IsA<glib::Object>,
94+
{
8995
/// Retrieves the parent class' implementation of the virtual method and
9096
/// calls it.
9197
fn parent_sync_method(&self, extra_text: Option<&str>) {
@@ -107,10 +113,13 @@ pub trait BaseButtonImplExt: BaseButtonImpl {
107113
}
108114
}
109115

110-
impl<T: BaseButtonImpl> BaseButtonImplExt for T {}
116+
impl<T: BaseButtonImpl> BaseButtonImplExt for T where <T as ObjectSubclass>::Type: IsA<glib::Object> {}
111117

112118
/// This allows to implement subclasses of `BaseButton`.
113-
unsafe impl<T: BaseButtonImpl> IsSubclassable<T> for BaseButton {
119+
unsafe impl<T: BaseButtonImpl> IsSubclassable<T> for BaseButton
120+
where
121+
<T as ObjectSubclass>::Type: IsA<glib::Object>,
122+
{
114123
/// Called whenever the class of a `BaseButton` subclass is initialized,
115124
/// i.e. usually right before the first instance of it is created.
116125
fn class_init(class: &mut glib::Class<Self>) {

gdk4/src/subclass/content_provider.rs

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ use glib::{translate::*, Value};
99

1010
use crate::{ffi, prelude::*, subclass::prelude::*, Clipboard, ContentFormats, ContentProvider};
1111

12-
pub trait ContentProviderImpl: ContentProviderImplExt + ObjectImpl {
12+
pub trait ContentProviderImpl: ObjectImpl
13+
where
14+
<Self as ObjectSubclass>::Type: IsA<glib::Object>,
15+
{
1316
fn content_changed(&self) {
1417
self.parent_content_changed()
1518
}
@@ -44,12 +47,10 @@ pub trait ContentProviderImpl: ContentProviderImplExt + ObjectImpl {
4447
}
4548
}
4649

47-
mod sealed {
48-
pub trait Sealed {}
49-
impl<T: super::ContentProviderImplExt> Sealed for T {}
50-
}
51-
52-
pub trait ContentProviderImplExt: sealed::Sealed + ObjectSubclass {
50+
pub trait ContentProviderImplExt: ContentProviderImpl
51+
where
52+
<Self as ObjectSubclass>::Type: IsA<glib::Object>,
53+
{
5354
fn parent_content_changed(&self) {
5455
unsafe {
5556
let data = Self::type_data();
@@ -260,9 +261,15 @@ pub trait ContentProviderImplExt: sealed::Sealed + ObjectSubclass {
260261
}
261262
}
262263

263-
impl<T: ContentProviderImpl> ContentProviderImplExt for T {}
264+
impl<T: ContentProviderImpl> ContentProviderImplExt for T where
265+
<T as ObjectSubclass>::Type: IsA<glib::Object>
266+
{
267+
}
264268

265-
unsafe impl<T: ContentProviderImpl> IsSubclassable<T> for ContentProvider {
269+
unsafe impl<T: ContentProviderImpl> IsSubclassable<T> for ContentProvider
270+
where
271+
<T as ObjectSubclass>::Type: IsA<glib::Object>,
272+
{
266273
fn class_init(class: &mut glib::Class<Self>) {
267274
Self::parent_class_init::<T>(class);
268275

@@ -280,7 +287,9 @@ unsafe impl<T: ContentProviderImpl> IsSubclassable<T> for ContentProvider {
280287

281288
unsafe extern "C" fn content_provider_content_changed<T: ContentProviderImpl>(
282289
ptr: *mut ffi::GdkContentProvider,
283-
) {
290+
) where
291+
<T as ObjectSubclass>::Type: IsA<glib::Object>,
292+
{
284293
let instance = &*(ptr as *mut T::Instance);
285294
let imp = instance.imp();
286295

@@ -290,7 +299,9 @@ unsafe extern "C" fn content_provider_content_changed<T: ContentProviderImpl>(
290299
unsafe extern "C" fn content_provider_attach_clipboard<T: ContentProviderImpl>(
291300
ptr: *mut ffi::GdkContentProvider,
292301
clipboard_ptr: *mut ffi::GdkClipboard,
293-
) {
302+
) where
303+
<T as ObjectSubclass>::Type: IsA<glib::Object>,
304+
{
294305
let instance = &*(ptr as *mut T::Instance);
295306
let imp = instance.imp();
296307
let clipboard = from_glib_borrow(clipboard_ptr);
@@ -301,7 +312,9 @@ unsafe extern "C" fn content_provider_attach_clipboard<T: ContentProviderImpl>(
301312
unsafe extern "C" fn content_provider_detach_clipboard<T: ContentProviderImpl>(
302313
ptr: *mut ffi::GdkContentProvider,
303314
clipboard_ptr: *mut ffi::GdkClipboard,
304-
) {
315+
) where
316+
<T as ObjectSubclass>::Type: IsA<glib::Object>,
317+
{
305318
let instance = &*(ptr as *mut T::Instance);
306319
let imp = instance.imp();
307320
let clipboard = from_glib_borrow(clipboard_ptr);
@@ -311,7 +324,10 @@ unsafe extern "C" fn content_provider_detach_clipboard<T: ContentProviderImpl>(
311324

312325
unsafe extern "C" fn content_provider_formats<T: ContentProviderImpl>(
313326
ptr: *mut ffi::GdkContentProvider,
314-
) -> *mut ffi::GdkContentFormats {
327+
) -> *mut ffi::GdkContentFormats
328+
where
329+
<T as ObjectSubclass>::Type: IsA<glib::Object>,
330+
{
315331
let instance = &*(ptr as *mut T::Instance);
316332
let imp = instance.imp();
317333

@@ -320,7 +336,10 @@ unsafe extern "C" fn content_provider_formats<T: ContentProviderImpl>(
320336

321337
unsafe extern "C" fn content_provider_storable_formats<T: ContentProviderImpl>(
322338
ptr: *mut ffi::GdkContentProvider,
323-
) -> *mut ffi::GdkContentFormats {
339+
) -> *mut ffi::GdkContentFormats
340+
where
341+
<T as ObjectSubclass>::Type: IsA<glib::Object>,
342+
{
324343
let instance = &*(ptr as *mut T::Instance);
325344
let imp = instance.imp();
326345

@@ -335,7 +354,9 @@ unsafe extern "C" fn content_provider_write_mime_type_async<T: ContentProviderIm
335354
cancellable_ptr: *mut gio::ffi::GCancellable,
336355
callback: gio::ffi::GAsyncReadyCallback,
337356
user_data: glib::ffi::gpointer,
338-
) {
357+
) where
358+
<T as ObjectSubclass>::Type: IsA<glib::Object>,
359+
{
339360
let instance = &*(ptr as *mut T::Instance);
340361
let imp = instance.imp();
341362
let wrap: ContentProvider = from_glib_none(ptr);
@@ -394,7 +415,10 @@ unsafe extern "C" fn content_provider_get_value<T: ContentProviderImpl>(
394415
ptr: *mut ffi::GdkContentProvider,
395416
value_ptr: *mut glib::gobject_ffi::GValue,
396417
error_ptr: *mut *mut glib::ffi::GError,
397-
) -> glib::ffi::gboolean {
418+
) -> glib::ffi::gboolean
419+
where
420+
<T as ObjectSubclass>::Type: IsA<glib::Object>,
421+
{
398422
let instance = &*(ptr as *mut T::Instance);
399423
let imp = instance.imp();
400424
let value: Value = from_glib_none(value_ptr);

0 commit comments

Comments
 (0)