Stop parsing capture clauses
This commit is contained in:
parent
4b9b32839e
commit
abc4ea2001
@ -748,18 +748,6 @@ fn is_named_argument() -> bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
// This version of parse arg doesn't necessarily require
|
||||||
// identifier names.
|
// identifier names.
|
||||||
fn parse_arg_general(require_name: bool) -> arg {
|
fn parse_arg_general(require_name: bool) -> arg {
|
||||||
@ -788,32 +776,26 @@ fn parse_arg() -> arg_or_capture_item {
|
|||||||
either::Left(self.parse_arg_general(true))
|
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 {
|
fn parse_fn_block_arg() -> arg_or_capture_item {
|
||||||
do self.parse_capture_item_or |p| {
|
let m = self.parse_arg_mode();
|
||||||
let m = p.parse_arg_mode();
|
let is_mutbl = self.eat_keyword(~"mut");
|
||||||
let is_mutbl = self.eat_keyword(~"mut");
|
let pat = self.parse_pat(false);
|
||||||
let pat = p.parse_pat(false);
|
let t = if self.eat(token::COLON) {
|
||||||
let t = if p.eat(token::COLON) {
|
self.parse_ty(false)
|
||||||
p.parse_ty(false)
|
} else {
|
||||||
} else {
|
@Ty {
|
||||||
@Ty {
|
id: self.get_id(),
|
||||||
id: p.get_id(),
|
node: ty_infer,
|
||||||
node: ty_infer,
|
span: mk_sp(self.span.lo, self.span.hi),
|
||||||
span: mk_sp(p.span.lo, p.span.hi),
|
}
|
||||||
}
|
};
|
||||||
};
|
either::Left(ast::arg {
|
||||||
either::Left(ast::arg {
|
mode: m,
|
||||||
mode: m,
|
is_mutbl: is_mutbl,
|
||||||
is_mutbl: is_mutbl,
|
ty: t,
|
||||||
ty: t,
|
pat: pat,
|
||||||
pat: pat,
|
id: self.get_id()
|
||||||
id: p.get_id()
|
})
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn maybe_parse_fixed_vstore_with_star() -> Option<uint> {
|
fn maybe_parse_fixed_vstore_with_star() -> Option<uint> {
|
||||||
@ -1722,7 +1704,7 @@ fn parse_fn_expr(sigil: Sigil) -> @expr {
|
|||||||
|
|
||||||
// if we want to allow fn expression argument types to be inferred in
|
// 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.
|
// 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();
|
let body = self.parse_block();
|
||||||
|
|
||||||
|
@ -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) { };
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user