summaryrefslogtreecommitdiff
path: root/macros/src
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2023-03-19 18:11:00 +0100
committerHampusM <hampus@hampusmat.com>2023-03-19 18:11:00 +0100
commitb20400e80f5737f39fad83546c9a60921d88b8bd (patch)
tree1245ef7b4d172ac19c4d21b0c20f397cbba8c164 /macros/src
parentf73c3218b9a004fb405386ce2623d2dfa077388c (diff)
refactor: skip transmuting expectations without generics
Diffstat (limited to 'macros/src')
-rw-r--r--macros/src/expectation.rs8
1 files changed, 7 insertions, 1 deletions
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