pub fn parse_trait_items(&mut self) -> PResult<'a,  Vec<TraitItem>> {
        self.parse_unspanned_seq(
            &token::OpenDelim(token::Brace),
            &token::CloseDelim(token::Brace),
            SeqSep::none(),
            |p| -> PResult<'a, TraitItem> {
            maybe_whole!(no_clone_from_p p, NtTraitItem);
            let mut attrs = try!(p.parse_outer_attributes());
            let lo = p.span.lo;

            let (name, node) = if p.eat_keyword(keywords::Type) {
                let TyParam {ident, bounds, default, ..} = try!(p.parse_ty_param());
                try!(p.expect(&token::Semi));
                (ident, TraitItemKind::Type(bounds, default))
            } else if p.is_const_item() {
                try!(p.expect_keyword(keywords::Const));
                let ident = try!(p.parse_ident());
                try!(p.expect(&token::Colon));
                let ty = try!(p.parse_ty_sum());
                let default = if p.check(&token::Eq) {
                    p.bump();
                    let expr = try!(p.parse_expr());
                    try!(p.commit_expr_expecting(&expr, token::Semi));
                    Some(expr)
                } else {
                    try!(p.expect(&token::Semi));
                    None
                };
                (ident, TraitItemKind::Const(ty, default))
            } else {
                let (constness, unsafety, abi) = match p.parse_fn_front_matter() {
                    Ok(cua) => cua,
                    Err(e) => {
                        loop {
                            match p.token {
                                token::Eof => break,

                                token::CloseDelim(token::Brace) |
                                token::Semi => {
                                    p.bump();
                                    break;
                                }

                                token::OpenDelim(token::Brace) => {
                                    try!(p.parse_token_tree());
                                    break;
                                }

                                _ => p.bump()
                            }
                        }

                        return Err(e);
                    }
                };

                let ident = try!(p.parse_ident());
                let mut generics = try!(p.parse_generics());

                let (explicit_self, d) = try!(p.parse_fn_decl_with_self(|p: &mut Parser<'a>|{
                    // This is somewhat dubious; We don't want to allow
                    // argument names to be left off if there is a
                    // definition...
                    p.parse_arg_general(false)
                }));

                generics.where_clause = try!(p.parse_where_clause());
                let sig = ast::MethodSig {
                    unsafety: unsafety,
                    constness: constness,
                    decl: d,
                    generics: generics,
                    abi: abi,
                    explicit_self: explicit_self,
                };

                let body = match p.token {
                  token::Semi => {
                    p.bump();
                    debug!("parse_trait_methods(): parsing required method");
                    None
                  }
                  token::OpenDelim(token::Brace) => {
                    debug!("parse_trait_methods(): parsing provided method");
                    let (inner_attrs, body) =
                        try!(p.parse_inner_attrs_and_block());
                    attrs.extend(inner_attrs.iter().cloned());
                    Some(body)
                  }

                  _ => {
                      let token_str = p.this_token_to_string();
                      return Err(p.fatal(&format!("expected `;` or `{{`, found `{}`",
                                       token_str)[..]))
                  }
                };
                (ident, ast::TraitItemKind::Method(sig, body))
            };

            Ok(TraitItem {
                id: ast::DUMMY_NODE_ID,
                ident: name,
                attrs: attrs,
                node: node,
                span: mk_sp(lo, p.last_span.hi),
            })
        })
    }
/// Parse the items in a trait declaration
Parse the items in a trait declaration
Parse the items in a trait declaration
pub fn parse_trait_items(&mut self) -> PResult<'a,  Vec<TraitItem>> {
        self.parse_unspanned_seq(
            &token::OpenDelim(token::Brace),
            &token::CloseDelim(token::Brace),
            SeqSep::none(),
            |p| -> PResult<'a, TraitItem> {
            maybe_whole!(no_clone_from_p p, NtTraitItem);
            let mut attrs = try!(p.parse_outer_attributes());
            let lo = p.span.lo;
            let (name, node) = if p.eat_keyword(keywords::Type) {
                let TyParam {ident, bounds, default, ..} = try!(p.parse_ty_param());
                try!(p.expect(&token::Semi));
                (ident, TraitItemKind::Type(bounds, default))
            } else if p.is_const_item() {
                try!(p.expect_keyword(keywords::Const));
                let ident = try!(p.parse_ident());
                try!(p.expect(&token::Colon));
                let ty = try!(p.parse_ty_sum());
                let default = if p.check(&token::Eq) {
                    p.bump();
                    let expr = try!(p.parse_expr());
                    try!(p.commit_expr_expecting(&expr, token::Semi));
                    Some(expr)
                } else {
                    try!(p.expect(&token::Semi));
                    None
                };
                (ident, TraitItemKind::Const(ty, default))
            } else {
                let (constness, unsafety, abi) = match p.parse_fn_front_matter() {
                    Ok(cua) => cua,
                    Err(e) => {
                        loop {
                            match p.token {
                                token::Eof => break,
                                token::CloseDelim(token::Brace) |
                                token::Semi => {
                                    p.bump();
                                    break;
                                }
                                token::OpenDelim(token::Brace) => {
                                    try!(p.parse_token_tree());
                                    break;
                                }
                                _ => p.bump()
                            }
                        }
                        return Err(e);
                    }
                };
                let ident = try!(p.parse_ident());
                let mut generics = try!(p.parse_generics());
                let (explicit_self, d) = try!(p.parse_fn_decl_with_self(|p: &mut Parser<'a>|{
                    // This is somewhat dubious; We don't want to allow
                    // argument names to be left off if there is a
                    // definition...
                    p.parse_arg_general(false)
                }));
                generics.where_clause = try!(p.parse_where_clause());
                let sig = ast::MethodSig {
                    unsafety: unsafety,
                    constness: constness,
                    decl: d,
                    generics: generics,
                    abi: abi,
                    explicit_self: explicit_self,
                };
                let body = match p.token {
                  token::Semi => {
                    p.bump();
                    debug!("parse_trait_methods(): parsing required method");
                    None
                  }
                  token::OpenDelim(token::Brace) => {
                    debug!("parse_trait_methods(): parsing provided method");
                    let (inner_attrs, body) =
                        try!(p.parse_inner_attrs_and_block());
                    attrs.extend(inner_attrs.iter().cloned());
                    Some(body)
                  }
                  _ => {
                      let token_str = p.this_token_to_string();
                      return Err(p.fatal(&format!("expected `;` or `{{`, found `{}`",
                                       token_str)[..]))
                  }
                };
                (ident, ast::TraitItemKind::Method(sig, body))
            };
            Ok(TraitItem {
                id: ast::DUMMY_NODE_ID,
                ident: name,
                attrs: attrs,
                node: node,
                span: mk_sp(lo, p.last_span.hi),
            })
        })
    }
