about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-03-28 23:00:50 -0700
committerbors <bors@rust-lang.org>2013-03-28 23:00:50 -0700
commita985bc52cd3e65ee6693327eb728d34f477c0a12 (patch)
treecfeded27e8a7d3d04177c78a4b67c7e0dfc91b80 /src/libsyntax
parentf7a2371c176663d59062ec5158f39faecba45768 (diff)
parent36909c7575e2ddfe2925423aceb62d82ae8208b2 (diff)
downloadrust-a985bc52cd3e65ee6693327eb728d34f477c0a12.tar.gz
rust-a985bc52cd3e65ee6693327eb728d34f477c0a12.zip
auto merge of #5616 : pcwalton/rust/parenthesized-trait, r=brson
r? @brson
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/parse/parser.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 51a7f7fbd1c..c52162b7f14 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -3107,11 +3107,15 @@ pub impl Parser {
         // XXX: clownshoes
         let ident = special_idents::clownshoes_extensions;
 
+        // Special case: if the next identifier that follows is '(', don't
+        // allow this to be parsed as a trait.
+        let could_be_trait = *self.token != token::LPAREN;
+
         // Parse the trait.
         let mut ty = self.parse_ty(false);
 
         // Parse traits, if necessary.
-        let opt_trait = if self.eat_keyword(&~"for") {
+        let opt_trait = if could_be_trait && self.eat_keyword(&~"for") {
             // New-style trait. Reinterpret the type as a trait.
             let opt_trait_ref = match ty.node {
                 ty_path(path, node_id) => {