1
Fork 0

syntax: Lower priority of + in impl Trait/dyn Trait

This commit is contained in:
Vadim Petrochenkov 2017-10-15 01:55:18 +03:00
parent 6b99adeb11
commit 873b77531c
2 changed files with 4 additions and 5 deletions

View file

@ -1614,13 +1614,12 @@ impl<'a> Parser<'a> {
self.parse_remaining_bounds(lifetime_defs, path, lo, parse_plus)? self.parse_remaining_bounds(lifetime_defs, path, lo, parse_plus)?
} }
} else if self.eat_keyword(keywords::Impl) { } else if self.eat_keyword(keywords::Impl) {
// FIXME: figure out priority of `+` in `impl Trait1 + Trait2` (#34511). TyKind::ImplTrait(self.parse_ty_param_bounds_common(allow_plus)?)
TyKind::ImplTrait(self.parse_ty_param_bounds()?)
} else if self.check_keyword(keywords::Dyn) && } else if self.check_keyword(keywords::Dyn) &&
self.look_ahead(1, |t| t.can_begin_bound() && !can_continue_type_after_ident(t)) { self.look_ahead(1, |t| t.can_begin_bound() && !can_continue_type_after_ident(t)) {
// FIXME: figure out priority of `+` in `dyn Trait1 + Trait2` (#34511).
self.bump(); // `dyn` self.bump(); // `dyn`
TyKind::TraitObject(self.parse_ty_param_bounds()?, TraitObjectSyntax::Dyn) TyKind::TraitObject(self.parse_ty_param_bounds_common(allow_plus)?,
TraitObjectSyntax::Dyn)
} else if self.check(&token::Question) || } else if self.check(&token::Question) ||
self.check_lifetime() && self.look_ahead(1, |t| t == &token::BinOp(token::Plus)) { self.check_lifetime() && self.look_ahead(1, |t| t == &token::BinOp(token::Plus)) {
// Bound list (trait object type) // Bound list (trait object type)

View file

@ -72,7 +72,7 @@ mod m {
impl TraitWithAssocTy for u8 { type AssocTy = Priv; } impl TraitWithAssocTy for u8 { type AssocTy = Priv; }
//~^ ERROR private type `m::Priv` in public interface //~^ ERROR private type `m::Priv` in public interface
pub fn leak_anon1() -> impl Trait + 'static { 0 } pub fn leak_anon1() -> (impl Trait + 'static) { 0 }
pub fn leak_anon2() -> impl TraitWithTyParam<Alias> { 0 } pub fn leak_anon2() -> impl TraitWithTyParam<Alias> { 0 }
pub fn leak_anon3() -> impl TraitWithAssocTy<AssocTy = Alias> { 0 } pub fn leak_anon3() -> impl TraitWithAssocTy<AssocTy = Alias> { 0 }