Skip to content

Commit 28c9fda

Browse files
committedApr 12, 2016
Auto merge of #32711 - marcusklaas:try-shorthand-span-fix, r=nagisa
Fix the span for try shorthand expressions My five character contribution to the rust parser! Fixes #32709.
2 parents c0221c8 + 05e4116 commit 28c9fda

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed
 

‎src/libsyntax/parse/parser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2578,7 +2578,7 @@ impl<'a> Parser<'a> {
25782578
loop {
25792579
// expr?
25802580
while self.eat(&token::Question) {
2581-
let hi = self.span.hi;
2581+
let hi = self.last_span.hi;
25822582
e = self.mk_expr(lo, hi, ExprKind::Try(e), None);
25832583
}
25842584

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2016 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+
#![feature(question_mark)]
12+
13+
// Make sure that the span of try shorthand does not include the trailing
14+
// semicolon;
15+
fn a() -> Result<i32, ()> {
16+
Err(5)?; //~ ERROR 16:5: 16:12
17+
Ok(1)
18+
}
19+
20+
fn main() {}

0 commit comments

Comments
 (0)