fn parse_pat_ident(&mut self,
                       binding_mode: ast::BindingMode)
                       -> PResult<'a, PatKind> {
        if !self.token.is_plain_ident() {
            let span = self.span;
            let tok_str = self.this_token_to_string();
            return Err(self.span_fatal(span,
                            &format!("expected identifier, found `{}`", tok_str)))
        }
        let ident = try!(self.parse_ident());
        let last_span = self.last_span;
        let name = codemap::Spanned{span: last_span, node: ident};
        let sub = if self.eat(&token::At) {
            Some(try!(self.parse_pat()))
        } else {
            None
        };

        // just to be friendly, if they write something like
        //   ref Some(i)
        // we end up here with ( as the current token.  This shortly
        // leads to a parse error.  Note that if there is no explicit
        // binding mode then we do not end up here, because the lookahead
        // will direct us over to parse_enum_variant()
        if self.token == token::OpenDelim(token::Paren) {
            let last_span = self.last_span;
            return Err(self.span_fatal(
                last_span,
                "expected identifier, found enum pattern"))
        }

        Ok(PatKind::Ident(binding_mode, name, sub))
    }
/// Parse ident or ident @ pat
/// used by the copy foo and ref foo patterns to give a good
/// error message when parsing mistakes like ref foo(a,b)
Parse ident or ident @ pat
used by the copy foo and ref foo patterns to give a good
error message when parsing mistakes like ref foo(a,b)
Parse ident or ident @ pat used by the copy foo and ref foo patterns to give a good error message when parsing mistakes like ref foo ( a b )
fn parse_pat_ident(&mut self,
                       binding_mode: ast::BindingMode)
                       -> PResult<'a, PatKind> {
        if !self.token.is_plain_ident() {
            let span = self.span;
            let tok_str = self.this_token_to_string();
            return Err(self.span_fatal(span,
                            &format!("expected identifier, found `{}`", tok_str)))
        }
        let ident = try!(self.parse_ident());
        let last_span = self.last_span;
        let name = codemap::Spanned{span: last_span, node: ident};
        let sub = if self.eat(&token::At) {
            Some(try!(self.parse_pat()))
        } else {
            None
        };
        // just to be friendly, if they write something like
        //   ref Some(i)
        // we end up here with ( as the current token.  This shortly
        // leads to a parse error.  Note that if there is no explicit
        // binding mode then we do not end up here, because the lookahead
        // will direct us over to parse_enum_variant()
        if self.token == token::OpenDelim(token::Paren) {
            let last_span = self.last_span;
            return Err(self.span_fatal(
                last_span,
                "expected identifier, found enum pattern"))
        }
        Ok(PatKind::Ident(binding_mode, name, sub))
    }
fn parse_pat_ident ( & mut self , binding_mode : ast :: BindingMode ) -> PResult < ' a , PatKind > { if ! self . token . is_plain_ident ( ) { let span = self . span ; let tok_str = self . this_token_to_string ( ) ; return Err ( self . span_fatal ( span , & format ! ( " " tok_str ) ) ) } let ident = try ! ( self parse_ident ( ) ) ; let last_span = self . last_span ; let name = codemap :: Spanned { span : last_span , node : ident } ; let sub = if self . eat ( & token :: At ) { Some ( try ! ( self parse_pat ( ) ) ) } else { None } ; // just to be friendly, if they write something like //   ref Some(i) // we end up here with ( as the current token.  This shortly // leads to a parse error.  Note that if there is no explicit // binding mode then we do not end up here, because the lookahead // will direct us over to parse_enum_variant() if self . token == token :: OpenDelim ( token :: Paren ) { let last_span = self . last_span ; return Err ( self . span_fatal ( last_span , " " ) ) } Ok ( PatKind :: Ident ( binding_mode , name , sub ) ) }
Parse ident or ident @ pat
used by the copy foo and ref foo patterns to give a good
error message when parsing mistakes like ref foo(a,b)
Parse ident or ident @ pat used by the copy foo and ref foo patterns to give a good error message when parsing mistakes like ref foo ( a b )
&mut self
binding_mode
ast::BindingMode
&mut self
binding_mode
ast::BindingMode