Skip to content

Commit f69594c

Browse files
authored
Merge pull request #1529 from felinira/wip/implied-supertraits
Use rust 1.79 implied supertraits to simplify trait bounds
2 parents b1c7d4a + bafbe83 commit f69594c

Some content is hidden

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

41 files changed

+221
-881
lines changed

.github/workflows/CI.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- stable
1919
- beta
2020
- nightly
21-
- "1.70.0"
21+
- "1.80.0"
2222
conf:
2323
- { name: "cairo", features: "png,pdf,svg,ps,use_glib,v1_18,freetype,script,xcb,xlib,win32-surface", nightly: "--features 'png,pdf,svg,ps,use_glib,v1_18,freetype,script,xcb,xlib,win32-surface'", test_sys: true }
2424
- { name: "gdk-pixbuf", features: "v2_42", nightly: "--all-features", test_sys: true }
@@ -104,7 +104,7 @@ jobs:
104104
- stable
105105
- beta
106106
- nightly
107-
- "1.70.0"
107+
- "1.80.0"
108108
steps:
109109
- uses: actions/checkout@v4
110110
- uses: actions-rs/toolchain@v1

Cargo.toml

+2-4
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,9 @@ authors = ["The gtk-rs Project Developers"]
3030
version = "0.21.0"
3131
repository = "https://github.com/gtk-rs/gtk-rs-core"
3232
license = "MIT"
33-
exclude = [
34-
"gir-files/*",
35-
]
33+
exclude = ["gir-files/*"]
3634
edition = "2021"
37-
rust-version = "1.70"
35+
rust-version = "1.80"
3836

3937
[workspace.dependencies]
4038
libc = "0.2"

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ information about each crate, please refer to their `README.md` file in their di
88

99
## Minimum supported Rust version
1010

11-
Currently, the minimum supported Rust version is `1.70.0`.
11+
Currently, the minimum supported Rust version is `1.80.0`.
1212

1313
## Documentation
1414

cairo/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Cairo __1.14__ is the lowest supported version for the underlying library.
88

99
## Minimum supported Rust version
1010

11-
Currently, the minimum supported Rust version is `1.70.0`.
11+
Currently, the minimum supported Rust version is `1.80.0`.
1212

1313
## Default-on features
1414

examples/virtual_methods/cat.rs

