Skip to content

Commit 6705c15

Browse files
authored
Fix for nightly unpredictable_function_pointer_comparisons warning (#3633)
1 parent 3d19e00 commit 6705c15

File tree

83 files changed

+482
-463
lines changed

Some content is hidden

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

83 files changed

+482
-463
lines changed

crates/libs/bindgen/src/types/cpp_struct.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,11 @@ impl CppStruct {
146146
}
147147

148148
if !config.sys && !has_explicit_layout && !has_packing {
149-
derive.extend(["Debug", "PartialEq"]);
149+
derive.extend(["Debug"]);
150+
151+
if !self.has_cpp_delegate() {
152+
derive.extend(["PartialEq"]);
153+
}
150154
}
151155

152156
let default = if self.can_derive_default(config) {
@@ -263,6 +267,13 @@ impl CppStruct {
263267
})
264268
}
265269

270+
pub fn has_cpp_delegate(&self) -> bool {
271+
self.def.fields().any(|field| {
272+
let ty = field.ty(Some(self));
273+
ty.has_cpp_delegate()
274+
})
275+
}
276+
266277
pub fn is_copyable(&self) -> bool {
267278
if matches!(
268279
self.def.type_name(),

crates/libs/bindgen/src/types/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,14 @@ impl Type {
376376
}
377377
}
378378

379+
pub fn has_cpp_delegate(&self) -> bool {
380+
match self {
381+
Self::CppDelegate(..) => true,
382+
Self::CppStruct(ty) => ty.has_cpp_delegate(),
383+
_ => false,
384+
}
385+
}
386+
379387
pub fn is_interface(&self) -> bool {
380388
matches!(
381389
self,

crates/libs/windows/src/Windows/Wdk/Devices/HumanInterfaceDevice/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl Default for HID_XFER_PACKET {
3939
}
4040
}
4141
#[repr(C)]
42-
#[derive(Clone, Copy, Debug, PartialEq)]
42+
#[derive(Clone, Copy, Debug)]
4343
pub struct VHF_CONFIG {
4444
pub Size: u32,
4545
pub VhfClientContext: *mut core::ffi::c_void,

crates/libs/windows/src/Windows/Wdk/Foundation/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ pub type DRIVER_DISPATCH = Option<unsafe extern "system" fn(deviceobject: *const
369369
pub type DRIVER_DISPATCH_PAGED = Option<unsafe extern "system" fn(deviceobject: *const DEVICE_OBJECT, irp: *mut IRP) -> super::super::Win32::Foundation::NTSTATUS>;
370370
#[repr(C)]
371371
#[cfg(all(feature = "Wdk_Storage_FileSystem", feature = "Wdk_System_SystemServices", feature = "Win32_Security", feature = "Win32_System_IO", feature = "Win32_System_Kernel", feature = "Win32_System_Power"))]
372-
#[derive(Clone, Copy, Debug, PartialEq)]
372+
#[derive(Clone, Copy, Debug)]
373373
pub struct DRIVER_EXTENSION {
374374
pub DriverObject: *mut DRIVER_OBJECT,
375375
pub AddDevice: DRIVER_ADD_DEVICE,
@@ -389,7 +389,7 @@ pub type DRIVER_INITIALIZE = Option<unsafe extern "system" fn(driverobject: *con
389389
pub type DRIVER_NOTIFICATION_CALLBACK_ROUTINE = Option<unsafe extern "system" fn(notificationstructure: *const core::ffi::c_void, context: *mut core::ffi::c_void) -> super::super::Win32::Foundation::NTSTATUS>;
390390
#[repr(C)]
391391
#[cfg(all(feature = "Wdk_Storage_FileSystem", feature = "Wdk_System_SystemServices", feature = "Win32_Security", feature = "Win32_System_IO", feature = "Win32_System_Kernel", feature = "Win32_System_Power"))]
392-
#[derive(Clone, Copy, Debug, PartialEq)]
392+
#[derive(Clone, Copy, Debug)]
393393
pub struct DRIVER_OBJECT {
394394
pub Type: i16,
395395
pub Size: i16,
@@ -498,7 +498,7 @@ pub type FAST_IO_DETACH_DEVICE = Option<unsafe extern "system" fn(sourcedevice:
498498
pub type FAST_IO_DEVICE_CONTROL = Option<unsafe extern "system" fn(fileobject: *const FILE_OBJECT, wait: bool, inputbuffer: *const core::ffi::c_void, inputbufferlength: u32, outputbuffer: *mut core::ffi::c_void, outputbufferlength: u32, iocontrolcode: u32, iostatus: *mut super::super::Win32::System::IO::IO_STATUS_BLOCK, deviceobject: *const DEVICE_OBJECT) -> bool>;
499499
#[repr(C)]
500500
#[cfg(all(feature = "Wdk_Storage_FileSystem", feature = "Wdk_System_SystemServices", feature = "Win32_Security", feature = "Win32_System_IO", feature = "Win32_System_Kernel", feature = "Win32_System_Power"))]
501-
#[derive(Clone, Copy, Debug, Default, PartialEq)]
501+
#[derive(Clone, Copy, Debug, Default)]
502502
pub struct FAST_IO_DISPATCH {
503503
pub SizeOfFastIoDispatch: u32,
504504
pub FastIoCheckIfPossible: FAST_IO_CHECK_IF_POSSIBLE,
@@ -1910,7 +1910,7 @@ impl Default for VPB {
19101910
}
19111911
#[repr(C)]
19121912
#[cfg(feature = "Win32_System_Kernel")]
1913-
#[derive(Clone, Copy, Debug, PartialEq)]
1913+
#[derive(Clone, Copy, Debug)]
19141914
pub struct WORK_QUEUE_ITEM {
19151915
pub List: super::super::Win32::System::Kernel::LIST_ENTRY,
19161916
pub WorkerRoutine: PWORKER_THREAD_ROUTINE,

crates/libs/windows/src/Windows/Wdk/Graphics/Direct3D/mod.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2738,7 +2738,7 @@ pub const D3DHALSTATE_GET_RENDER: i32 = 4i32;
27382738
pub const D3DHALSTATE_GET_TRANSFORM: i32 = 1i32;
27392739
#[repr(C)]
27402740
#[cfg(all(feature = "Win32_Graphics_Direct3D9", feature = "Win32_Graphics_DirectDraw", feature = "Win32_Graphics_Gdi"))]
2741-
#[derive(Clone, Copy, Debug, PartialEq)]
2741+
#[derive(Clone, Copy, Debug)]
27422742
pub struct D3DHAL_CALLBACKS {
27432743
pub dwSize: u32,
27442744
pub ContextCreate: LPD3DHAL_CONTEXTCREATECB,
@@ -2784,7 +2784,7 @@ impl Default for D3DHAL_CALLBACKS {
27842784
}
27852785
#[repr(C)]
27862786
#[cfg(all(feature = "Win32_Graphics_Direct3D9", feature = "Win32_Graphics_DirectDraw", feature = "Win32_Graphics_Gdi"))]
2787-
#[derive(Clone, Copy, Debug, Default, PartialEq)]
2787+
#[derive(Clone, Copy, Debug, Default)]
27882788
pub struct D3DHAL_CALLBACKS2 {
27892789
pub dwSize: u32,
27902790
pub dwFlags: u32,
@@ -2796,7 +2796,7 @@ pub struct D3DHAL_CALLBACKS2 {
27962796
}
27972797
#[repr(C)]
27982798
#[cfg(all(feature = "Win32_Graphics_Direct3D9", feature = "Win32_Graphics_DirectDraw", feature = "Win32_Graphics_Gdi"))]
2799-
#[derive(Clone, Copy, Debug, PartialEq)]
2799+
#[derive(Clone, Copy, Debug)]
28002800
pub struct D3DHAL_CALLBACKS3 {
28012801
pub dwSize: u32,
28022802
pub dwFlags: u32,
@@ -9028,7 +9028,7 @@ impl Default for D3DKMT_RECLAIMALLOCATIONS2_0 {
90289028
}
90299029
}
90309030
#[repr(C)]
9031-
#[derive(Clone, Copy, Debug, PartialEq)]
9031+
#[derive(Clone, Copy, Debug)]
90329032
pub struct D3DKMT_REGISTERBUDGETCHANGENOTIFICATION {
90339033
pub hDevice: u32,
90349034
pub Callback: PFND3DKMT_BUDGETCHANGENOTIFICATIONCALLBACK,
@@ -9041,7 +9041,7 @@ impl Default for D3DKMT_REGISTERBUDGETCHANGENOTIFICATION {
90419041
}
90429042
}
90439043
#[repr(C)]
9044-
#[derive(Clone, Copy, Debug, PartialEq)]
9044+
#[derive(Clone, Copy, Debug)]
90459045
pub struct D3DKMT_REGISTERTRIMNOTIFICATION {
90469046
pub AdapterLuid: super::super::super::Win32::Foundation::LUID,
90479047
pub hDevice: u32,
@@ -9791,7 +9791,7 @@ impl Default for D3DKMT_UNREGISTERBUDGETCHANGENOTIFICATION {
97919791
}
97929792
}
97939793
#[repr(C)]
9794-
#[derive(Clone, Copy, Debug, PartialEq)]
9794+
#[derive(Clone, Copy, Debug)]
97959795
pub struct D3DKMT_UNREGISTERTRIMNOTIFICATION {
97969796
pub Handle: *mut core::ffi::c_void,
97979797
pub Callback: PFND3DKMT_TRIMNOTIFICATIONCALLBACK,
@@ -10696,7 +10696,7 @@ pub const D3DNTHALDP2_VIDMEMCOMMANDBUF: i32 = 128i32;
1069610696
pub const D3DNTHALDP2_VIDMEMVERTEXBUF: i32 = 64i32;
1069710697
#[repr(C)]
1069810698
#[cfg(feature = "Win32_Graphics_DirectDraw")]
10699-
#[derive(Clone, Copy, Debug, PartialEq)]
10699+
#[derive(Clone, Copy, Debug)]
1070010700
pub struct D3DNTHAL_CALLBACKS {
1070110701
pub dwSize: u32,
1070210702
pub ContextCreate: LPD3DNTHAL_CONTEXTCREATECB,
@@ -10742,7 +10742,7 @@ impl Default for D3DNTHAL_CALLBACKS {
1074210742
}
1074310743
#[repr(C)]
1074410744
#[cfg(feature = "Win32_Graphics_DirectDraw")]
10745-
#[derive(Clone, Copy, Debug, PartialEq)]
10745+
#[derive(Clone, Copy, Debug)]
1074610746
pub struct D3DNTHAL_CALLBACKS2 {
1074710747
pub dwSize: u32,
1074810748
pub dwFlags: u32,
@@ -10760,7 +10760,7 @@ impl Default for D3DNTHAL_CALLBACKS2 {
1076010760
}
1076110761
#[repr(C)]
1076210762
#[cfg(all(feature = "Win32_Graphics_Direct3D9", feature = "Win32_Graphics_DirectDraw"))]
10763-
#[derive(Clone, Copy, Debug, PartialEq)]
10763+
#[derive(Clone, Copy, Debug)]
1076410764
pub struct D3DNTHAL_CALLBACKS3 {
1076510765
pub dwSize: u32,
1076610766
pub dwFlags: u32,
@@ -12972,7 +12972,7 @@ impl Default for DXGK_GPUVERSION {
1297212972
}
1297312973
#[repr(C)]
1297412974
#[cfg(feature = "Win32_System_Power")]
12975-
#[derive(Clone, Copy, Debug, PartialEq)]
12975+
#[derive(Clone, Copy, Debug)]
1297612976
pub struct DXGK_GRAPHICSPOWER_REGISTER_INPUT_V_1_2 {
1297712977
pub Version: u32,
1297812978
pub PrivateHandle: *mut core::ffi::c_void,
@@ -12989,7 +12989,7 @@ impl Default for DXGK_GRAPHICSPOWER_REGISTER_INPUT_V_1_2 {
1298912989
}
1299012990
#[repr(C)]
1299112991
#[cfg(feature = "Win32_System_Power")]
12992-
#[derive(Clone, Copy, Debug, PartialEq)]
12992+
#[derive(Clone, Copy, Debug)]
1299312993
pub struct DXGK_GRAPHICSPOWER_REGISTER_OUTPUT {
1299412994
pub DeviceHandle: *mut core::ffi::c_void,
1299512995
pub InitialGrfxPowerState: super::super::super::Win32::System::Power::DEVICE_POWER_STATE,

crates/libs/windows/src/Windows/Wdk/NetworkManagement/Ndis/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3484,7 +3484,7 @@ pub struct NDIS_WMI_TCP_LARGE_SEND_OFFLOAD_V2_1 {
34843484
pub TcpOptionsSupported: u32,
34853485
}
34863486
#[repr(C)]
3487-
#[derive(Clone, Copy, Debug, PartialEq)]
3487+
#[derive(Clone, Copy, Debug)]
34883488
pub struct NDIS_WORK_ITEM {
34893489
pub Context: *mut core::ffi::c_void,
34903490
pub Routine: NDIS_PROC,

crates/libs/windows/src/Windows/Wdk/Storage/FileSystem/Minifilters/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,7 +1611,7 @@ impl Default for FLT_CALLBACK_DATA_0_0 {
16111611
}
16121612
#[repr(C)]
16131613
#[cfg(all(feature = "Wdk_Foundation", feature = "Wdk_System_SystemServices", feature = "Win32_Security", feature = "Win32_System_IO", feature = "Win32_System_Kernel", feature = "Win32_System_Power"))]
1614-
#[derive(Clone, Copy, Debug, Default, PartialEq)]
1614+
#[derive(Clone, Copy, Debug, Default)]
16151615
pub struct FLT_CALLBACK_DATA_QUEUE {
16161616
pub Csq: super::super::super::System::SystemServices::IO_CSQ,
16171617
pub Flags: FLT_CALLBACK_DATA_QUEUE_FLAGS,
@@ -1629,7 +1629,7 @@ pub struct FLT_CALLBACK_DATA_QUEUE_FLAGS(pub i32);
16291629
pub const FLT_CONTEXT_END: u32 = 65535u32;
16301630
#[repr(C)]
16311631
#[cfg(feature = "Wdk_Foundation")]
1632-
#[derive(Clone, Copy, Debug, PartialEq)]
1632+
#[derive(Clone, Copy, Debug)]
16331633
pub struct FLT_CONTEXT_REGISTRATION {
16341634
pub ContextType: u16,
16351635
pub Flags: u16,
@@ -1717,7 +1717,7 @@ pub struct FLT_NAME_CONTROL {
17171717
}
17181718
#[repr(C)]
17191719
#[cfg(all(feature = "Wdk_Foundation", feature = "Wdk_System_SystemServices", feature = "Win32_Security", feature = "Win32_System_IO", feature = "Win32_System_Kernel", feature = "Win32_System_Power"))]
1720-
#[derive(Clone, Copy, Debug, PartialEq)]
1720+
#[derive(Clone, Copy, Debug)]
17211721
pub struct FLT_OPERATION_REGISTRATION {
17221722
pub MajorFunction: u8,
17231723
pub Flags: u32,
@@ -2598,7 +2598,7 @@ pub const FLT_PUSH_LOCK_ENABLE_AUTO_BOOST: u32 = 1u32;
25982598
pub const FLT_PUSH_LOCK_VALID_FLAGS: u32 = 3u32;
25992599
#[repr(C)]
26002600
#[cfg(all(feature = "Wdk_Foundation", feature = "Wdk_System_SystemServices", feature = "Win32_Security", feature = "Win32_Storage_InstallableFileSystems", feature = "Win32_System_IO", feature = "Win32_System_Kernel", feature = "Win32_System_Power"))]
2601-
#[derive(Clone, Copy, Debug, PartialEq)]
2601+
#[derive(Clone, Copy, Debug)]
26022602
pub struct FLT_REGISTRATION {
26032603
pub Size: u16,
26042604
pub Version: u16,

crates/libs/windows/src/Windows/Wdk/Storage/FileSystem/mod.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4133,23 +4133,23 @@ pub struct BOOT_AREA_INFO_0 {
41334133
pub Offset: i64,
41344134
}
41354135
#[repr(C)]
4136-
#[derive(Clone, Copy, Debug, Default, PartialEq)]
4136+
#[derive(Clone, Copy, Debug, Default)]
41374137
pub struct CACHE_MANAGER_CALLBACKS {
41384138
pub AcquireForLazyWrite: PACQUIRE_FOR_LAZY_WRITE,
41394139
pub ReleaseFromLazyWrite: PRELEASE_FROM_LAZY_WRITE,
41404140
pub AcquireForReadAhead: PACQUIRE_FOR_READ_AHEAD,
41414141
pub ReleaseFromReadAhead: PRELEASE_FROM_READ_AHEAD,
41424142
}
41434143
#[repr(C)]
4144-
#[derive(Clone, Copy, Debug, Default, PartialEq)]
4144+
#[derive(Clone, Copy, Debug, Default)]
41454145
pub struct CACHE_MANAGER_CALLBACKS_EX {
41464146
pub Version: u16,
41474147
pub Size: u16,
41484148
pub Functions: CACHE_MANAGER_CALLBACK_FUNCTIONS,
41494149
}
41504150
pub const CACHE_MANAGER_CALLBACKS_EX_V1: u32 = 1u32;
41514151
#[repr(C)]
4152-
#[derive(Clone, Copy, Debug, Default, PartialEq)]
4152+
#[derive(Clone, Copy, Debug, Default)]
41534153
pub struct CACHE_MANAGER_CALLBACK_FUNCTIONS {
41544154
pub AcquireForLazyWriteEx: PACQUIRE_FOR_LAZY_WRITE_EX,
41554155
pub ReleaseFromLazyWrite: PRELEASE_FROM_LAZY_WRITE,
@@ -4176,7 +4176,7 @@ pub const CC_ACQUIRE_SUPPORTS_ASYNC_LAZYWRITE: u32 = 1u32;
41764176
pub const CC_AGGRESSIVE_UNMAP_BEHIND: u32 = 1u32;
41774177
#[repr(C)]
41784178
#[cfg(feature = "Wdk_Foundation")]
4179-
#[derive(Clone, Copy, Debug, PartialEq)]
4179+
#[derive(Clone, Copy, Debug)]
41804180
pub struct CC_ASYNC_READ_CONTEXT {
41814181
pub CompletionRoutine: PASYNC_READ_COMPLETION_CALLBACK,
41824182
pub Context: *mut core::ffi::c_void,
@@ -4967,7 +4967,7 @@ pub const FILE_LINK_REPLACE_IF_EXISTS: u32 = 1u32;
49674967
pub const FILE_LINK_SUPPRESS_STORAGE_RESERVE_INHERITANCE: u32 = 8u32;
49684968
#[repr(C)]
49694969
#[cfg(all(feature = "Wdk_Foundation", feature = "Wdk_System_SystemServices", feature = "Win32_Security", feature = "Win32_System_IO", feature = "Win32_System_Kernel", feature = "Win32_System_Power"))]
4970-
#[derive(Clone, Copy, Debug, PartialEq)]
4970+
#[derive(Clone, Copy, Debug)]
49714971
pub struct FILE_LOCK {
49724972
pub CompleteLockIrpRoutine: PCOMPLETE_LOCK_IRP_ROUTINE,
49734973
pub UnlockRoutine: PUNLOCK_ROUTINE,
@@ -5755,7 +5755,7 @@ impl Default for FSRTL_PER_FILEOBJECT_CONTEXT {
57555755
}
57565756
#[repr(C)]
57575757
#[cfg(all(feature = "Wdk_Foundation", feature = "Win32_System_Kernel"))]
5758-
#[derive(Clone, Copy, Debug, PartialEq)]
5758+
#[derive(Clone, Copy, Debug)]
57595759
pub struct FSRTL_PER_FILE_CONTEXT {
57605760
pub Links: super::super::super::Win32::System::Kernel::LIST_ENTRY,
57615761
pub OwnerId: *mut core::ffi::c_void,
@@ -5770,7 +5770,7 @@ impl Default for FSRTL_PER_FILE_CONTEXT {
57705770
}
57715771
#[repr(C)]
57725772
#[cfg(all(feature = "Wdk_Foundation", feature = "Win32_System_Kernel"))]
5773-
#[derive(Clone, Copy, Debug, PartialEq)]
5773+
#[derive(Clone, Copy, Debug)]
57745774
pub struct FSRTL_PER_STREAM_CONTEXT {
57755775
pub Links: super::super::super::Win32::System::Kernel::LIST_ENTRY,
57765776
pub OwnerId: *mut core::ffi::c_void,
@@ -5881,7 +5881,7 @@ pub const FS_FILTER_ACQUIRE_FOR_MOD_WRITE: u16 = 65533u16;
58815881
pub const FS_FILTER_ACQUIRE_FOR_SECTION_SYNCHRONIZATION: u16 = 65535u16;
58825882
#[repr(C)]
58835883
#[cfg(all(feature = "Wdk_Foundation", feature = "Wdk_System_SystemServices", feature = "Win32_Security", feature = "Win32_System_IO", feature = "Win32_System_Kernel", feature = "Win32_System_Power"))]
5884-
#[derive(Clone, Copy, Debug, Default, PartialEq)]
5884+
#[derive(Clone, Copy, Debug, Default)]
58855885
pub struct FS_FILTER_CALLBACKS {
58865886
pub SizeOfFsFilterCallbacks: u32,
58875887
pub Reserved: u32,
@@ -7644,7 +7644,7 @@ pub struct RTL_HEAP_MEMORY_LIMIT_INFO {
76447644
pub Data: RTL_HEAP_MEMORY_LIMIT_DATA,
76457645
}
76467646
#[repr(C)]
7647-
#[derive(Clone, Copy, Debug, PartialEq)]
7647+
#[derive(Clone, Copy, Debug)]
76487648
pub struct RTL_HEAP_PARAMETERS {
76497649
pub Length: u32,
76507650
pub SegmentReserve: usize,
@@ -7725,7 +7725,7 @@ impl Default for RTL_SEGMENT_HEAP_PARAMETERS {
77257725
}
77267726
}
77277727
#[repr(C)]
7728-
#[derive(Clone, Copy, Debug, Default, PartialEq)]
7728+
#[derive(Clone, Copy, Debug, Default)]
77297729
pub struct RTL_SEGMENT_HEAP_VA_CALLBACKS {
77307730
pub CallbackContext: super::super::super::Win32::Foundation::HANDLE,
77317731
pub AllocateVirtualMemory: PALLOCATE_VIRTUAL_MEMORY_EX_CALLBACK,

0 commit comments

Comments
 (0)