Skip to content

Commit

Permalink
Fixed WhereClause parsing.
Browse files Browse the repository at this point in the history
  • Loading branch information
azriel91 committed Oct 17, 2018
1 parent a003f3e commit 5e5c548
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/attr.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::str::FromStr;

use quote::ToTokens;
use syn;

/// Represent the `derivative` attributes on the input type (`struct`/`enum`).
Expand Down Expand Up @@ -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::<syn::WhereClause>(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::<syn::WhereClause>(stream).map_err(|e| e.to_string());
bounds.extend(try!(where_clause).predicates);
}

Expand Down

0 comments on commit 5e5c548

Please sign in to comment.