+2-14
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,7 @@ impl Default for Cat {
9696
///
9797
/// By convention we still create an empty `CatImpl` trait, this allows us to add
9898
/// 'protected' cat methods only available to be called by other Cats later.
99-
pub trait CatImpl: PetImpl
100-
where
101-
<Self as ObjectSubclass>::Type: IsA<glib::Object>,
102-
<Self as ObjectSubclass>::Type: IsA<Pet>,
103-
<Self as ObjectSubclass>::Type: IsA<Cat>,
104-
{
105-
}
99+
pub trait CatImpl: PetImpl + ObjectSubclass<Type: IsA<Cat>> {}
106100

107101
/// To make this class subclassable we need to implement IsSubclassable
108-
unsafe impl<Obj: CatImpl + PetImpl> IsSubclassable<Obj> for Cat
109-
where
110-
<Obj as ObjectSubclass>::Type: IsA<glib::Object>,
111-
<Obj as ObjectSubclass>::Type: IsA<Pet>,
112-
<Obj as ObjectSubclass>::Type: IsA<Cat>,
113-
{
114-
}
102+
unsafe impl<Obj: CatImpl + PetImpl> IsSubclassable<Obj> for Cat {}

examples/virtual_methods/pet.rs

+4-21
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,7 @@ pub trait PetExt: IsA<Pet> {
125125
impl<T: IsA<Pet>> PetExt for T {}
126126

127127
/// The `PetImpl` trait contains overridable virtual function definitions for [`Pet`] objects.
128-
pub trait PetImpl: ObjectImpl
129-
where
130-
<Self as ObjectSubclass>::Type: IsA<glib::Object>,
131-
<Self as ObjectSubclass>::Type: IsA<Pet>,
132-
{
128+
pub trait PetImpl: ObjectImpl + ObjectSubclass<Type: IsA<Pet>> {
133129
/// Default implementation of a virtual method.
134130
///
135131
/// This always calls into the implementation of the parent class so that if
@@ -152,11 +148,7 @@ where
152148
/// The `PetImplExt` trait contains non-overridable methods for subclasses to use.
153149
///
154150
/// These are supposed to be called only from inside implementations of `Pet` subclasses.
155-
pub trait PetImplExt: PetImpl
156-
where
157-
<Self as ObjectSubclass>::Type: IsA<glib::Object>,
158-
<Self as ObjectSubclass>::Type: IsA<Pet>,
159-
{
151+
pub trait PetImplExt: PetImpl {
160152
/// Chains up to the parent implementation of [`PetImpl::pet`]
161153
fn parent_pet(&self) -> bool {
162154
let data = Self::type_data();
@@ -177,19 +169,10 @@ where
177169
}
178170

179171
/// The `PetImplExt` trait is implemented for all subclasses that have [`Pet`] in the class hierarchy
180-
impl<T: PetImpl> PetImplExt for T
181-
where
182-
<Self as ObjectSubclass>::Type: IsA<glib::Object>,
183-
<Self as ObjectSubclass>::Type: IsA<Pet>,
184-
{
185-
}
172+
impl<T: PetImpl> PetImplExt for T {}
186173

187174
/// To make this class subclassable we need to implement IsSubclassable
188-
unsafe impl<Obj: PetImpl> IsSubclassable<Obj> for Pet
189-
where
190-
<Obj as ObjectSubclass>::Type: IsA<glib::Object>,
191-
<Obj as ObjectSubclass>::Type: IsA<Pet>,
192-
{
175+
unsafe impl<Obj: PetImpl> IsSubclassable<Obj> for Pet {
193176
/// Override the virtual method function pointers in subclasses to call directly into the
194177
/// `PetImpl` of the subclass.
195178
///

examples/virtual_methods/purrable.rs

+4-21
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,7 @@ pub trait PurrableExt: IsA<Purrable> {
8282
impl<T: IsA<Purrable>> PurrableExt for T {}
8383

8484
/// The `PurrableImpl` trait contains virtual function definitions for [`Purrable`] objects.
85-
pub trait PurrableImpl: ObjectImpl
86-
where
87-
<Self as ObjectSubclass>::Type: IsA<glib::Object>,
88-
<Self as ObjectSubclass>::Type: IsA<Purrable>,
89-
{
85+
pub trait PurrableImpl: ObjectImpl + ObjectSubclass<Type: IsA<Purrable>> {
9086
/// Return the current purring status.
9187
///
9288
/// The default implementation chains up to the parent implementation,
@@ -100,11 +96,7 @@ where
10096
/// The `PurrableImplExt` trait contains non-overridable methods for subclasses to use.
10197
///
10298
/// These are supposed to be called only from inside implementations of `Pet` subclasses.
103-
pub trait PurrableImplExt: PurrableImpl
104-
where
105-
<Self as ObjectSubclass>::Type: IsA<glib::Object>,
106-
<Self as ObjectSubclass>::Type: IsA<Purrable>,
107-
{
99+
pub trait PurrableImplExt: PurrableImpl {
108100
/// Chains up to the parent implementation of [`PurrableExt::is_purring`]
109101
fn parent_is_purring(&self) -> bool {
110102
let data = Self::type_data();
@@ -117,19 +109,10 @@ where
117109
}
118110

119111
/// The `PurrableImplExt` trait is implemented for all classes that implement [`Purrable`].
120-
impl<T: PurrableImpl> PurrableImplExt for T
121-
where
122-
<Self as ObjectSubclass>::Type: IsA<glib::Object>,
123-
<Self as ObjectSubclass>::Type: IsA<Purrable>,
124-
{
125-
}
112+
impl<T: PurrableImpl> PurrableImplExt for T {}
126113

127114
/// To make this interface implementable we need to implement [`IsImplementable`]
128-
unsafe impl<Obj: PurrableImpl> IsImplementable<Obj> for Purrable
129-
where
130-
<Obj as ObjectSubclass>::Type: IsA<glib::Object>,
131-
<Obj as ObjectSubclass>::Type: IsA<Purrable>,
132-
{
115+
unsafe impl<Obj: PurrableImpl> IsImplementable<Obj> for Purrable {
133116
fn interface_init(iface: &mut glib::Interface<Self>) {
134117
let klass = iface.as_mut();
135118

gdk-pixbuf/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ GDK-PixBuf __2.36.8__ is the lowest supported version for the underlying library
66

77
## Minimum supported Rust version
88

9-
Currently, the minimum supported Rust version is `1.70.0`.
9+
Currently, the minimum supported Rust version is `1.80.0`.
1010

1111
## Documentation
1212

gdk-pixbuf/src/subclass/pixbuf_animation.rs

+8-40
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ use glib::{prelude::*, subclass::prelude::*, translate::*};
1313

1414
use crate::{ffi, Pixbuf, PixbufAnimation, PixbufAnimationIter};
1515

16-
pub trait PixbufAnimationImpl: ObjectImpl
17-
where
18-
<Self as ObjectSubclass>::Type: IsA<glib::Object>,
19-
<Self as ObjectSubclass>::Type: IsA<PixbufAnimation>,
20-
{
16+
pub trait PixbufAnimationImpl: ObjectImpl + ObjectSubclass<Type: IsA<PixbufAnimation>> {
2117
fn is_static_image(&self) -> bool {
2218
self.parent_is_static_image()
2319
}
@@ -35,11 +31,7 @@ where
3531
}
3632
}
3733

38-
pub trait PixbufAnimationImplExt: ObjectSubclass + PixbufAnimationImpl
39-
where
40-
<Self as ObjectSubclass>::Type: IsA<glib::Object>,
41-
<Self as ObjectSubclass>::Type: IsA<PixbufAnimation>,
42-
{
34+
pub trait PixbufAnimationImplExt: PixbufAnimationImpl {
4335
fn parent_is_static_image(&self) -> bool {
4436
unsafe {
4537
let data = Self::type_data();
@@ -119,18 +111,9 @@ where
119111
}
120112
}
121113

122-
impl<T: PixbufAnimationImpl> PixbufAnimationImplExt for T
123-
where
124-
<T as ObjectSubclass>::Type: IsA<glib::Object>,
125-
<T as ObjectSubclass>::Type: IsA<PixbufAnimation>,
126-
{
127-
}
114+
impl<T: PixbufAnimationImpl> PixbufAnimationImplExt for T {}
128115

129-
unsafe impl<T: PixbufAnimationImpl> IsSubclassable<T> for PixbufAnimation
130-
where
131-
<T as ObjectSubclass>::Type: IsA<glib::Object>,
132-
<T as ObjectSubclass>::Type: IsA<PixbufAnimation>,
133-
{
116+
unsafe impl<T: PixbufAnimationImpl> IsSubclassable<T> for PixbufAnimation {
134117
fn class_init(class: &mut ::glib::Class<Self>) {
135118
Self::parent_class_init::<T>(class);
136119

@@ -144,11 +127,7 @@ where
144127

145128
unsafe extern "C" fn animation_is_static_image<T: PixbufAnimationImpl>(
146129
ptr: *mut ffi::GdkPixbufAnimation,
147-
) -> glib::ffi::gboolean
148-
where
149-
<T as ObjectSubclass>::Type: IsA<glib::Object>,
150-
<T as ObjectSubclass>::Type: IsA<PixbufAnimation>,
151-
{
130+
) -> glib::ffi::gboolean {
152131
let instance = &*(ptr as *mut T::Instance);
153132
let imp = instance.imp();
154133

@@ -159,10 +138,7 @@ unsafe extern "C" fn animation_get_size<T: PixbufAnimationImpl>(
159138
ptr: *mut ffi::GdkPixbufAnimation,
160139
width_ptr: *mut libc::c_int,
161140
height_ptr: *mut libc::c_int,
162-
) where
163-
<T as ObjectSubclass>::Type: IsA<glib::Object>,
164-
<T as ObjectSubclass>::Type: IsA<PixbufAnimation>,
165-
{
141+
) {
166142
if width_ptr.is_null() && height_ptr.is_null() {
167143
return;
168144
}
@@ -181,11 +157,7 @@ unsafe extern "C" fn animation_get_size<T: PixbufAnimationImpl>(
181157

182158
unsafe extern "C" fn animation_get_static_image<T: PixbufAnimationImpl>(
183159
ptr: *mut ffi::GdkPixbufAnimation,
184-
) -> *mut ffi::GdkPixbuf
185-
where
186-
<T as ObjectSubclass>::Type: IsA<glib::Object>,
187-
<T as ObjectSubclass>::Type: IsA<PixbufAnimation>,
188-
{
160+
) -> *mut ffi::GdkPixbuf {
189161
let instance = &*(ptr as *mut T::Instance);
190162
let imp = instance.imp();
191163

@@ -215,11 +187,7 @@ where
215187
unsafe extern "C" fn animation_get_iter<T: PixbufAnimationImpl>(
216188
ptr: *mut ffi::GdkPixbufAnimation,
217189
start_time_ptr: *const glib::ffi::GTimeVal,
218-
) -> *mut ffi::GdkPixbufAnimationIter
219-
where
220-
<T as ObjectSubclass>::Type: IsA<glib::Object>,
221-
<T as ObjectSubclass>::Type: IsA<PixbufAnimation>,
222-
{
190+
) -> *mut ffi::GdkPixbufAnimationIter {
223191
let instance = &*(ptr as *mut T::Instance);
224192
let imp = instance.imp();
225193

gdk-pixbuf/src/subclass/pixbuf_animation_iter.rs

+9-40
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ use glib::{prelude::*, subclass::prelude::*, translate::*};
1212

1313
use crate::{ffi, Pixbuf, PixbufAnimationIter};
1414

15-
pub trait PixbufAnimationIterImpl: ObjectImpl
16-
where
17-
<Self as ObjectSubclass>::Type: IsA<glib::Object>,
18-
<Self as ObjectSubclass>::Type: IsA<PixbufAnimationIter>,
15+
pub trait PixbufAnimationIterImpl:
16+
ObjectImpl + ObjectSubclass<Type: IsA<PixbufAnimationIter>>
1917
{
2018
// rustdoc-stripper-ignore-next
2119
/// Time in milliseconds, returning `None` implies showing the same pixbuf forever.
@@ -36,11 +34,7 @@ where
3634
}
3735
}
3836

39-
pub trait PixbufAnimationIterImplExt: ObjectSubclass + PixbufAnimationIterImpl
40-
where
41-
<Self as ObjectSubclass>::Type: IsA<glib::Object>,
42-
<Self as ObjectSubclass>::Type: IsA<PixbufAnimationIter>,
43-
{
37+
pub trait PixbufAnimationIterImplExt: PixbufAnimationIterImpl {
4438
fn parent_delay_time(&self) -> Option<Duration> {
4539
unsafe {
4640
let data = Self::type_data();
@@ -124,18 +118,9 @@ where
124118
}
125119
}
126120

127-
impl<T: PixbufAnimationIterImpl> PixbufAnimationIterImplExt for T
128-
where
129-
<T as ObjectSubclass>::Type: IsA<glib::Object>,
130-
<T as ObjectSubclass>::Type: IsA<PixbufAnimationIter>,
131-
{
132-
}
121+
impl<T: PixbufAnimationIterImpl> PixbufAnimationIterImplExt for T {}
133122

134-
unsafe impl<T: PixbufAnimationIterImpl> IsSubclassable<T> for PixbufAnimationIter
135-
where
136-
<T as ObjectSubclass>::Type: IsA<glib::Object>,
137-
<T as ObjectSubclass>::Type: IsA<PixbufAnimationIter>,
138-
{
123+
unsafe impl<T: PixbufAnimationIterImpl> IsSubclassable<T> for PixbufAnimationIter {
139124
fn class_init(class: &mut ::glib::Class<Self>) {
140125
Self::parent_class_init::<T>(class);
141126

@@ -149,11 +134,7 @@ where
149134

150135
unsafe extern "C" fn animation_iter_get_delay_time<T: PixbufAnimationIterImpl>(
151136
ptr: *mut ffi::GdkPixbufAnimationIter,
152-
) -> i32
153-
where
154-
<T as ObjectSubclass>::Type: IsA<glib::Object>,
155-
<T as ObjectSubclass>::Type: IsA<PixbufAnimationIter>,
156-
{
137+
) -> i32 {
157138
let instance = &*(ptr as *mut T::Instance);
158139
let imp = instance.imp();
159140

@@ -162,11 +143,7 @@ where
162143

163144
unsafe extern "C" fn animation_iter_get_pixbuf<T: PixbufAnimationIterImpl>(
164145
ptr: *mut ffi::GdkPixbufAnimationIter,
165-
) -> *mut ffi::GdkPixbuf
166-
where
167-
<T as ObjectSubclass>::Type: IsA<glib::Object>,
168-
<T as ObjectSubclass>::Type: IsA<PixbufAnimationIter>,
169-
{
146+
) -> *mut ffi::GdkPixbuf {
170147
let instance = &*(ptr as *mut T::Instance);
171148
let imp = instance.imp();
172149

@@ -182,11 +159,7 @@ where
182159

183160
unsafe extern "C" fn animation_iter_on_currently_loading_frame<T: PixbufAnimationIterImpl>(
184161
ptr: *mut ffi::GdkPixbufAnimationIter,
185-
) -> glib::ffi::gboolean
186-
where
187-
<T as ObjectSubclass>::Type: IsA<glib::Object>,
188-
<T as ObjectSubclass>::Type: IsA<PixbufAnimationIter>,
189-
{
162+
) -> glib::ffi::gboolean {
190163
let instance = &*(ptr as *mut T::Instance);
191164
let imp = instance.imp();
192165

@@ -196,11 +169,7 @@ where
196169
unsafe extern "C" fn animation_iter_advance<T: PixbufAnimationIterImpl>(
197170
ptr: *mut ffi::GdkPixbufAnimationIter,
198171
current_time_ptr: *const glib::ffi::GTimeVal,
199-
) -> glib::ffi::gboolean
200-
where
201-
<T as ObjectSubclass>::Type: IsA<glib::Object>,
202-
<T as ObjectSubclass>::Type: IsA<PixbufAnimationIter>,
203-
{
172+
) -> glib::ffi::gboolean {
204173
let instance = &*(ptr as *mut T::Instance);
205174
let imp = instance.imp();
206175

0 commit comments

Comments
 (0)