summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2023-03-19 13:30:53 +0100
committerHampusM <hampus@hampusmat.com>2023-03-19 13:30:53 +0100
commitd03c747cfef277fda5823e08784c94c30c7f3964 (patch)
tree99620a5d44ed4c1874f69578cddfdc1420c11d6e
parent21911153355b4bf9612c38f5ac92562aec02ffd9 (diff)
fix: allow trait generic param bounds
-rw-r--r--macros/src/expectation.rs2
-rw-r--r--macros/src/syn_ext.rs17
2 files changed, 16 insertions, 3 deletions
diff --git a/macros/src/expectation.rs b/macros/src/expectation.rs
index d35ef97..7d8f1a7 100644
--- a/macros/src/expectation.rs
+++ b/macros/src/expectation.rs
@@ -208,7 +208,7 @@ impl ToTokens for Expectation
vis: Visibility::new_pub_crate(),
struct_token: <Token![struct]>::default(),
ident: self.ident.clone(),
- generics: generics.clone().without_where_clause(),
+ generics: generics.clone().strip_where_clause_and_bounds(),
fields: Fields::Named(FieldsNamed {
brace_token: Brace::default(),
named: [Field {
diff --git a/macros/src/syn_ext.rs b/macros/src/syn_ext.rs
index 7a3e9ae..9b5b037 100644
--- a/macros/src/syn_ext.rs
+++ b/macros/src/syn_ext.rs
@@ -27,15 +27,28 @@ use syn::{
pub trait GenericsExt: Sized
{
- fn without_where_clause(self) -> Self;
+ fn strip_where_clause_and_bounds(self) -> Self;
}
impl GenericsExt for Generics
{
- fn without_where_clause(mut self) -> Self
+ fn strip_where_clause_and_bounds(mut self) -> Self
{
self.where_clause = None;
+ self.params = self
+ .params
+ .into_iter()
+ .map(|generic_param| match generic_param {
+ GenericParam::Type(mut type_param) => {
+ type_param.bounds.clear();
+
+ GenericParam::Type(type_param)
+ }
+ generic_param => generic_param,
+ })
+ .collect();
+
self
}
}