aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib.rs11
-rw-r--r--tests/tests.rs12
2 files changed, 21 insertions, 2 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 2e0129e..a190cb9 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -9,7 +9,6 @@ use quote::quote;
use quote::quote_spanned;
use quote::ToTokens;
use syn::parse_macro_input;
-use syn::punctuated::Punctuated;
use syn::spanned::Spanned;
use syn::token::Brace;
use syn::token::Gt;
@@ -171,7 +170,15 @@ pub fn dynamize(_attr: TokenStream, input: TokenStream) -> TokenStream {
trait_token: Trait::default(),
generics: original_trait.generics.clone(),
colon_token: None,
- supertraits: Punctuated::new(),
+ supertraits: original_trait
+ .supertraits
+ .iter()
+ .filter(|t| match t {
+ TypeParamBound::Trait(t) => !t.path.is_ident("Sized"),
+ TypeParamBound::Lifetime(_) => true,
+ })
+ .cloned()
+ .collect(),
brace_token: Brace::default(),
items: Vec::new(),
};
diff --git a/tests/tests.rs b/tests/tests.rs
index 3a14811..448af64 100644
--- a/tests/tests.rs
+++ b/tests/tests.rs
@@ -187,3 +187,15 @@ fn type_trait_bound_static_test(
) -> Option<Box<dyn std::error::Error>> {
t.foobar("test").err()
}
+
+#[dynamize::dynamize]
+trait TypeWithSuper: std::fmt::Display + Sized {
+ type A: std::error::Error;
+
+ fn foobar(&self, text: &str) -> Result<i32, Self::A>;
+}
+
+fn test3<T: TypeWithSuper>(some: T) {
+ let dyn_trait: &dyn DynTypeWithSuper = &some;
+ println!("{}", dyn_trait);
+}