@@ -347,6 +347,13 @@ impl Drop for Parser {
347
347
fn drop ( & self ) { }
348
348
}
349
349
350
+ fn is_plain_ident_or_underscore ( t : & token:: Token ) -> bool {
351
+ match * t {
352
+ token:: IDENT ( _, false ) | token:: UNDERSCORE => true ,
353
+ _ => false ,
354
+ }
355
+ }
356
+
350
357
impl Parser {
351
358
// convert a token to a string using self's reader
352
359
pub fn token_to_str ( & self , token : & token:: Token ) -> ~str {
@@ -1242,11 +1249,13 @@ impl Parser {
1242
1249
_ => 0
1243
1250
} ;
1244
1251
1252
+ debug ! ( "parser is_named_argument offset:%u" , offset) ;
1253
+
1245
1254
if offset == 0 {
1246
- is_plain_ident ( & * self . token )
1255
+ is_plain_ident_or_underscore ( & * self . token )
1247
1256
&& self . look_ahead ( 1 , |t| * t == token:: COLON )
1248
1257
} else {
1249
- self . look_ahead ( offset, |t| is_plain_ident ( t) )
1258
+ self . look_ahead ( offset, |t| is_plain_ident_or_underscore ( t) )
1250
1259
&& self . look_ahead ( offset + 1 , |t| * t == token:: COLON )
1251
1260
}
1252
1261
}
@@ -1256,6 +1265,8 @@ impl Parser {
1256
1265
pub fn parse_arg_general ( & self , require_name : bool ) -> arg {
1257
1266
let is_mutbl = self . eat_keyword ( keywords:: Mut ) ;
1258
1267
let pat = if require_name || self . is_named_argument ( ) {
1268
+ debug ! ( "parse_arg_general parse_pat (require_name:%?)" ,
1269
+ require_name) ;
1259
1270
self . parse_arg_mode ( ) ;
1260
1271
let pat = self . parse_pat ( ) ;
1261
1272
@@ -1266,6 +1277,7 @@ impl Parser {
1266
1277
self . expect ( & token:: COLON ) ;
1267
1278
pat
1268
1279
} else {
1280
+ debug ! ( "parse_arg_general ident_to_pat" ) ;
1269
1281
ast_util:: ident_to_pat ( self . get_id ( ) ,
1270
1282
* self . last_span ,
1271
1283
special_idents:: invalid)
0 commit comments