Skip to content

Stop parsing capture clauses #5109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 20 additions & 38 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -748,18 +748,6 @@ pub impl Parser {
}
}

fn parse_capture_item_or(parse_arg_fn: fn(Parser) -> arg_or_capture_item)
-> arg_or_capture_item
{
if self.eat_keyword(~"copy") {
// XXX outdated syntax now that moves-based-on-type has gone in
self.parse_ident();
either::Right(())
} else {
parse_arg_fn(self)
}
}

// This version of parse arg doesn't necessarily require
// identifier names.
fn parse_arg_general(require_name: bool) -> arg {
Expand Down Expand Up @@ -788,32 +776,26 @@ pub impl Parser {
either::Left(self.parse_arg_general(true))
}

fn parse_arg_or_capture_item() -> arg_or_capture_item {
self.parse_capture_item_or(|p| p.parse_arg())
}

fn parse_fn_block_arg() -> arg_or_capture_item {
do self.parse_capture_item_or |p| {
let m = p.parse_arg_mode();
let is_mutbl = self.eat_keyword(~"mut");
let pat = p.parse_pat(false);
let t = if p.eat(token::COLON) {
p.parse_ty(false)
} else {
@Ty {
id: p.get_id(),
node: ty_infer,
span: mk_sp(p.span.lo, p.span.hi),
}
};
either::Left(ast::arg {
mode: m,
is_mutbl: is_mutbl,
ty: t,
pat: pat,
id: p.get_id()
})
}
let m = self.parse_arg_mode();
let is_mutbl = self.eat_keyword(~"mut");
let pat = self.parse_pat(false);
let t = if self.eat(token::COLON) {
self.parse_ty(false)
} else {
@Ty {
id: self.get_id(),
node: ty_infer,
span: mk_sp(self.span.lo, self.span.hi),
}
};
either::Left(ast::arg {
mode: m,
is_mutbl: is_mutbl,
ty: t,
pat: pat,
id: self.get_id()
})
}

fn maybe_parse_fixed_vstore_with_star() -> Option<uint> {
Expand Down Expand Up @@ -1722,7 +1704,7 @@ pub impl Parser {

// if we want to allow fn expression argument types to be inferred in
// the future, just have to change parse_arg to parse_fn_block_arg.
let decl = self.parse_fn_decl(|p| p.parse_arg_or_capture_item());
let decl = self.parse_fn_decl(|p| p.parse_arg());

let body = self.parse_block();

Expand Down
15 changes: 0 additions & 15 deletions src/test/run-pass/cap-clause-not-used.rs

This file was deleted.