mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 17:24:06 +00:00
refactor parse_fn_decl
This commit is contained in:
parent
2b7f1a4f24
commit
50a7f5483b
@ -259,7 +259,7 @@ pub impl Parser {
|
|||||||
fn try_parse_obsolete_struct_ctor(&self) -> bool {
|
fn try_parse_obsolete_struct_ctor(&self) -> bool {
|
||||||
if self.eat_obsolete_ident("new") {
|
if self.eat_obsolete_ident("new") {
|
||||||
self.obsolete(*self.last_span, ObsoleteStructCtor);
|
self.obsolete(*self.last_span, ObsoleteStructCtor);
|
||||||
self.parse_fn_decl(|p| p.parse_arg());
|
self.parse_fn_decl();
|
||||||
self.parse_block();
|
self.parse_block();
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
|
@ -2844,7 +2844,8 @@ pub impl Parser {
|
|||||||
(lifetimes, opt_vec::take_vec(result))
|
(lifetimes, opt_vec::take_vec(result))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_fn_decl(&self, parse_arg_fn: &fn(&Parser) -> arg_or_capture_item)
|
// parse the argument list and result type of a function declaration
|
||||||
|
fn parse_fn_decl(&self)
|
||||||
-> fn_decl
|
-> fn_decl
|
||||||
{
|
{
|
||||||
let args_or_capture_items: ~[arg_or_capture_item] =
|
let args_or_capture_items: ~[arg_or_capture_item] =
|
||||||
@ -2852,7 +2853,7 @@ pub impl Parser {
|
|||||||
&token::LPAREN,
|
&token::LPAREN,
|
||||||
&token::RPAREN,
|
&token::RPAREN,
|
||||||
seq_sep_trailing_disallowed(token::COMMA),
|
seq_sep_trailing_disallowed(token::COMMA),
|
||||||
parse_arg_fn
|
|p| p.parse_arg()
|
||||||
);
|
);
|
||||||
|
|
||||||
let inputs = either::lefts(args_or_capture_items);
|
let inputs = either::lefts(args_or_capture_items);
|
||||||
@ -3081,7 +3082,7 @@ pub impl Parser {
|
|||||||
// parse an item-position function declaration.
|
// parse an item-position function declaration.
|
||||||
fn parse_item_fn(&self, purity: purity, abis: AbiSet) -> item_info {
|
fn parse_item_fn(&self, purity: purity, abis: AbiSet) -> item_info {
|
||||||
let (ident, generics) = self.parse_fn_header();
|
let (ident, generics) = self.parse_fn_header();
|
||||||
let decl = self.parse_fn_decl(|p| p.parse_arg());
|
let decl = self.parse_fn_decl();
|
||||||
let (inner_attrs, body) = self.parse_inner_attrs_and_block(true);
|
let (inner_attrs, body) = self.parse_inner_attrs_and_block(true);
|
||||||
(ident,
|
(ident,
|
||||||
item_fn(decl, purity, abis, generics, body),
|
item_fn(decl, purity, abis, generics, body),
|
||||||
@ -3593,7 +3594,7 @@ pub impl Parser {
|
|||||||
let vis = self.parse_visibility();
|
let vis = self.parse_visibility();
|
||||||
let purity = self.parse_fn_purity();
|
let purity = self.parse_fn_purity();
|
||||||
let (ident, generics) = self.parse_fn_header();
|
let (ident, generics) = self.parse_fn_header();
|
||||||
let decl = self.parse_fn_decl(|p| p.parse_arg());
|
let decl = self.parse_fn_decl();
|
||||||
let hi = self.span.hi;
|
let hi = self.span.hi;
|
||||||
self.expect(&token::SEMI);
|
self.expect(&token::SEMI);
|
||||||
@ast::foreign_item { ident: ident,
|
@ast::foreign_item { ident: ident,
|
||||||
|
Loading…
Reference in New Issue
Block a user