Skip to content

Commit a985bc5

Browse files
committed
auto merge of #5616 : pcwalton/rust/parenthesized-trait, r=brson
r? @brson
2 parents f7a2371 + 36909c7 commit a985bc5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/libsyntax/parse/parser.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -3107,11 +3107,15 @@ pub impl Parser {
31073107
// XXX: clownshoes
31083108
let ident = special_idents::clownshoes_extensions;
31093109

3110+
// Special case: if the next identifier that follows is '(', don't
3111+
// allow this to be parsed as a trait.
3112+
let could_be_trait = *self.token != token::LPAREN;
3113+
31103114
// Parse the trait.
31113115
let mut ty = self.parse_ty(false);
31123116

31133117
// Parse traits, if necessary.
3114-
let opt_trait = if self.eat_keyword(&~"for") {
3118+
let opt_trait = if could_be_trait && self.eat_keyword(&~"for") {
31153119
// New-style trait. Reinterpret the type as a trait.
31163120
let opt_trait_ref = match ty.node {
31173121
ty_path(path, node_id) => {

0 commit comments

Comments
 (0)