@@ -343,7 +343,7 @@ pub trait Cast: ObjectType {
343
343
// same representation except for the name and the phantom data
344
344
// type. IsA<> is an unsafe trait that must only be implemented
345
345
// if this is a valid wrapper type
346
- mem :: transmute ( self )
346
+ & * ( self as * const Self as * const T )
347
347
}
348
348
}
349
349
@@ -532,7 +532,7 @@ macro_rules! glib_object_wrapper {
532
532
#[ doc( hidden) ]
533
533
impl $crate:: translate:: FromGlibPtrNone <* mut $ffi_name> for $name {
534
534
#[ inline]
535
- #[ cfg_attr ( feature = "cargo-clippy" , allow( cast_ptr_alignment) ) ]
535
+ #[ allow( clippy :: cast_ptr_alignment) ]
536
536
unsafe fn from_glib_none( ptr: * mut $ffi_name) -> Self {
537
537
debug_assert!( $crate:: types:: instance_of:: <Self >( ptr as * const _) ) ;
538
538
$name( $crate:: translate:: from_glib_none( ptr as * mut _) , :: std:: marker:: PhantomData )
@@ -542,7 +542,7 @@ macro_rules! glib_object_wrapper {
542
542
#[ doc( hidden) ]
543
543
impl $crate:: translate:: FromGlibPtrNone <* const $ffi_name> for $name {
544
544
#[ inline]
545
- #[ cfg_attr ( feature = "cargo-clippy" , allow( cast_ptr_alignment) ) ]
545
+ #[ allow( clippy :: cast_ptr_alignment) ]
546
546
unsafe fn from_glib_none( ptr: * const $ffi_name) -> Self {
547
547
debug_assert!( $crate:: types:: instance_of:: <Self >( ptr as * const _) ) ;
548
548
$name( $crate:: translate:: from_glib_none( ptr as * mut _) , :: std:: marker:: PhantomData )
@@ -552,7 +552,7 @@ macro_rules! glib_object_wrapper {
552
552
#[ doc( hidden) ]
553
553
impl $crate:: translate:: FromGlibPtrFull <* mut $ffi_name> for $name {
554
554
#[ inline]
555
- #[ cfg_attr ( feature = "cargo-clippy" , allow( cast_ptr_alignment) ) ]
555
+ #[ allow( clippy :: cast_ptr_alignment) ]
556
556
unsafe fn from_glib_full( ptr: * mut $ffi_name) -> Self {
557
557
debug_assert!( $crate:: types:: instance_of:: <Self >( ptr as * const _) ) ;
558
558
$name( $crate:: translate:: from_glib_full( ptr as * mut _) , :: std:: marker:: PhantomData )
@@ -562,7 +562,7 @@ macro_rules! glib_object_wrapper {
562
562
#[ doc( hidden) ]
563
563
impl $crate:: translate:: FromGlibPtrBorrow <* mut $ffi_name> for $name {
564
564
#[ inline]
565
- #[ cfg_attr ( feature = "cargo-clippy" , allow( cast_ptr_alignment) ) ]
565
+ #[ allow( clippy :: cast_ptr_alignment) ]
566
566
unsafe fn from_glib_borrow( ptr: * mut $ffi_name) -> Self {
567
567
debug_assert!( $crate:: types:: instance_of:: <Self >( ptr as * const _) ) ;
568
568
$name( $crate:: translate:: from_glib_borrow( ptr as * mut _) ,
@@ -573,7 +573,7 @@ macro_rules! glib_object_wrapper {
573
573
#[ doc( hidden) ]
574
574
impl $crate:: translate:: FromGlibPtrBorrow <* const $ffi_name> for $name {
575
575
#[ inline]
576
- #[ cfg_attr ( feature = "cargo-clippy" , allow( cast_ptr_alignment) ) ]
576
+ #[ allow( clippy :: cast_ptr_alignment) ]
577
577
unsafe fn from_glib_borrow( ptr: * const $ffi_name) -> Self {
578
578
$crate:: translate:: from_glib_borrow( ptr as * mut $ffi_name)
579
579
}
@@ -704,15 +704,15 @@ macro_rules! glib_object_wrapper {
704
704
705
705
#[ doc( hidden) ]
706
706
impl $crate:: value:: SetValue for $name {
707
- #[ cfg_attr ( feature = "cargo-clippy" , allow( cast_ptr_alignment) ) ]
707
+ #[ allow( clippy :: cast_ptr_alignment) ]
708
708
unsafe fn set_value( value: & mut $crate:: Value , this: & Self ) {
709
709
$crate:: gobject_ffi:: g_value_set_object( $crate:: translate:: ToGlibPtrMut :: to_glib_none_mut( value) . 0 , $crate:: translate:: ToGlibPtr :: <* mut $ffi_name>:: to_glib_none( this) . 0 as * mut $crate:: gobject_ffi:: GObject )
710
710
}
711
711
}
712
712
713
713
#[ doc( hidden) ]
714
714
impl $crate:: value:: SetValueOptional for $name {
715
- #[ cfg_attr ( feature = "cargo-clippy" , allow( cast_ptr_alignment) ) ]
715
+ #[ allow( clippy :: cast_ptr_alignment) ]
716
716
unsafe fn set_value_optional( value: & mut $crate:: Value , this: Option <& Self >) {
717
717
$crate:: gobject_ffi:: g_value_set_object( $crate:: translate:: ToGlibPtrMut :: to_glib_none_mut( value) . 0 , $crate:: translate:: ToGlibPtr :: <* mut $ffi_name>:: to_glib_none( & this) . 0 as * mut $crate:: gobject_ffi:: GObject )
718
718
}
@@ -1063,11 +1063,9 @@ impl<T: ObjectType> ObjectExt for T {
1063
1063
}
1064
1064
1065
1065
unsafe fn connect_notify_unsafe < F : Fn ( & Self , & :: ParamSpec ) > ( & self , name : Option < & str > , f : F ) -> SignalHandlerId {
1066
- use std:: mem:: transmute;
1067
-
1068
1066
unsafe extern "C" fn notify_trampoline < P , F : Fn ( & P , & :: ParamSpec ) > ( this : * mut gobject_ffi:: GObject , param_spec : * mut gobject_ffi:: GParamSpec , f : glib_ffi:: gpointer )
1069
1067
where P : ObjectType {
1070
- let f: & F = transmute ( f ) ;
1068
+ let f: & F = & * ( f as * const F ) ;
1071
1069
f ( & Object :: from_glib_borrow ( this) . unsafe_cast ( ) , & from_glib_borrow ( param_spec) )
1072
1070
}
1073
1071
@@ -1223,9 +1221,9 @@ impl<T: ObjectType> ObjectExt for T {
1223
1221
return Err ( glib_bool_error ! ( "Incompatible number of arguments" ) ) ;
1224
1222
}
1225
1223
1226
- for i in 0 .. ( details . n_params as usize ) {
1224
+ for ( i , item ) in args . iter ( ) . enumerate ( ) {
1227
1225
let arg_type = * ( details. param_types . add ( i) ) & ( !gobject_ffi:: G_TYPE_FLAG_RESERVED_ID_BIT ) ;
1228
- if arg_type != args [ i ] . to_value_type ( ) . to_glib ( ) {
1226
+ if arg_type != item . to_value_type ( ) . to_glib ( ) {
1229
1227
return Err ( glib_bool_error ! ( "Incompatible argument types" ) ) ;
1230
1228
}
1231
1229
}
@@ -1243,7 +1241,7 @@ impl<T: ObjectType> ObjectExt for T {
1243
1241
for ( i, arg) in args. iter ( ) . enumerate ( ) {
1244
1242
s_args[ i+1 ] = arg. to_value ( ) ;
1245
1243
}
1246
- & s_args[ 0 ..args. len ( ) + 1 ]
1244
+ & s_args[ 0 ..= args. len ( ) ]
1247
1245
} else {
1248
1246
v_args = Vec :: with_capacity ( args. len ( ) + 1 ) ;
1249
1247
v_args. push ( self_v) ;
@@ -1437,7 +1435,7 @@ impl<T: ObjectType> ops::Deref for SendWeakRef<T> {
1437
1435
// Deriving this gives the wrong trait bounds
1438
1436
impl < T : ObjectType > Clone for SendWeakRef < T > {
1439
1437
fn clone ( & self ) -> Self {
1440
- SendWeakRef ( self . 0 . clone ( ) , self . 1 . clone ( ) )
1438
+ SendWeakRef ( self . 0 . clone ( ) , self . 1 )
1441
1439
}
1442
1440
}
1443
1441
@@ -1510,7 +1508,7 @@ impl<'a> BindingBuilder<'a> {
1510
1508
1511
1509
pub fn flags ( self , flags : :: BindingFlags ) -> Self {
1512
1510
Self {
1513
- flags : flags ,
1511
+ flags,
1514
1512
..self
1515
1513
}
1516
1514
}
0 commit comments