about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2017-01-19 13:28:45 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2017-01-19 13:28:45 +0300
commit853f6974767243e2e5defb43f5f7195ce1fb1cc7 (patch)
treede69b2f21ea89aace638a4bd09e6e3eb79621406 /src/libsyntax/parse
parent74c42ac173bee900979870ed986c760596d1fbdb (diff)
downloadrust-853f6974767243e2e5defb43f5f7195ce1fb1cc7.tar.gz
rust-853f6974767243e2e5defb43f5f7195ce1fb1cc7.zip
Fix regression in parsing of trait object types
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/parser.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index d1a683b0bd5..b5913daaa5b 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -1277,10 +1277,17 @@ impl<'a> Parser<'a> {
                           "at least one type parameter bound \
                           must be specified");
         }
-        if let TyKind::Path(None, ref path) = lhs.node {
+
+        let mut lhs = lhs.unwrap();
+        if let TyKind::Paren(ty) = lhs.node {
+            // We have to accept the first bound in parens for backward compatibility.
+            // Example: `(Bound) + Bound + Bound`
+            lhs = ty.unwrap();
+        }
+        if let TyKind::Path(None, path) = lhs.node {
             let poly_trait_ref = PolyTraitRef {
                 bound_lifetimes: Vec::new(),
-                trait_ref: TraitRef { path: path.clone(), ref_id: lhs.id },
+                trait_ref: TraitRef { path: path, ref_id: lhs.id },
                 span: lhs.span,
             };
             let poly_trait_ref = TraitTyParamBound(poly_trait_ref, TraitBoundModifier::None);