Skip to content

Commit afe3252

Browse files
authored
Require delegates to be Send (#1458)
1 parent 2542ec7 commit afe3252

File tree

51 files changed

+509
-519
lines changed

Some content is hidden

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

51 files changed

+509
-519
lines changed

.github/workflows/test.yml

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -67,59 +67,59 @@ jobs:
6767

6868
- name: Test stable (${{ matrix.os }})
6969
run: |
70-
cargo test --target ${{ matrix.other }} -p test_agile
71-
cargo test --target ${{ matrix.other }} -p test_alternate_success_code
72-
cargo test --target ${{ matrix.other }} -p test_arch
73-
cargo test --target ${{ matrix.other }} -p test_arch_feature
74-
cargo test --target ${{ matrix.other }} -p test_bstr
75-
cargo test --target ${{ matrix.other }} -p test_core
76-
cargo test --target ${{ matrix.other }} -p test_debug
77-
cargo test --target ${{ matrix.other }} -p test_deprecated
78-
cargo test --target ${{ matrix.other }} -p test_enums
79-
cargo test --target ${{ matrix.other }} -p test_handles
80-
cargo test --target ${{ matrix.other }} -p test_helpers
81-
cargo test --target ${{ matrix.other }} -p test_implement
82-
cargo test --target ${{ matrix.other }} -p test_interop
83-
cargo test --target ${{ matrix.other }} -p test_lib
84-
cargo test --target ${{ matrix.other }} -p test_matrix3x2
85-
cargo test --target ${{ matrix.other }} -p test_mshtml
86-
cargo test --target ${{ matrix.other }} -p test_ntstatus
87-
cargo test --target ${{ matrix.other }} -p test_pwstr
88-
cargo test --target ${{ matrix.other }} -p test_return_struct
89-
cargo test --target ${{ matrix.other }} -p test_structs
90-
cargo test --target ${{ matrix.other }} -p test_sys
91-
cargo test --target ${{ matrix.other }} -p test_unions
92-
cargo test --target ${{ matrix.other }} -p test_weak
93-
cargo test --target ${{ matrix.other }} -p test_win32
94-
cargo test --target ${{ matrix.other }} -p test_win32_arrays
70+
cargo test --target ${{ matrix.other }} -p test_agile &&
71+
cargo test --target ${{ matrix.other }} -p test_alternate_success_code &&
72+
cargo test --target ${{ matrix.other }} -p test_arch &&
73+
cargo test --target ${{ matrix.other }} -p test_arch_feature &&
74+
cargo test --target ${{ matrix.other }} -p test_bstr &&
75+
cargo test --target ${{ matrix.other }} -p test_core &&
76+
cargo test --target ${{ matrix.other }} -p test_debug &&
77+
cargo test --target ${{ matrix.other }} -p test_deprecated &&
78+
cargo test --target ${{ matrix.other }} -p test_enums &&
79+
cargo test --target ${{ matrix.other }} -p test_handles &&
80+
cargo test --target ${{ matrix.other }} -p test_helpers &&
81+
cargo test --target ${{ matrix.other }} -p test_interop &&
82+
cargo test --target ${{ matrix.other }} -p test_lib &&
83+
cargo test --target ${{ matrix.other }} -p test_matrix3x2 &&
84+
cargo test --target ${{ matrix.other }} -p test_mshtml &&
85+
cargo test --target ${{ matrix.other }} -p test_ntstatus &&
86+
cargo test --target ${{ matrix.other }} -p test_pwstr &&
87+
cargo test --target ${{ matrix.other }} -p test_return_struct &&
88+
cargo test --target ${{ matrix.other }} -p test_structs &&
89+
cargo test --target ${{ matrix.other }} -p test_sys &&
90+
cargo test --target ${{ matrix.other }} -p test_unions &&
91+
cargo test --target ${{ matrix.other }} -p test_weak &&
92+
cargo test --target ${{ matrix.other }} -p test_win32 &&
93+
cargo test --target ${{ matrix.other }} -p test_win32_arrays
9594
if: contains(matrix.rust, 'stable')
9695

9796
- name: Test nightly (${{ matrix.os }})
9897
run: |
99-
cargo test --target ${{ matrix.other }} -p test_implement_class_factory
100-
cargo test --target ${{ matrix.other }} -p test_implement_data_object
101-
cargo test --target ${{ matrix.other }} -p test_implement_identity
102-
cargo test --target ${{ matrix.other }} -p test_implement_map
103-
cargo test --target ${{ matrix.other }} -p test_implement_no_use
104-
cargo test --target ${{ matrix.other }} -p test_implement_null_result
105-
cargo test --target ${{ matrix.other }} -p test_implement_winrt
106-
cargo test --target ${{ matrix.other }} -p com_uri
107-
cargo test --target ${{ matrix.other }} -p core_app
108-
cargo test --target ${{ matrix.other }} -p create_window
109-
cargo test --target ${{ matrix.other }} -p create_window_sys
110-
cargo test --target ${{ matrix.other }} -p direct2d
111-
cargo test --target ${{ matrix.other }} -p direct3d12
112-
cargo test --target ${{ matrix.other }} -p enum_windows
113-
cargo test --target ${{ matrix.other }} -p enum_windows_sys
114-
cargo test --target ${{ matrix.other }} -p kernel_event
115-
cargo test --target ${{ matrix.other }} -p memory_buffer
116-
cargo test --target ${{ matrix.other }} -p message_box
117-
cargo test --target ${{ matrix.other }} -p ocr
118-
cargo test --target ${{ matrix.other }} -p overlapped
119-
cargo test --target ${{ matrix.other }} -p rss
120-
cargo test --target ${{ matrix.other }} -p simple
121-
cargo test --target ${{ matrix.other }} -p spellchecker
122-
cargo test --target ${{ matrix.other }} -p uiautomation
123-
cargo test --target ${{ matrix.other }} -p xaml_app
124-
cargo test --target ${{ matrix.other }} -p xml
98+
cargo test --target ${{ matrix.other }} -p test_implement &&
99+
cargo test --target ${{ matrix.other }} -p test_implement_class_factory &&
100+
cargo test --target ${{ matrix.other }} -p test_implement_data_object &&
101+
cargo test --target ${{ matrix.other }} -p test_implement_identity &&
102+
cargo test --target ${{ matrix.other }} -p test_implement_map &&
103+
cargo test --target ${{ matrix.other }} -p test_implement_no_use &&
104+
cargo test --target ${{ matrix.other }} -p test_implement_null_result &&
105+
cargo test --target ${{ matrix.other }} -p test_implement_winrt &&
106+
cargo test --target ${{ matrix.other }} -p com_uri &&
107+
cargo test --target ${{ matrix.other }} -p core_app &&
108+
cargo test --target ${{ matrix.other }} -p create_window &&
109+
cargo test --target ${{ matrix.other }} -p create_window_sys &&
110+
cargo test --target ${{ matrix.other }} -p direct2d &&
111+
cargo test --target ${{ matrix.other }} -p direct3d12 &&
112+
cargo test --target ${{ matrix.other }} -p enum_windows &&
113+
cargo test --target ${{ matrix.other }} -p enum_windows_sys &&
114+
cargo test --target ${{ matrix.other }} -p kernel_event &&
115+
cargo test --target ${{ matrix.other }} -p memory_buffer &&
116+
cargo test --target ${{ matrix.other }} -p message_box &&
117+
cargo test --target ${{ matrix.other }} -p ocr &&
118+
cargo test --target ${{ matrix.other }} -p overlapped &&
119+
cargo test --target ${{ matrix.other }} -p rss &&
120+
cargo test --target ${{ matrix.other }} -p simple &&
121+
cargo test --target ${{ matrix.other }} -p spellchecker &&
122+
cargo test --target ${{ matrix.other }} -p uiautomation &&
123+
cargo test --target ${{ matrix.other }} -p xaml_app &&
124+
cargo test --target ${{ matrix.other }} -p xml
125125
if: contains(matrix.rust, 'nightly')

crates/libs/bindgen/src/delegates.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,5 +117,5 @@ fn gen_win_delegate(def: &TypeDef, gen: &Gen) -> TokenStream {
117117
fn gen_fn_constraint(def: &TypeDef, method: &MethodDef, gen: &Gen) -> TokenStream {
118118
let signature = gen_impl_signature(def, method, gen);
119119

120-
quote! { F: FnMut #signature + 'static }
120+
quote! { F: FnMut #signature + ::core::marker::Send + 'static }
121121
}

crates/libs/windows/src/Windows/ApplicationModel/Background/mod.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,7 @@ impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &Back
11461146
#[repr(transparent)]
11471147
pub struct BackgroundTaskCanceledEventHandler(pub ::windows::core::IUnknown);
11481148
impl BackgroundTaskCanceledEventHandler {
1149-
pub fn new<F: FnMut(&::core::option::Option<IBackgroundTaskInstance>, BackgroundTaskCancellationReason) -> ::windows::core::Result<()> + 'static>(invoke: F) -> Self {
1149+
pub fn new<F: FnMut(&::core::option::Option<IBackgroundTaskInstance>, BackgroundTaskCancellationReason) -> ::windows::core::Result<()> + ::core::marker::Send + 'static>(invoke: F) -> Self {
11501150
let com = BackgroundTaskCanceledEventHandlerBox::<F> { vtable: &BackgroundTaskCanceledEventHandlerBox::<F>::VTABLE, count: ::windows::core::RefCount::new(1), invoke };
11511151
unsafe { ::core::mem::transmute(::windows::core::alloc::boxed::Box::new(com)) }
11521152
}
@@ -1157,12 +1157,12 @@ impl BackgroundTaskCanceledEventHandler {
11571157
}
11581158
}
11591159
#[repr(C)]
1160-
struct BackgroundTaskCanceledEventHandlerBox<F: FnMut(&::core::option::Option<IBackgroundTaskInstance>, BackgroundTaskCancellationReason) -> ::windows::core::Result<()> + 'static> {
1160+
struct BackgroundTaskCanceledEventHandlerBox<F: FnMut(&::core::option::Option<IBackgroundTaskInstance>, BackgroundTaskCancellationReason) -> ::windows::core::Result<()> + ::core::marker::Send + 'static> {
11611161
vtable: *const BackgroundTaskCanceledEventHandler_Vtbl,
11621162
invoke: F,
11631163
count: ::windows::core::RefCount,
11641164
}
1165-
impl<F: FnMut(&::core::option::Option<IBackgroundTaskInstance>, BackgroundTaskCancellationReason) -> ::windows::core::Result<()> + 'static> BackgroundTaskCanceledEventHandlerBox<F> {
1165+
impl<F: FnMut(&::core::option::Option<IBackgroundTaskInstance>, BackgroundTaskCancellationReason) -> ::windows::core::Result<()> + ::core::marker::Send + 'static> BackgroundTaskCanceledEventHandlerBox<F> {
11661166
const VTABLE: BackgroundTaskCanceledEventHandler_Vtbl = BackgroundTaskCanceledEventHandler_Vtbl { base: ::windows::core::IUnknownVtbl { QueryInterface: Self::QueryInterface, AddRef: Self::AddRef, Release: Self::Release }, Invoke: Self::Invoke };
11671167
unsafe extern "system" fn QueryInterface(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT {
11681168
let this = this as *mut ::windows::core::RawPtr as *mut Self;
@@ -1353,7 +1353,7 @@ unsafe impl ::core::marker::Sync for BackgroundTaskCompletedEventArgs {}
13531353
#[repr(transparent)]
13541354
pub struct BackgroundTaskCompletedEventHandler(pub ::windows::core::IUnknown);
13551355
impl BackgroundTaskCompletedEventHandler {
1356-
pub fn new<F: FnMut(&::core::option::Option<BackgroundTaskRegistration>, &::core::option::Option<BackgroundTaskCompletedEventArgs>) -> ::windows::core::Result<()> + 'static>(invoke: F) -> Self {
1356+
pub fn new<F: FnMut(&::core::option::Option<BackgroundTaskRegistration>, &::core::option::Option<BackgroundTaskCompletedEventArgs>) -> ::windows::core::Result<()> + ::core::marker::Send + 'static>(invoke: F) -> Self {
13571357
let com = BackgroundTaskCompletedEventHandlerBox::<F> { vtable: &BackgroundTaskCompletedEventHandlerBox::<F>::VTABLE, count: ::windows::core::RefCount::new(1), invoke };
13581358
unsafe { ::core::mem::transmute(::windows::core::alloc::boxed::Box::new(com)) }
13591359
}
@@ -1364,12 +1364,12 @@ impl BackgroundTaskCompletedEventHandler {
13641364
}
13651365
}
13661366
#[repr(C)]
1367-
struct BackgroundTaskCompletedEventHandlerBox<F: FnMut(&::core::option::Option<BackgroundTaskRegistration>, &::core::option::Option<BackgroundTaskCompletedEventArgs>) -> ::windows::core::Result<()> + 'static> {
1367+
struct BackgroundTaskCompletedEventHandlerBox<F: FnMut(&::core::option::Option<BackgroundTaskRegistration>, &::core::option::Option<BackgroundTaskCompletedEventArgs>) -> ::windows::core::Result<()> + ::core::marker::Send + 'static> {
13681368
vtable: *const BackgroundTaskCompletedEventHandler_Vtbl,
13691369
invoke: F,
13701370
count: ::windows::core::RefCount,
13711371
}
1372-
impl<F: FnMut(&::core::option::Option<BackgroundTaskRegistration>, &::core::option::Option<BackgroundTaskCompletedEventArgs>) -> ::windows::core::Result<()> + 'static> BackgroundTaskCompletedEventHandlerBox<F> {
1372+
impl<F: FnMut(&::core::option::Option<BackgroundTaskRegistration>, &::core::option::Option<BackgroundTaskCompletedEventArgs>) -> ::windows::core::Result<()> + ::core::marker::Send + 'static> BackgroundTaskCompletedEventHandlerBox<F> {
13731373
const VTABLE: BackgroundTaskCompletedEventHandler_Vtbl = BackgroundTaskCompletedEventHandler_Vtbl { base: ::windows::core::IUnknownVtbl { QueryInterface: Self::QueryInterface, AddRef: Self::AddRef, Release: Self::Release }, Invoke: Self::Invoke };
13741374
unsafe extern "system" fn QueryInterface(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT {
13751375
let this = this as *mut ::windows::core::RawPtr as *mut Self;
@@ -1598,7 +1598,7 @@ unsafe impl ::core::marker::Sync for BackgroundTaskProgressEventArgs {}
15981598
#[repr(transparent)]
15991599
pub struct BackgroundTaskProgressEventHandler(pub ::windows::core::IUnknown);
16001600
impl BackgroundTaskProgressEventHandler {
1601-
pub fn new<F: FnMut(&::core::option::Option<BackgroundTaskRegistration>, &::core::option::Option<BackgroundTaskProgressEventArgs>) -> ::windows::core::Result<()> + 'static>(invoke: F) -> Self {
1601+
pub fn new<F: FnMut(&::core::option::Option<BackgroundTaskRegistration>, &::core::option::Option<BackgroundTaskProgressEventArgs>) -> ::windows::core::Result<()> + ::core::marker::Send + 'static>(invoke: F) -> Self {
16021602
let com = BackgroundTaskProgressEventHandlerBox::<F> { vtable: &BackgroundTaskProgressEventHandlerBox::<F>::VTABLE, count: ::windows::core::RefCount::new(1), invoke };
16031603
unsafe { ::core::mem::transmute(::windows::core::alloc::boxed::Box::new(com)) }
16041604
}
@@ -1609,12 +1609,12 @@ impl BackgroundTaskProgressEventHandler {
16091609
}
16101610
}
16111611
#[repr(C)]
1612-
struct BackgroundTaskProgressEventHandlerBox<F: FnMut(&::core::option::Option<BackgroundTaskRegistration>, &::core::option::Option<BackgroundTaskProgressEventArgs>) -> ::windows::core::Result<()> + 'static> {
1612+
struct BackgroundTaskProgressEventHandlerBox<F: FnMut(&::core::option::Option<BackgroundTaskRegistration>, &::core::option::Option<BackgroundTaskProgressEventArgs>) -> ::windows::core::Result<()> + ::core::marker::Send + 'static> {
16131613
vtable: *const BackgroundTaskProgressEventHandler_Vtbl,
16141614
invoke: F,
16151615
count: ::windows::core::RefCount,
16161616
}
1617-
impl<F: FnMut(&::core::option::Option<BackgroundTaskRegistration>, &::core::option::Option<BackgroundTaskProgressEventArgs>) -> ::windows::core::Result<()> + 'static> BackgroundTaskProgressEventHandlerBox<F> {
1617+
impl<F: FnMut(&::core::option::Option<BackgroundTaskRegistration>, &::core::option::Option<BackgroundTaskProgressEventArgs>) -> ::windows::core::Result<()> + ::core::marker::Send + 'static> BackgroundTaskProgressEventHandlerBox<F> {
16181618
const VTABLE: BackgroundTaskProgressEventHandler_Vtbl = BackgroundTaskProgressEventHandler_Vtbl { base: ::windows::core::IUnknownVtbl { QueryInterface: Self::QueryInterface, AddRef: Self::AddRef, Release: Self::Release }, Invoke: Self::Invoke };
16191619
unsafe extern "system" fn QueryInterface(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT {
16201620
let this = this as *mut ::windows::core::RawPtr as *mut Self;

crates/libs/windows/src/Windows/ApplicationModel/DataTransfer/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1871,7 +1871,7 @@ unsafe impl ::core::marker::Sync for DataProviderDeferral {}
18711871
#[repr(transparent)]
18721872
pub struct DataProviderHandler(pub ::windows::core::IUnknown);
18731873
impl DataProviderHandler {
1874-
pub fn new<F: FnMut(&::core::option::Option<DataProviderRequest>) -> ::windows::core::Result<()> + 'static>(invoke: F) -> Self {
1874+
pub fn new<F: FnMut(&::core::option::Option<DataProviderRequest>) -> ::windows::core::Result<()> + ::core::marker::Send + 'static>(invoke: F) -> Self {
18751875
let com = DataProviderHandlerBox::<F> { vtable: &DataProviderHandlerBox::<F>::VTABLE, count: ::windows::core::RefCount::new(1), invoke };
18761876
unsafe { ::core::mem::transmute(::windows::core::alloc::boxed::Box::new(com)) }
18771877
}
@@ -1882,12 +1882,12 @@ impl DataProviderHandler {
18821882
}
18831883
}
18841884
#[repr(C)]
1885-
struct DataProviderHandlerBox<F: FnMut(&::core::option::Option<DataProviderRequest>) -> ::windows::core::Result<()> + 'static> {
1885+
struct DataProviderHandlerBox<F: FnMut(&::core::option::Option<DataProviderRequest>) -> ::windows::core::Result<()> + ::core::marker::Send + 'static> {
18861886
vtable: *const DataProviderHandler_Vtbl,
18871887
invoke: F,
18881888
count: ::windows::core::RefCount,
18891889
}
1890-
impl<F: FnMut(&::core::option::Option<DataProviderRequest>) -> ::windows::core::Result<()> + 'static> DataProviderHandlerBox<F> {
1890+
impl<F: FnMut(&::core::option::Option<DataProviderRequest>) -> ::windows::core::Result<()> + ::core::marker::Send + 'static> DataProviderHandlerBox<F> {
18911891
const VTABLE: DataProviderHandler_Vtbl = DataProviderHandler_Vtbl { base: ::windows::core::IUnknownVtbl { QueryInterface: Self::QueryInterface, AddRef: Self::AddRef, Release: Self::Release }, Invoke: Self::Invoke };
18921892
unsafe extern "system" fn QueryInterface(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT {
18931893
let this = this as *mut ::windows::core::RawPtr as *mut Self;
@@ -3817,7 +3817,7 @@ unsafe impl ::core::marker::Sync for ShareProvider {}
38173817
#[repr(transparent)]
38183818
pub struct ShareProviderHandler(pub ::windows::core::IUnknown);
38193819
impl ShareProviderHandler {
3820-
pub fn new<F: FnMut(&::core::option::Option<ShareProviderOperation>) -> ::windows::core::Result<()> + 'static>(invoke: F) -> Self {
3820+
pub fn new<F: FnMut(&::core::option::Option<ShareProviderOperation>) -> ::windows::core::Result<()> + ::core::marker::Send + 'static>(invoke: F) -> Self {
38213821
let com = ShareProviderHandlerBox::<F> { vtable: &ShareProviderHandlerBox::<F>::VTABLE, count: ::windows::core::RefCount::new(1), invoke };
38223822
unsafe { ::core::mem::transmute(::windows::core::alloc::boxed::Box::new(com)) }
38233823
}
@@ -3828,12 +3828,12 @@ impl ShareProviderHandler {
38283828
}
38293829
}
38303830
#[repr(C)]
3831-
struct ShareProviderHandlerBox<F: FnMut(&::core::option::Option<ShareProviderOperation>) -> ::windows::core::Result<()> + 'static> {
3831+
struct ShareProviderHandlerBox<F: FnMut(&::core::option::Option<ShareProviderOperation>) -> ::windows::core::Result<()> + ::core::marker::Send + 'static> {
38323832
vtable: *const ShareProviderHandler_Vtbl,
38333833
invoke: F,
38343834
count: ::windows::core::RefCount,
38353835
}
3836-
impl<F: FnMut(&::core::option::Option<ShareProviderOperation>) -> ::windows::core::Result<()> + 'static> ShareProviderHandlerBox<F> {
3836+
impl<F: FnMut(&::core::option::Option<ShareProviderOperation>) -> ::windows::core::Result<()> + ::core::marker::Send + 'static> ShareProviderHandlerBox<F> {
38373837
const VTABLE: ShareProviderHandler_Vtbl = ShareProviderHandler_Vtbl { base: ::windows::core::IUnknownVtbl { QueryInterface: Self::QueryInterface, AddRef: Self::AddRef, Release: Self::Release }, Invoke: Self::Invoke };
38383838
unsafe extern "system" fn QueryInterface(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT {
38393839
let this = this as *mut ::windows::core::RawPtr as *mut Self;

0 commit comments

Comments
 (0)