summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--Cargo.toml2
-rw-r--r--src/lib.rs2
-rw-r--r--tests/10-multiple-traits-with-generics.rs26
-rw-r--r--tests/progress.rs1
4 files changed, 30 insertions, 1 deletions
diff --git a/Cargo.toml b/Cargo.toml
index dfc22ee..4cc9dea 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "impl_trait"
-version = "0.1.1"
+version = "0.1.2"
 authors = ["SoniEx2 <endermoneymod@gmail.com>"]
 edition = "2018"
 description = "Allows impl trait inside inherent impl."
diff --git a/src/lib.rs b/src/lib.rs
index d8e5a15..9473af0 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -295,6 +295,7 @@ pub fn impl_trait(item: TokenStream) -> TokenStream {
                         in_generic = true;
                         in_path = true;
                         in_impl = false;
+                        has_injected_generics = false;
                         continue;
                     }
                 },
@@ -341,5 +342,6 @@ pub fn impl_trait(item: TokenStream) -> TokenStream {
     drop(where_bounds);
     //eprintln!("attributes: {:#?}", attributes);
     //eprintln!("OUTPUT: {:#?}", output);
+    //eprintln!("OUTPUT: {}", (&output).into_iter().cloned().collect::<TokenStream>());
     attributes.into_iter().chain(output.into_iter()).collect()
 }
diff --git a/tests/10-multiple-traits-with-generics.rs b/tests/10-multiple-traits-with-generics.rs
new file mode 100644
index 0000000..f302f11
--- /dev/null
+++ b/tests/10-multiple-traits-with-generics.rs
@@ -0,0 +1,26 @@
+// Checks that multiple `impl trait` in a row are valid, with generics.
+
+use impl_trait::impl_trait;
+
+struct Foo<T>(T);
+trait Bar {
+}
+trait Baz {
+}
+
+impl_trait! {
+    impl<T> Foo<T> {
+        impl trait Bar {
+        }
+        impl trait Baz {
+        }
+    }
+}
+
+fn static_assert_1<T: Bar>(_t: T) {}
+fn static_assert_2<T: Baz>(_t: T) {}
+
+fn main() {
+    static_assert_1(Foo(()));
+    static_assert_2(Foo(()));
+}
diff --git a/tests/progress.rs b/tests/progress.rs
index 22110b0..74c5774 100644
--- a/tests/progress.rs
+++ b/tests/progress.rs
@@ -10,6 +10,7 @@ fn tests() {
     t.pass("tests/07-docs.rs");
     t.pass("tests/08-inherent-docs.rs");
     t.pass("tests/09-multiple-traits.rs");
+    t.pass("tests/10-multiple-traits-with-generics.rs");
     t.pass("tests/98-readme.rs");
     t.pass("tests/99-goal.rs");
 }