fn parse_impl_method(&mut self, vis: Visibility)
                         -> PResult<'a, (Ident, Vec<ast::Attribute>, ast::ImplItemKind)> {
        // code copied from parse_macro_use_or_failure... abstraction!
        if !self.token.is_any_keyword()
            && self.look_ahead(1, |t| *t == token::Not)
            && (self.look_ahead(2, |t| *t == token::OpenDelim(token::Paren))
                || self.look_ahead(2, |t| *t == token::OpenDelim(token::Brace))) {
            // method macro.

            let last_span = self.last_span;
            self.complain_if_pub_macro(vis, last_span);

            let lo = self.span.lo;
            let pth = try!(self.parse_path(NoTypesAllowed));
            try!(self.expect(&token::Not));

            // eat a matched-delimiter token tree:
            let delim = try!(self.expect_open_delim());
            let tts = try!(self.parse_seq_to_end(&token::CloseDelim(delim),
                                                 SeqSep::none(),
                                                 |p| p.parse_token_tree()));
            let m_ = Mac_ { path: pth, tts: tts, ctxt: EMPTY_CTXT };
            let m: ast::Mac = codemap::Spanned { node: m_,
                                                span: mk_sp(lo,
                                                            self.last_span.hi) };
            if delim != token::Brace {
                try!(self.expect(&token::Semi))
            }
            Ok((token::special_idents::invalid, vec![], ast::ImplItemKind::Macro(m)))
        } else {
            let (constness, unsafety, abi) = try!(self.parse_fn_front_matter());
            let ident = try!(self.parse_ident());
            let mut generics = try!(self.parse_generics());
            let (explicit_self, decl) = try!(self.parse_fn_decl_with_self(|p| {
                    p.parse_arg()
                }));
            generics.where_clause = try!(self.parse_where_clause());
            let (inner_attrs, body) = try!(self.parse_inner_attrs_and_block());
            Ok((ident, inner_attrs, ast::ImplItemKind::Method(ast::MethodSig {
                generics: generics,
                abi: abi,
                explicit_self: explicit_self,
                unsafety: unsafety,
                constness: constness,
                decl: decl
             }, body)))
        }
    }
/// Parse a method or a macro invocation in a trait impl.
Parse a method or a macro invocation in a trait impl.
Parse a method or a macro invocation in a trait impl .
fn parse_impl_method(&mut self, vis: Visibility)
                         -> PResult<'a, (Ident, Vec<ast::Attribute>, ast::ImplItemKind)> {
        // code copied from parse_macro_use_or_failure... abstraction!
        if !self.token.is_any_keyword()
            && self.look_ahead(1, |t| *t == token::Not)
            && (self.look_ahead(2, |t| *t == token::OpenDelim(token::Paren))
                || self.look_ahead(2, |t| *t == token::OpenDelim(token::Brace))) {
            // method macro.
            let last_span = self.last_span;
            self.complain_if_pub_macro(vis, last_span);
            let lo = self.span.lo;
            let pth = try!(self.parse_path(NoTypesAllowed));
            try!(self.expect(&token::Not));
            // eat a matched-delimiter token tree:
            let delim = try!(self.expect_open_delim());
            let tts = try!(self.parse_seq_to_end(&token::CloseDelim(delim),
                                                 SeqSep::none(),
                                                 |p| p.parse_token_tree()));
            let m_ = Mac_ { path: pth, tts: tts, ctxt: EMPTY_CTXT };
            let m: ast::Mac = codemap::Spanned { node: m_,
                                                span: mk_sp(lo,
                                                            self.last_span.hi) };
            if delim != token::Brace {
                try!(self.expect(&token::Semi))
            }
            Ok((token::special_idents::invalid, vec![], ast::ImplItemKind::Macro(m)))
        } else {
            let (constness, unsafety, abi) = try!(self.parse_fn_front_matter());
            let ident = try!(self.parse_ident());
            let mut generics = try!(self.parse_generics());
            let (explicit_self, decl) = try!(self.parse_fn_decl_with_self(|p| {
                    p.parse_arg()
                }));
            generics.where_clause = try!(self.parse_where_clause());
            let (inner_attrs, body) = try!(self.parse_inner_attrs_and_block());
            Ok((ident, inner_attrs, ast::ImplItemKind::Method(ast::MethodSig {
                generics: generics,
                abi: abi,
                explicit_self: explicit_self,
                unsafety: unsafety,
                constness: constness,
                decl: decl
             }, body)))
        }
    }
fn parse_impl_method ( & mut self , vis : Visibility ) -> PResult < ' a , ( Ident , Vec < ast :: Attribute > , ast :: ImplItemKind ) > { // code copied from parse_macro_use_or_failure... abstraction! if ! self . token . is_any_keyword ( ) && self . look_ahead ( 1 , | t | * t == token :: Not ) && ( self . look_ahead ( 2 , | t | * t == token :: OpenDelim ( token :: Paren ) ) || self . look_ahead ( 2 , | t | * t == token :: OpenDelim ( token :: Brace ) ) ) { // method macro. let last_span = self . last_span ; self . complain_if_pub_macro ( vis , last_span ) ; let lo = self . span . lo ; let pth = try ! ( self parse_path ( NoTypesAllowed ) ) ; try ! ( self expect ( token Not ) ) ; // eat a matched-delimiter token tree: let delim = try ! ( self expect_open_delim ( ) ) ; let tts = try ! ( self parse_seq_to_end ( token CloseDelim ( delim ) SeqSep none ( ) p p parse_token_tree ( ) ) ) ; let m_ = Mac_ { path : pth , tts : tts , ctxt : EMPTY_CTXT } ; let m : ast :: Mac = codemap :: Spanned { node : m_ , span : mk_sp ( lo , self . last_span . hi ) } ; if delim != token :: Brace { try ! ( self expect ( token Semi ) ) } Ok ( ( token :: special_idents :: invalid , vec ! [ ] , ast :: ImplItemKind :: Macro ( m ) ) ) } else { let ( constness , unsafety , abi ) = try ! ( self parse_fn_front_matter ( ) ) ; let ident = try ! ( self parse_ident ( ) ) ; let mut generics = try ! ( self parse_generics ( ) ) ; let ( explicit_self , decl ) = try ! ( self parse_fn_decl_with_self ( p { p parse_arg ( ) } ) ) ; generics . where_clause = try ! ( self parse_where_clause ( ) ) ; let ( inner_attrs , body ) = try ! ( self parse_inner_attrs_and_block ( ) ) ; Ok ( ( ident , inner_attrs , ast :: ImplItemKind :: Method ( ast :: MethodSig { generics : generics , abi : abi , explicit_self : explicit_self , unsafety : unsafety , constness : constness , decl : decl } , body ) ) ) } }
Parse a method or a macro invocation in a trait impl.
Parse a method or a macro invocation in a trait impl .
&mut self
vis
Visibility
&mut self
vis
Visibility