Skip to content

Commit 873b775

Browse files
committed
syntax: Lower priority of + in impl Trait/dyn Trait
1 parent 6b99ade commit 873b775

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/libsyntax/parse/parser.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,13 +1614,12 @@ impl<'a> Parser<'a> {
16141614
self.parse_remaining_bounds(lifetime_defs, path, lo, parse_plus)?
16151615
}
16161616
} else if self.eat_keyword(keywords::Impl) {
1617-
// FIXME: figure out priority of `+` in `impl Trait1 + Trait2` (#34511).
1618-
TyKind::ImplTrait(self.parse_ty_param_bounds()?)
1617+
TyKind::ImplTrait(self.parse_ty_param_bounds_common(allow_plus)?)
16191618
} else if self.check_keyword(keywords::Dyn) &&
16201619
self.look_ahead(1, |t| t.can_begin_bound() && !can_continue_type_after_ident(t)) {
1621-
// FIXME: figure out priority of `+` in `dyn Trait1 + Trait2` (#34511).
16221620
self.bump(); // `dyn`
1623-
TyKind::TraitObject(self.parse_ty_param_bounds()?, TraitObjectSyntax::Dyn)
1621+
TyKind::TraitObject(self.parse_ty_param_bounds_common(allow_plus)?,
1622+
TraitObjectSyntax::Dyn)
16241623
} else if self.check(&token::Question) ||
16251624
self.check_lifetime() && self.look_ahead(1, |t| t == &token::BinOp(token::Plus)) {
16261625
// Bound list (trait object type)

src/test/compile-fail/private-inferred-type.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ mod m {
7272
impl TraitWithAssocTy for u8 { type AssocTy = Priv; }
7373
//~^ ERROR private type `m::Priv` in public interface
7474

75-
pub fn leak_anon1() -> impl Trait + 'static { 0 }
75+
pub fn leak_anon1() -> (impl Trait + 'static) { 0 }
7676
pub fn leak_anon2() -> impl TraitWithTyParam<Alias> { 0 }
7777
pub fn leak_anon3() -> impl TraitWithAssocTy<AssocTy = Alias> { 0 }
7878

0 commit comments

Comments
 (0)