pub fn parse_trait_items ( & mut self ) -> PResult < ' a , Vec < TraitItem > > { self . parse_unspanned_seq ( & token :: OpenDelim ( token :: Brace ) , & token :: CloseDelim ( token :: Brace ) , SeqSep :: none ( ) , | p | -> PResult < ' a , TraitItem > { maybe_whole ! ( no_clone_from_p p NtTraitItem ) ; let mut attrs = try ! ( p parse_outer_attributes ( ) ) ; let lo = p . span . lo ; let ( name , node ) = if p . eat_keyword ( keywords :: Type ) { let TyParam { ident , bounds , default , .. } = try ! ( p parse_ty_param ( ) ) ; try ! ( p expect ( token Semi ) ) ; ( ident , TraitItemKind :: Type ( bounds , default ) ) } else if p . is_const_item ( ) { try ! ( p expect_keyword ( keywords Const ) ) ; let ident = try ! ( p parse_ident ( ) ) ; try ! ( p expect ( token Colon ) ) ; let ty = try ! ( p parse_ty_sum ( ) ) ; let default = if p . check ( & token :: Eq ) { p . bump ( ) ; let expr = try ! ( p parse_expr ( ) ) ; try ! ( p commit_expr_expecting ( expr token Semi ) ) ; Some ( expr ) } else { try ! ( p expect ( token Semi ) ) ; None } ; ( ident , TraitItemKind :: Const ( ty , default ) ) } else { let ( constness , unsafety , abi ) = match p . parse_fn_front_matter ( ) { Ok ( cua ) => cua , Err ( e ) => { loop { match p . token { token :: Eof => break , token :: CloseDelim ( token :: Brace ) | token :: Semi => { p . bump ( ) ; break ; } token :: OpenDelim ( token :: Brace ) => { try ! ( p parse_token_tree ( ) ) ; break ; } _ => p . bump ( ) } } return Err ( e ) ; } } ; let ident = try ! ( p parse_ident ( ) ) ; let mut generics = try ! ( p parse_generics ( ) ) ; let ( explicit_self , d ) = try ! ( p parse_fn_decl_with_self ( p mut Parser ' a { // This is somewhat dubious; We don't want to allow // argument names to be left off if there is a // definition... p parse_arg_general ( false ) } ) ) ; generics . where_clause = try ! ( p parse_where_clause ( ) ) ; let sig = ast :: MethodSig { unsafety : unsafety , constness : constness , decl : d , generics : generics , abi : abi , explicit_self : explicit_self , } ; let body = match p . token { token :: Semi => { p . bump ( ) ; debug ! ( " " ) ; None } token :: OpenDelim ( token :: Brace ) => { debug ! ( " " ) ; let ( inner_attrs , body ) = try ! ( p parse_inner_attrs_and_block ( ) ) ; attrs . extend ( inner_attrs . iter ( ) . cloned ( ) ) ; Some ( body ) } _ => { let token_str = p . this_token_to_string ( ) ; return Err ( p . fatal ( & format ! ( " " token_str ) [ .. ] ) ) } } ; ( ident , ast :: TraitItemKind :: Method ( sig , body ) ) } ; Ok ( TraitItem { id : ast :: DUMMY_NODE_ID , ident : name , attrs : attrs , node : node , span : mk_sp ( lo , p . last_span . hi ) , } ) } ) }
Parse the items in a trait declaration
Parse the items in a trait declaration
&mut self
&mut self