From 6253f0ff34cbbc786add4e6b2b79144382772819 Mon Sep 17 00:00:00 2001 From: Kenny Kerr Date: Thu, 6 Jun 2024 07:45:27 -0500 Subject: [PATCH] debug_assert --- crates/libs/bindgen/src/rust/winrt_methods.rs | 12 ++++++--- crates/tests/noexcept/src/bindings.rs | 27 ++++++++++++------- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/crates/libs/bindgen/src/rust/winrt_methods.rs b/crates/libs/bindgen/src/rust/winrt_methods.rs index 1f98cf7999..345cb01e75 100644 --- a/crates/libs/bindgen/src/rust/winrt_methods.rs +++ b/crates/libs/bindgen/src/rust/winrt_methods.rs @@ -66,7 +66,8 @@ pub fn writer( metadata::Type::Void => { if noexcept { quote! { - _ = #vcall; + let hresult__ = #vcall; + debug_assert!(hresult__.0 == 0); } } else { quote! { @@ -78,7 +79,8 @@ pub fn writer( if noexcept { quote! { let mut result__ = core::mem::MaybeUninit::zeroed(); - _ = #vcall; + let hresult__ = #vcall; + debug_assert!(hresult__.0 == 0); result__.assume_init() } } else { @@ -94,12 +96,14 @@ pub fn writer( if metadata::type_is_blittable(&signature.return_type) { quote! { let mut result__ = core::mem::zeroed(); - _ = #vcall; + let hresult__ = #vcall; + debug_assert!(hresult__.0 == 0); result__ } } else { quote! { let mut result__ = core::mem::zeroed(); - _ = #vcall; + let hresult__ = #vcall; + debug_assert!(hresult__.0 == 0); core::mem::transmute(result__) } } } else if metadata::type_is_blittable(&signature.return_type) { diff --git a/crates/tests/noexcept/src/bindings.rs b/crates/tests/noexcept/src/bindings.rs index 5ca843dd7a..1f4a837e1a 100644 --- a/crates/tests/noexcept/src/bindings.rs +++ b/crates/tests/noexcept/src/bindings.rs @@ -118,19 +118,21 @@ impl ITest { pub fn MethodStringN(&self, test: &windows_core::HSTRING) { let this = self; unsafe { - _ = (windows_core::Interface::vtable(this).MethodStringN)( + let hresult__ = (windows_core::Interface::vtable(this).MethodStringN)( windows_core::Interface::as_raw(this), core::mem::transmute_copy(test), ); + debug_assert!(hresult__.0 == 0); } } pub fn MethodInt32N(&self, test: i32) { let this = self; unsafe { - _ = (windows_core::Interface::vtable(this).MethodInt32N)( + let hresult__ = (windows_core::Interface::vtable(this).MethodInt32N)( windows_core::Interface::as_raw(this), test, ); + debug_assert!(hresult__.0 == 0); } } pub fn MethodTestN(&self, test: P0) @@ -139,60 +141,66 @@ impl ITest { { let this = self; unsafe { - _ = (windows_core::Interface::vtable(this).MethodTestN)( + let hresult__ = (windows_core::Interface::vtable(this).MethodTestN)( windows_core::Interface::as_raw(this), test.param().abi(), ); + debug_assert!(hresult__.0 == 0); } } pub fn StringN(&self) -> windows_core::HSTRING { let this = self; unsafe { let mut result__ = core::mem::zeroed(); - _ = (windows_core::Interface::vtable(this).StringN)( + let hresult__ = (windows_core::Interface::vtable(this).StringN)( windows_core::Interface::as_raw(this), &mut result__, ); + debug_assert!(hresult__.0 == 0); core::mem::transmute(result__) } } pub fn SetStringN(&self, value: &windows_core::HSTRING) { let this = self; unsafe { - _ = (windows_core::Interface::vtable(this).SetStringN)( + let hresult__ = (windows_core::Interface::vtable(this).SetStringN)( windows_core::Interface::as_raw(this), core::mem::transmute_copy(value), ); + debug_assert!(hresult__.0 == 0); } } pub fn Int32N(&self) -> i32 { let this = self; unsafe { let mut result__ = core::mem::zeroed(); - _ = (windows_core::Interface::vtable(this).Int32N)( + let hresult__ = (windows_core::Interface::vtable(this).Int32N)( windows_core::Interface::as_raw(this), &mut result__, ); + debug_assert!(hresult__.0 == 0); result__ } } pub fn SetInt32N(&self, value: i32) { let this = self; unsafe { - _ = (windows_core::Interface::vtable(this).SetInt32N)( + let hresult__ = (windows_core::Interface::vtable(this).SetInt32N)( windows_core::Interface::as_raw(this), value, ); + debug_assert!(hresult__.0 == 0); } } pub fn TestN(&self) -> Option { let this = self; unsafe { let mut result__ = core::mem::zeroed(); - _ = (windows_core::Interface::vtable(this).TestN)( + let hresult__ = (windows_core::Interface::vtable(this).TestN)( windows_core::Interface::as_raw(this), &mut result__, ); + debug_assert!(hresult__.0 == 0); core::mem::transmute(result__) } } @@ -202,10 +210,11 @@ impl ITest { { let this = self; unsafe { - _ = (windows_core::Interface::vtable(this).SetTestN)( + let hresult__ = (windows_core::Interface::vtable(this).SetTestN)( windows_core::Interface::as_raw(this), value.param().abi(), ); + debug_assert!(hresult__.0 == 0); } } }