Skip to content

Commit

Permalink
libsyntax: Don't allow impl (Trait) for Type (with the parentheses).
Browse files Browse the repository at this point in the history
  • Loading branch information
pcwalton committed Mar 29, 2013
1 parent 943d7ad commit 36909c7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

5 comments on commit 36909c7

@bors
Copy link
Contributor

@bors bors commented on 36909c7 Mar 29, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from brson
at pcwalton@36909c7

@bors
Copy link
Contributor

@bors bors commented on 36909c7 Mar 29, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging pcwalton/rust/parenthesized-trait = 36909c7 into auto

@bors
Copy link
Contributor

@bors bors commented on 36909c7 Mar 29, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pcwalton/rust/parenthesized-trait = 36909c7 merged ok, testing candidate = a985bc5

@bors
Copy link
Contributor

@bors bors commented on 36909c7 Mar 29, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 36909c7 Mar 29, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding incoming to auto = a985bc5

Please sign in to comment.