Convert TyPolyTraitRef to accept arbitary bounds, so that things like

`Box<for<'a> Foo<&'a T> + 'a>` can be accepted. Also cleanup the visitor/fold
in general, exposing more callbacks.
This commit is contained in:
Niko Matsakis 2014-11-15 16:55:27 -05:00
parent 9c808ffee4
commit c8a94c5dfa
8 changed files with 155 additions and 70 deletions

View file

@ -1023,10 +1023,21 @@ impl<'a> Parser<'a> {
self.parse_ty_bare_fn_or_ty_closure(lifetime_defs)
} else if self.token == token::ModSep ||
self.token.is_ident() ||
self.token.is_path() {
self.token.is_path()
{
let trait_ref = self.parse_trait_ref();
TyPolyTraitRef(P(PolyTraitRef { bound_lifetimes: lifetime_defs,
trait_ref: trait_ref }))
let poly_trait_ref = ast::PolyTraitRef { bound_lifetimes: lifetime_defs,
trait_ref: trait_ref };
let other_bounds = if self.eat(&token::BinOp(token::Plus)) {
self.parse_ty_param_bounds()
} else {
OwnedSlice::empty()
};
let all_bounds =
Some(TraitTyParamBound(poly_trait_ref)).into_iter()
.chain(other_bounds.into_vec().into_iter())
.collect();
ast::TyPolyTraitRef(all_bounds)
} else {
self.parse_ty_closure(lifetime_defs)
}