about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-09-03 02:56:03 -0700
committerbors <bors@rust-lang.org>2013-09-03 02:56:03 -0700
commit8183c74ec1f4747986eb177d7d93bee4c622b0b7 (patch)
tree87cef0103a379f4f0cc642487e531479758d82fa /src/libsyntax/parse
parent58decdd7a115f2892d63fa3760fa2125eb784ac8 (diff)
parent1b3cd960decbaad3fc585c4ac4e5ec4dd8ceabc9 (diff)
downloadrust-8183c74ec1f4747986eb177d7d93bee4c622b0b7.tar.gz
rust-8183c74ec1f4747986eb177d7d93bee4c622b0b7.zip
auto merge of #8940 : pnkfelix/rust/fsk-8468-allow-underscore-paramname-in-trait-default-method, r=alexcrichton
Fix #8468.  (Though the right answer in the end, as noted on the dialogue on the ticket, might be to just require trait methods to name their parameters, regardless of whether they have a default method implementation or not.)
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/parser.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 02af6d23b44..14b133b4379 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -347,6 +347,10 @@ impl Drop for Parser {
     fn drop(&self) {}
 }
 
+fn is_plain_ident_or_underscore(t: &token::Token) -> bool {
+    is_plain_ident(t) || *t == token::UNDERSCORE
+}
+
 impl Parser {
     // convert a token to a string using self's reader
     pub fn token_to_str(&self, token: &token::Token) -> ~str {
@@ -1242,11 +1246,13 @@ impl Parser {
             _ => 0
         };
 
+        debug!("parser is_named_argument offset:%u", offset);
+
         if offset == 0 {
-            is_plain_ident(&*self.token)
+            is_plain_ident_or_underscore(&*self.token)
                 && self.look_ahead(1, |t| *t == token::COLON)
         } else {
-            self.look_ahead(offset, |t| is_plain_ident(t))
+            self.look_ahead(offset, |t| is_plain_ident_or_underscore(t))
                 && self.look_ahead(offset + 1, |t| *t == token::COLON)
         }
     }
@@ -1256,6 +1262,8 @@ impl Parser {
     pub fn parse_arg_general(&self, require_name: bool) -> arg {
         let is_mutbl = self.eat_keyword(keywords::Mut);
         let pat = if require_name || self.is_named_argument() {
+            debug!("parse_arg_general parse_pat (require_name:%?)",
+                   require_name);
             self.parse_arg_mode();
             let pat = self.parse_pat();
 
@@ -1266,6 +1274,7 @@ impl Parser {
             self.expect(&token::COLON);
             pat
         } else {
+            debug!("parse_arg_general ident_to_pat");
             ast_util::ident_to_pat(self.get_id(),
                                    *self.last_span,
                                    special_idents::invalid)