Skip to content

Commit 7a52835

Browse files
committed
Auto merge of #25466 - P1start:move-closure-span, r=alexcrichton
Closes #24986.
2 parents daaf715 + 5a1b336 commit 7a52835

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

src/libsyntax/parse/parser.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2026,7 +2026,8 @@ impl<'a> Parser<'a> {
20262026
return self.parse_block_expr(lo, DefaultBlock);
20272027
},
20282028
token::BinOp(token::Or) | token::OrOr => {
2029-
return self.parse_lambda_expr(CaptureByRef);
2029+
let lo = self.span.lo;
2030+
return self.parse_lambda_expr(lo, CaptureByRef);
20302031
},
20312032
token::Ident(id @ ast::Ident {
20322033
name: token::SELF_KEYWORD_NAME,
@@ -2081,7 +2082,8 @@ impl<'a> Parser<'a> {
20812082
return Ok(self.mk_expr(lo, hi, ExprPath(Some(qself), path)));
20822083
}
20832084
if try!(self.eat_keyword(keywords::Move) ){
2084-
return self.parse_lambda_expr(CaptureByValue);
2085+
let lo = self.last_span.lo;
2086+
return self.parse_lambda_expr(lo, CaptureByValue);
20852087
}
20862088
if try!(self.eat_keyword(keywords::If)) {
20872089
return self.parse_if_expr();
@@ -2840,10 +2842,9 @@ impl<'a> Parser<'a> {
28402842
}
28412843

28422844
// `|args| expr`
2843-
pub fn parse_lambda_expr(&mut self, capture_clause: CaptureClause)
2845+
pub fn parse_lambda_expr(&mut self, lo: BytePos, capture_clause: CaptureClause)
28442846
-> PResult<P<Expr>>
28452847
{
2846-
let lo = self.span.lo;
28472848
let decl = try!(self.parse_fn_block_decl());
28482849
let body = match decl.output {
28492850
DefaultReturn(_) => {
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Make sure that the span of a closure marked `move` begins at the `move` keyword.
12+
13+
fn main() {
14+
let x: () =
15+
move //~ ERROR mismatched types
16+
|| ();
17+
}

0 commit comments

Comments
 (0)