Skip to content

Commit 4406717

Browse files
committed
Auto merge of #30723 - nrc:macro-err-bug, r=Manishearth
Fixes #30715
2 parents 3ed6e9e + 535282b commit 4406717

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

src/libsyntax/parse/parser.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2798,8 +2798,15 @@ impl<'a> Parser<'a> {
27982798
// We have 2 alternatives here: `x..y` and `x..` The other two variants are
27992799
// handled with `parse_prefix_range_expr` call above.
28002800
let rhs = if self.is_at_start_of_range_notation_rhs() {
2801-
self.parse_assoc_expr_with(op.precedence() + 1,
2802-
LhsExpr::NotYetParsed).ok()
2801+
let rhs = self.parse_assoc_expr_with(op.precedence() + 1,
2802+
LhsExpr::NotYetParsed);
2803+
match rhs {
2804+
Ok(e) => Some(e),
2805+
Err(mut e) => {
2806+
e.cancel();
2807+
None
2808+
}
2809+
}
28032810
} else {
28042811
None
28052812
};

src/test/compile-fail/issue-30715.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
macro_rules! parallel {
12+
(
13+
for $id:ident in $iter:expr {
14+
$( $inner:expr; )*
15+
}
16+
) => {};
17+
}
18+
19+
20+
fn main() {
21+
parallel! {
22+
for i in 0..n {
23+
x += i; //~ ERROR no rules expected the token `+=`
24+
}
25+
}
26+
}

0 commit comments

Comments
 (0)