Stop parsing capture clauses

This commit is contained in:
Ben Striegel 2013-02-25 19:49:28 -05:00
parent 4b9b32839e
commit abc4ea2001
2 changed files with 20 additions and 53 deletions

View File

@ -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 {
@ -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> {
@ -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();

View File

@ -1,15 +0,0 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// error-pattern: warning: Captured variable 'y' not used in closure
pub fn main() {
let x = 5;
let _y = fn~(copy x) { };
}