From 5e5c5481cde6168df43744648d476cbda57f20f0 Mon Sep 17 00:00:00 2001 From: Azriel Hoh Date: Wed, 17 Oct 2018 15:36:39 +1300 Subject: [PATCH] Fixed `WhereClause` parsing. Issue #25 --- src/attr.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/attr.rs b/src/attr.rs index 276fd0d..0e83796 100644 --- a/src/attr.rs +++ b/src/attr.rs @@ -1,5 +1,6 @@ use std::str::FromStr; +use quote::ToTokens; use syn; /// Represent the `derivative` attributes on the input type (`struct`/`enum`). @@ -619,8 +620,12 @@ fn parse_bound( let bound = try!(value.ok_or_else(|| "`bound` needs a value".to_string())); if !bound.is_empty() { - let where_clause = - syn::parse2::(quote!(where #bound)).map_err(|e| e.to_string()); + let mut stream = proc_macro2::TokenStream::new(); + quote!(where).to_tokens(&mut stream); + let constraints = proc_macro2::TokenStream::from_str(bound).map_err(|e| format!("{:?}", e)); + stream.extend(constraints); + + let where_clause = syn::parse2::(stream).map_err(|e| e.to_string()); bounds.extend(try!(where_clause).predicates); }