@@ -574,9 +574,12 @@ impl<'a> Parser<'a> {
574574 self . bug ( "ident interpolation not converted to real token" ) ;
575575 }
576576 _ => {
577- let token_str = self . this_token_to_string ( ) ;
578- Err ( self . fatal ( & format ! ( "expected ident, found `{}`" ,
579- token_str) ) )
577+ let mut err = self . fatal ( & format ! ( "expected identifier, found `{}`" ,
578+ self . this_token_to_string( ) ) ) ;
579+ if self . token == token:: Underscore {
580+ err. fileline_note ( self . span , "`_` is a wildcard pattern, not an identifier" ) ;
581+ }
582+ Err ( err)
580583 }
581584 }
582585 }
@@ -3782,12 +3785,6 @@ impl<'a> Parser<'a> {
37823785 fn parse_pat_ident ( & mut self ,
37833786 binding_mode : ast:: BindingMode )
37843787 -> PResult < ' a , PatKind > {
3785- if !self . token . is_plain_ident ( ) {
3786- let span = self . span ;
3787- let tok_str = self . this_token_to_string ( ) ;
3788- return Err ( self . span_fatal ( span,
3789- & format ! ( "expected identifier, found `{}`" , tok_str) ) )
3790- }
37913788 let ident = self . parse_ident ( ) ?;
37923789 let last_span = self . last_span ;
37933790 let name = codemap:: Spanned { span : last_span, node : ident} ;
@@ -3847,9 +3844,6 @@ impl<'a> Parser<'a> {
38473844 Visibility :: Inherited => self . span . lo ,
38483845 Visibility :: Public => self . last_span . lo ,
38493846 } ;
3850- if !self . token . is_plain_ident ( ) {
3851- return Err ( self . fatal ( "expected ident" ) ) ;
3852- }
38533847 let name = self . parse_ident ( ) ?;
38543848 self . expect ( & token:: Colon ) ?;
38553849 let ty = self . parse_ty_sum ( ) ?;
0 commit comments