Skip to content

Commit

Permalink
Require delegates to be Send (#1458)
Browse files Browse the repository at this point in the history
  • Loading branch information
kennykerr committed Jan 25, 2022
1 parent 2542ec7 commit afe3252
Show file tree
Hide file tree
Showing 51 changed files with 509 additions and 519 deletions.
102 changes: 51 additions & 51 deletions .github/workflows/test.yml
Expand Up @@ -67,59 +67,59 @@ jobs:

- name: Test stable (${{ matrix.os }})
run: |
cargo test --target ${{ matrix.other }} -p test_agile
cargo test --target ${{ matrix.other }} -p test_alternate_success_code
cargo test --target ${{ matrix.other }} -p test_arch
cargo test --target ${{ matrix.other }} -p test_arch_feature
cargo test --target ${{ matrix.other }} -p test_bstr
cargo test --target ${{ matrix.other }} -p test_core
cargo test --target ${{ matrix.other }} -p test_debug
cargo test --target ${{ matrix.other }} -p test_deprecated
cargo test --target ${{ matrix.other }} -p test_enums
cargo test --target ${{ matrix.other }} -p test_handles
cargo test --target ${{ matrix.other }} -p test_helpers
cargo test --target ${{ matrix.other }} -p test_implement
cargo test --target ${{ matrix.other }} -p test_interop
cargo test --target ${{ matrix.other }} -p test_lib
cargo test --target ${{ matrix.other }} -p test_matrix3x2
cargo test --target ${{ matrix.other }} -p test_mshtml
cargo test --target ${{ matrix.other }} -p test_ntstatus
cargo test --target ${{ matrix.other }} -p test_pwstr
cargo test --target ${{ matrix.other }} -p test_return_struct
cargo test --target ${{ matrix.other }} -p test_structs
cargo test --target ${{ matrix.other }} -p test_sys
cargo test --target ${{ matrix.other }} -p test_unions
cargo test --target ${{ matrix.other }} -p test_weak
cargo test --target ${{ matrix.other }} -p test_win32
cargo test --target ${{ matrix.other }} -p test_win32_arrays
cargo test --target ${{ matrix.other }} -p test_agile &&
cargo test --target ${{ matrix.other }} -p test_alternate_success_code &&
cargo test --target ${{ matrix.other }} -p test_arch &&
cargo test --target ${{ matrix.other }} -p test_arch_feature &&
cargo test --target ${{ matrix.other }} -p test_bstr &&
cargo test --target ${{ matrix.other }} -p test_core &&
cargo test --target ${{ matrix.other }} -p test_debug &&
cargo test --target ${{ matrix.other }} -p test_deprecated &&
cargo test --target ${{ matrix.other }} -p test_enums &&
cargo test --target ${{ matrix.other }} -p test_handles &&
cargo test --target ${{ matrix.other }} -p test_helpers &&
cargo test --target ${{ matrix.other }} -p test_interop &&
cargo test --target ${{ matrix.other }} -p test_lib &&
cargo test --target ${{ matrix.other }} -p test_matrix3x2 &&
cargo test --target ${{ matrix.other }} -p test_mshtml &&
cargo test --target ${{ matrix.other }} -p test_ntstatus &&
cargo test --target ${{ matrix.other }} -p test_pwstr &&
cargo test --target ${{ matrix.other }} -p test_return_struct &&
cargo test --target ${{ matrix.other }} -p test_structs &&
cargo test --target ${{ matrix.other }} -p test_sys &&
cargo test --target ${{ matrix.other }} -p test_unions &&
cargo test --target ${{ matrix.other }} -p test_weak &&
cargo test --target ${{ matrix.other }} -p test_win32 &&
cargo test --target ${{ matrix.other }} -p test_win32_arrays
if: contains(matrix.rust, 'stable')

- name: Test nightly (${{ matrix.os }})
run: |
cargo test --target ${{ matrix.other }} -p test_implement_class_factory
cargo test --target ${{ matrix.other }} -p test_implement_data_object
cargo test --target ${{ matrix.other }} -p test_implement_identity
cargo test --target ${{ matrix.other }} -p test_implement_map
cargo test --target ${{ matrix.other }} -p test_implement_no_use
cargo test --target ${{ matrix.other }} -p test_implement_null_result
cargo test --target ${{ matrix.other }} -p test_implement_winrt
cargo test --target ${{ matrix.other }} -p com_uri
cargo test --target ${{ matrix.other }} -p core_app
cargo test --target ${{ matrix.other }} -p create_window
cargo test --target ${{ matrix.other }} -p create_window_sys
cargo test --target ${{ matrix.other }} -p direct2d
cargo test --target ${{ matrix.other }} -p direct3d12
cargo test --target ${{ matrix.other }} -p enum_windows
cargo test --target ${{ matrix.other }} -p enum_windows_sys
cargo test --target ${{ matrix.other }} -p kernel_event
cargo test --target ${{ matrix.other }} -p memory_buffer
cargo test --target ${{ matrix.other }} -p message_box
cargo test --target ${{ matrix.other }} -p ocr
cargo test --target ${{ matrix.other }} -p overlapped
cargo test --target ${{ matrix.other }} -p rss
cargo test --target ${{ matrix.other }} -p simple
cargo test --target ${{ matrix.other }} -p spellchecker
cargo test --target ${{ matrix.other }} -p uiautomation
cargo test --target ${{ matrix.other }} -p xaml_app
cargo test --target ${{ matrix.other }} -p xml
cargo test --target ${{ matrix.other }} -p test_implement &&
cargo test --target ${{ matrix.other }} -p test_implement_class_factory &&
cargo test --target ${{ matrix.other }} -p test_implement_data_object &&
cargo test --target ${{ matrix.other }} -p test_implement_identity &&
cargo test --target ${{ matrix.other }} -p test_implement_map &&
cargo test --target ${{ matrix.other }} -p test_implement_no_use &&
cargo test --target ${{ matrix.other }} -p test_implement_null_result &&
cargo test --target ${{ matrix.other }} -p test_implement_winrt &&
cargo test --target ${{ matrix.other }} -p com_uri &&
cargo test --target ${{ matrix.other }} -p core_app &&
cargo test --target ${{ matrix.other }} -p create_window &&
cargo test --target ${{ matrix.other }} -p create_window_sys &&
cargo test --target ${{ matrix.other }} -p direct2d &&
cargo test --target ${{ matrix.other }} -p direct3d12 &&
cargo test --target ${{ matrix.other }} -p enum_windows &&
cargo test --target ${{ matrix.other }} -p enum_windows_sys &&
cargo test --target ${{ matrix.other }} -p kernel_event &&
cargo test --target ${{ matrix.other }} -p memory_buffer &&
cargo test --target ${{ matrix.other }} -p message_box &&
cargo test --target ${{ matrix.other }} -p ocr &&
cargo test --target ${{ matrix.other }} -p overlapped &&
cargo test --target ${{ matrix.other }} -p rss &&
cargo test --target ${{ matrix.other }} -p simple &&
cargo test --target ${{ matrix.other }} -p spellchecker &&
cargo test --target ${{ matrix.other }} -p uiautomation &&
cargo test --target ${{ matrix.other }} -p xaml_app &&
cargo test --target ${{ matrix.other }} -p xml
if: contains(matrix.rust, 'nightly')
2 changes: 1 addition & 1 deletion crates/libs/bindgen/src/delegates.rs
Expand Up @@ -117,5 +117,5 @@ fn gen_win_delegate(def: &TypeDef, gen: &Gen) -> TokenStream {
fn gen_fn_constraint(def: &TypeDef, method: &MethodDef, gen: &Gen) -> TokenStream {
let signature = gen_impl_signature(def, method, gen);

quote! { F: FnMut #signature + 'static }
quote! { F: FnMut #signature + ::core::marker::Send + 'static }
}
Expand Up @@ -1146,7 +1146,7 @@ impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &Back
#[repr(transparent)]
pub struct BackgroundTaskCanceledEventHandler(pub ::windows::core::IUnknown);
impl BackgroundTaskCanceledEventHandler {
pub fn new<F: FnMut(&::core::option::Option<IBackgroundTaskInstance>, BackgroundTaskCancellationReason) -> ::windows::core::Result<()> + 'static>(invoke: F) -> Self {
pub fn new<F: FnMut(&::core::option::Option<IBackgroundTaskInstance>, BackgroundTaskCancellationReason) -> ::windows::core::Result<()> + ::core::marker::Send + 'static>(invoke: F) -> Self {
let com = BackgroundTaskCanceledEventHandlerBox::<F> { vtable: &BackgroundTaskCanceledEventHandlerBox::<F>::VTABLE, count: ::windows::core::RefCount::new(1), invoke };
unsafe { ::core::mem::transmute(::windows::core::alloc::boxed::Box::new(com)) }
}
Expand All @@ -1157,12 +1157,12 @@ impl BackgroundTaskCanceledEventHandler {
}
}
#[repr(C)]
struct BackgroundTaskCanceledEventHandlerBox<F: FnMut(&::core::option::Option<IBackgroundTaskInstance>, BackgroundTaskCancellationReason) -> ::windows::core::Result<()> + 'static> {
struct BackgroundTaskCanceledEventHandlerBox<F: FnMut(&::core::option::Option<IBackgroundTaskInstance>, BackgroundTaskCancellationReason) -> ::windows::core::Result<()> + ::core::marker::Send + 'static> {
vtable: *const BackgroundTaskCanceledEventHandler_Vtbl,
invoke: F,
count: ::windows::core::RefCount,
}
impl<F: FnMut(&::core::option::Option<IBackgroundTaskInstance>, BackgroundTaskCancellationReason) -> ::windows::core::Result<()> + 'static> BackgroundTaskCanceledEventHandlerBox<F> {
impl<F: FnMut(&::core::option::Option<IBackgroundTaskInstance>, BackgroundTaskCancellationReason) -> ::windows::core::Result<()> + ::core::marker::Send + 'static> BackgroundTaskCanceledEventHandlerBox<F> {
const VTABLE: BackgroundTaskCanceledEventHandler_Vtbl = BackgroundTaskCanceledEventHandler_Vtbl { base: ::windows::core::IUnknownVtbl { QueryInterface: Self::QueryInterface, AddRef: Self::AddRef, Release: Self::Release }, Invoke: Self::Invoke };
unsafe extern "system" fn QueryInterface(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
Expand Down Expand Up @@ -1353,7 +1353,7 @@ unsafe impl ::core::marker::Sync for BackgroundTaskCompletedEventArgs {}
#[repr(transparent)]
pub struct BackgroundTaskCompletedEventHandler(pub ::windows::core::IUnknown);
impl BackgroundTaskCompletedEventHandler {
pub fn new<F: FnMut(&::core::option::Option<BackgroundTaskRegistration>, &::core::option::Option<BackgroundTaskCompletedEventArgs>) -> ::windows::core::Result<()> + 'static>(invoke: F) -> Self {
pub fn new<F: FnMut(&::core::option::Option<BackgroundTaskRegistration>, &::core::option::Option<BackgroundTaskCompletedEventArgs>) -> ::windows::core::Result<()> + ::core::marker::Send + 'static>(invoke: F) -> Self {
let com = BackgroundTaskCompletedEventHandlerBox::<F> { vtable: &BackgroundTaskCompletedEventHandlerBox::<F>::VTABLE, count: ::windows::core::RefCount::new(1), invoke };
unsafe { ::core::mem::transmute(::windows::core::alloc::boxed::Box::new(com)) }
}
Expand All @@ -1364,12 +1364,12 @@ impl BackgroundTaskCompletedEventHandler {
}
}
#[repr(C)]
struct BackgroundTaskCompletedEventHandlerBox<F: FnMut(&::core::option::Option<BackgroundTaskRegistration>, &::core::option::Option<BackgroundTaskCompletedEventArgs>) -> ::windows::core::Result<()> + 'static> {
struct BackgroundTaskCompletedEventHandlerBox<F: FnMut(&::core::option::Option<BackgroundTaskRegistration>, &::core::option::Option<BackgroundTaskCompletedEventArgs>) -> ::windows::core::Result<()> + ::core::marker::Send + 'static> {
vtable: *const BackgroundTaskCompletedEventHandler_Vtbl,
invoke: F,
count: ::windows::core::RefCount,
}
impl<F: FnMut(&::core::option::Option<BackgroundTaskRegistration>, &::core::option::Option<BackgroundTaskCompletedEventArgs>) -> ::windows::core::Result<()> + 'static> BackgroundTaskCompletedEventHandlerBox<F> {
impl<F: FnMut(&::core::option::Option<BackgroundTaskRegistration>, &::core::option::Option<BackgroundTaskCompletedEventArgs>) -> ::windows::core::Result<()> + ::core::marker::Send + 'static> BackgroundTaskCompletedEventHandlerBox<F> {
const VTABLE: BackgroundTaskCompletedEventHandler_Vtbl = BackgroundTaskCompletedEventHandler_Vtbl { base: ::windows::core::IUnknownVtbl { QueryInterface: Self::QueryInterface, AddRef: Self::AddRef, Release: Self::Release }, Invoke: Self::Invoke };
unsafe extern "system" fn QueryInterface(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
Expand Down Expand Up @@ -1598,7 +1598,7 @@ unsafe impl ::core::marker::Sync for BackgroundTaskProgressEventArgs {}
#[repr(transparent)]
pub struct BackgroundTaskProgressEventHandler(pub ::windows::core::IUnknown);
impl BackgroundTaskProgressEventHandler {
pub fn new<F: FnMut(&::core::option::Option<BackgroundTaskRegistration>, &::core::option::Option<BackgroundTaskProgressEventArgs>) -> ::windows::core::Result<()> + 'static>(invoke: F) -> Self {
pub fn new<F: FnMut(&::core::option::Option<BackgroundTaskRegistration>, &::core::option::Option<BackgroundTaskProgressEventArgs>) -> ::windows::core::Result<()> + ::core::marker::Send + 'static>(invoke: F) -> Self {
let com = BackgroundTaskProgressEventHandlerBox::<F> { vtable: &BackgroundTaskProgressEventHandlerBox::<F>::VTABLE, count: ::windows::core::RefCount::new(1), invoke };
unsafe { ::core::mem::transmute(::windows::core::alloc::boxed::Box::new(com)) }
}
Expand All @@ -1609,12 +1609,12 @@ impl BackgroundTaskProgressEventHandler {
}
}
#[repr(C)]
struct BackgroundTaskProgressEventHandlerBox<F: FnMut(&::core::option::Option<BackgroundTaskRegistration>, &::core::option::Option<BackgroundTaskProgressEventArgs>) -> ::windows::core::Result<()> + 'static> {
struct BackgroundTaskProgressEventHandlerBox<F: FnMut(&::core::option::Option<BackgroundTaskRegistration>, &::core::option::Option<BackgroundTaskProgressEventArgs>) -> ::windows::core::Result<()> + ::core::marker::Send + 'static> {
vtable: *const BackgroundTaskProgressEventHandler_Vtbl,
invoke: F,
count: ::windows::core::RefCount,
}
impl<F: FnMut(&::core::option::Option<BackgroundTaskRegistration>, &::core::option::Option<BackgroundTaskProgressEventArgs>) -> ::windows::core::Result<()> + 'static> BackgroundTaskProgressEventHandlerBox<F> {
impl<F: FnMut(&::core::option::Option<BackgroundTaskRegistration>, &::core::option::Option<BackgroundTaskProgressEventArgs>) -> ::windows::core::Result<()> + ::core::marker::Send + 'static> BackgroundTaskProgressEventHandlerBox<F> {
const VTABLE: BackgroundTaskProgressEventHandler_Vtbl = BackgroundTaskProgressEventHandler_Vtbl { base: ::windows::core::IUnknownVtbl { QueryInterface: Self::QueryInterface, AddRef: Self::AddRef, Release: Self::Release }, Invoke: Self::Invoke };
unsafe extern "system" fn QueryInterface(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
Expand Down
Expand Up @@ -1871,7 +1871,7 @@ unsafe impl ::core::marker::Sync for DataProviderDeferral {}
#[repr(transparent)]
pub struct DataProviderHandler(pub ::windows::core::IUnknown);
impl DataProviderHandler {
pub fn new<F: FnMut(&::core::option::Option<DataProviderRequest>) -> ::windows::core::Result<()> + 'static>(invoke: F) -> Self {
pub fn new<F: FnMut(&::core::option::Option<DataProviderRequest>) -> ::windows::core::Result<()> + ::core::marker::Send + 'static>(invoke: F) -> Self {
let com = DataProviderHandlerBox::<F> { vtable: &DataProviderHandlerBox::<F>::VTABLE, count: ::windows::core::RefCount::new(1), invoke };
unsafe { ::core::mem::transmute(::windows::core::alloc::boxed::Box::new(com)) }
}
Expand All @@ -1882,12 +1882,12 @@ impl DataProviderHandler {
}
}
#[repr(C)]
struct DataProviderHandlerBox<F: FnMut(&::core::option::Option<DataProviderRequest>) -> ::windows::core::Result<()> + 'static> {
struct DataProviderHandlerBox<F: FnMut(&::core::option::Option<DataProviderRequest>) -> ::windows::core::Result<()> + ::core::marker::Send + 'static> {
vtable: *const DataProviderHandler_Vtbl,
invoke: F,
count: ::windows::core::RefCount,
}
impl<F: FnMut(&::core::option::Option<DataProviderRequest>) -> ::windows::core::Result<()> + 'static> DataProviderHandlerBox<F> {
impl<F: FnMut(&::core::option::Option<DataProviderRequest>) -> ::windows::core::Result<()> + ::core::marker::Send + 'static> DataProviderHandlerBox<F> {
const VTABLE: DataProviderHandler_Vtbl = DataProviderHandler_Vtbl { base: ::windows::core::IUnknownVtbl { QueryInterface: Self::QueryInterface, AddRef: Self::AddRef, Release: Self::Release }, Invoke: Self::Invoke };
unsafe extern "system" fn QueryInterface(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
Expand Down Expand Up @@ -3817,7 +3817,7 @@ unsafe impl ::core::marker::Sync for ShareProvider {}
#[repr(transparent)]
pub struct ShareProviderHandler(pub ::windows::core::IUnknown);
impl ShareProviderHandler {
pub fn new<F: FnMut(&::core::option::Option<ShareProviderOperation>) -> ::windows::core::Result<()> + 'static>(invoke: F) -> Self {
pub fn new<F: FnMut(&::core::option::Option<ShareProviderOperation>) -> ::windows::core::Result<()> + ::core::marker::Send + 'static>(invoke: F) -> Self {
let com = ShareProviderHandlerBox::<F> { vtable: &ShareProviderHandlerBox::<F>::VTABLE, count: ::windows::core::RefCount::new(1), invoke };
unsafe { ::core::mem::transmute(::windows::core::alloc::boxed::Box::new(com)) }
}
Expand All @@ -3828,12 +3828,12 @@ impl ShareProviderHandler {
}
}
#[repr(C)]
struct ShareProviderHandlerBox<F: FnMut(&::core::option::Option<ShareProviderOperation>) -> ::windows::core::Result<()> + 'static> {
struct ShareProviderHandlerBox<F: FnMut(&::core::option::Option<ShareProviderOperation>) -> ::windows::core::Result<()> + ::core::marker::Send + 'static> {
vtable: *const ShareProviderHandler_Vtbl,
invoke: F,
count: ::windows::core::RefCount,
}
impl<F: FnMut(&::core::option::Option<ShareProviderOperation>) -> ::windows::core::Result<()> + 'static> ShareProviderHandlerBox<F> {
impl<F: FnMut(&::core::option::Option<ShareProviderOperation>) -> ::windows::core::Result<()> + ::core::marker::Send + 'static> ShareProviderHandlerBox<F> {
const VTABLE: ShareProviderHandler_Vtbl = ShareProviderHandler_Vtbl { base: ::windows::core::IUnknownVtbl { QueryInterface: Self::QueryInterface, AddRef: Self::AddRef, Release: Self::Release }, Invoke: Self::Invoke };
unsafe extern "system" fn QueryInterface(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
Expand Down

0 comments on commit afe3252

Please sign in to comment.