diff options
author | SoniEx2 <endermoneymod@gmail.com> | 2021-08-13 00:35:41 -0300 |
---|---|---|
committer | SoniEx2 <endermoneymod@gmail.com> | 2021-08-13 00:35:41 -0300 |
commit | 5cf5f84335c759338f993175fbbdc8bfba7fb5d3 (patch) | |
tree | 7887fe972ce4baa5c58947b2cf27a55c1079fe27 /src | |
parent | bffdb1e7ad54b0b857d69d45b8791c68741a6ea0 (diff) |
Fix `impl trait where` without `impl where`
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 14 |
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; } } |