From b20400e80f5737f39fad83546c9a60921d88b8bd Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 19 Mar 2023 18:11:00 +0100 Subject: refactor: skip transmuting expectations without generics --- macros/src/expectation.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'macros') diff --git a/macros/src/expectation.rs b/macros/src/expectation.rs index 5a4922c..a6d181f 100644 --- a/macros/src/expectation.rs +++ b/macros/src/expectation.rs @@ -278,6 +278,12 @@ impl ToTokens for Expectation let (boundless_impl_generics, _, _) = boundless_generics.split_for_impl(); + let do_strip_generic_params = if generic_params.is_empty() { + quote! { self } + } else { + quote! { unsafe { std::mem::transmute(self) } } + }; + quote! { #expectation_struct @@ -323,7 +329,7 @@ impl ToTokens for Expectation self, ) -> #ident<#(#bogus_generics),*> { - unsafe { std::mem::transmute(self) } + #do_strip_generic_params } fn get_returning(&self) -> &#returning_fn -- cgit v1.2.3-18-g5258