summary refs log tree commit diff stats
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 192d56b..348e4e1 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -210,14 +210,16 @@ pub fn impl_trait(item: TokenStream) -> TokenStream {
                         // *then* add the "where" (from the impl-trait)
                         found.last_mut().unwrap().push(tt.clone());
                         // and the parent bounds (except the "where")
-                        found.last_mut().unwrap().extend((&where_bounds).into_iter().skip(1).cloned());
-                        // also make sure that there's an ',' at the correct place
-                        if let Some(&TokenTree::Punct(ref x)) = where_bounds.last() {
-                            if x.as_char() == ',' {
-                                continue 'main_loop;
+                        if !where_bounds.is_empty() {
+                            found.last_mut().unwrap().extend((&where_bounds).into_iter().skip(1).cloned());
+                            // also make sure that there's an ',' at the correct place
+                            if let Some(&TokenTree::Punct(ref x)) = where_bounds.last() {
+                                if x.as_char() == ',' {
+                                    continue 'main_loop;
+                                }
                             }
+                            found.last_mut().unwrap().push(proc_macro::Punct::new(',', proc_macro::Spacing::Alone).into());
                         }
-                        found.last_mut().unwrap().push(proc_macro::Punct::new(',', proc_macro::Spacing::Alone).into());
                         continue 'main_loop;
                     }
                 }