mystor / synstructure

Utilities for dealing with substructures within syn macros

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Doesn't build on Rust 1.18 and 1.19

hcpl opened this issue · comments

commented

Currently synstructure uses break with value (a 1.19 feature) in

synstructure/src/lib.rs

Lines 2102 to 2111 in dad0b18

let ((unsafe_kw, bound, body, mut generics), after) = loop {
if let Ok((gi, c2)) = parse_gen_impl(c) {
break (gi, c2.token_stream());
} else if let Some((tt, c2)) = c.token_tree() {
c = c2;
before.push(tt);
} else {
panic!("Expected a gen impl block");
}
};
and Option::get_or_insert (a 1.20 feature) in

synstructure/src/lib.rs

Lines 282 to 286 in dad0b18

let mut to_clause = into.where_clause.get_or_insert(WhereClause {
where_token: Default::default(),
predicates: punctuated::Punctuated::new(),
});
to_clause.predicates.extend(from_clause.predicates.iter().cloned());

I see that 1.15 was failing in Travis so it was disabled and some non-1.15 features slipped into the library. But that was months ago, should it be re-enabled again or Rust version has to be bumped?

commented

There is a case about Option::get_or_insert_with which has a workaround:

synstructure/src/lib.rs

Lines 1508 to 1517 in dad0b18

// Ensure we have a where clause, because we need to use it. We
// can't use `get_or_insert_with`, because it isn't supported on all
// rustc versions we support.
if where_clause.is_none() {
*where_clause = Some(WhereClause {
where_token: Default::default(),
predicates: punctuated::Punctuated::new(),
});
}
let clause = where_clause.as_mut().unwrap();

I'd love a PR which re-enables the 1.15 tests, because I'd like to have the same minimum version as syn. It was disabled originally because I didn't have enough time to figure out what was wrong.

commented

Alright, I've changed those parts a bit and now it passes on 1.15 locally. I'll set up a PR a bit later.

You kindly fixed this for me in #15 🎉