diff options
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | src/lib.rs | 8 | ||||
-rw-r--r-- | tests/11-traits-generics-docs.rs | 28 | ||||
-rw-r--r-- | tests/progress.rs | 1 |
4 files changed, 38 insertions, 1 deletions
diff --git a/Cargo.toml b/Cargo.toml index 4cc9dea..af7d8ba 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "impl_trait" -version = "0.1.2" +version = "0.1.3" 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 9473af0..2a3b90f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -268,6 +268,14 @@ pub fn impl_trait(item: TokenStream) -> TokenStream { } if found.len() == to_remove.len() { found.push(Vec::new()); + in_unsafe = false; + in_impl = false; + in_where = false; + in_path = false; + in_attr_cont = false; + in_generic = false; + has_injected_generics = false; + count = 0; } match tt { &TokenTree::Ident(ref ident) => { diff --git a/tests/11-traits-generics-docs.rs b/tests/11-traits-generics-docs.rs new file mode 100644 index 0000000..7d6ab6e --- /dev/null +++ b/tests/11-traits-generics-docs.rs @@ -0,0 +1,28 @@ +// Checks that multiple `impl trait` in a row are valid, with generics and docs. + +use impl_trait::impl_trait; + +struct Foo<T>(T); +trait Bar { +} +trait Baz { +} + +impl_trait! { + impl<T> Foo<T> { + /// ABC + impl trait Bar { + } + /// DEF + 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 74c5774..5a1bdb6 100644 --- a/tests/progress.rs +++ b/tests/progress.rs @@ -11,6 +11,7 @@ fn tests() { 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/11-traits-generics-docs.rs"); t.pass("tests/98-readme.rs"); t.pass("tests/99-goal.rs"); } |