parent
716f920b7e
commit
5a1b336a01
2 changed files with 22 additions and 4 deletions
|
@ -2026,7 +2026,8 @@ impl<'a> Parser<'a> {
|
||||||
return self.parse_block_expr(lo, DefaultBlock);
|
return self.parse_block_expr(lo, DefaultBlock);
|
||||||
},
|
},
|
||||||
token::BinOp(token::Or) | token::OrOr => {
|
token::BinOp(token::Or) | token::OrOr => {
|
||||||
return self.parse_lambda_expr(CaptureByRef);
|
let lo = self.span.lo;
|
||||||
|
return self.parse_lambda_expr(lo, CaptureByRef);
|
||||||
},
|
},
|
||||||
token::Ident(id @ ast::Ident {
|
token::Ident(id @ ast::Ident {
|
||||||
name: token::SELF_KEYWORD_NAME,
|
name: token::SELF_KEYWORD_NAME,
|
||||||
|
@ -2081,7 +2082,8 @@ impl<'a> Parser<'a> {
|
||||||
return Ok(self.mk_expr(lo, hi, ExprPath(Some(qself), path)));
|
return Ok(self.mk_expr(lo, hi, ExprPath(Some(qself), path)));
|
||||||
}
|
}
|
||||||
if try!(self.eat_keyword(keywords::Move) ){
|
if try!(self.eat_keyword(keywords::Move) ){
|
||||||
return self.parse_lambda_expr(CaptureByValue);
|
let lo = self.last_span.lo;
|
||||||
|
return self.parse_lambda_expr(lo, CaptureByValue);
|
||||||
}
|
}
|
||||||
if try!(self.eat_keyword(keywords::If)) {
|
if try!(self.eat_keyword(keywords::If)) {
|
||||||
return self.parse_if_expr();
|
return self.parse_if_expr();
|
||||||
|
@ -2840,10 +2842,9 @@ impl<'a> Parser<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// `|args| expr`
|
// `|args| expr`
|
||||||
pub fn parse_lambda_expr(&mut self, capture_clause: CaptureClause)
|
pub fn parse_lambda_expr(&mut self, lo: BytePos, capture_clause: CaptureClause)
|
||||||
-> PResult<P<Expr>>
|
-> PResult<P<Expr>>
|
||||||
{
|
{
|
||||||
let lo = self.span.lo;
|
|
||||||
let decl = try!(self.parse_fn_block_decl());
|
let decl = try!(self.parse_fn_block_decl());
|
||||||
let body = match decl.output {
|
let body = match decl.output {
|
||||||
DefaultReturn(_) => {
|
DefaultReturn(_) => {
|
||||||
|
|
17
src/test/compile-fail/move-closure-span.rs
Normal file
17
src/test/compile-fail/move-closure-span.rs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
// Copyright 2015 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.
|
||||||
|
|
||||||
|
// Make sure that the span of a closure marked `move` begins at the `move` keyword.
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let x: () =
|
||||||
|
move //~ ERROR mismatched types
|
||||||
|
|| ();
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue