Skip to content

Commit 484d119

Browse files
committed
Merge pull request #30853 from brson/beta-next2
[beta] Add test for "malformed macro lhs" and change back span_bug to span_f…
2 parents a55e0e8 + fabcb99 commit 484d119

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/libsyntax/ext/tt/macro_rules.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -175,15 +175,15 @@ fn generic_extension<'cx>(cx: &'cx ExtCtxt,
175175
for (i, lhs) in lhses.iter().enumerate() { // try each arm's matchers
176176
let lhs_tt = match *lhs {
177177
TokenTree::Delimited(_, ref delim) => &delim.tts[..],
178-
_ => cx.span_bug(sp, "malformed macro lhs")
178+
_ => cx.span_fatal(sp, "malformed macro lhs")
179179
};
180180

181181
match TokenTree::parse(cx, lhs_tt, arg) {
182182
Success(named_matches) => {
183183
let rhs = match rhses[i] {
184184
// ignore delimiters
185185
TokenTree::Delimited(_, ref delimed) => delimed.tts.clone(),
186-
_ => cx.span_bug(sp, "malformed macro rhs"),
186+
_ => cx.span_fatal(sp, "malformed macro rhs"),
187187
};
188188
// rhs has holes ( `$id` and `$(...)` that need filled)
189189
let trncbr = new_tt_reader(&cx.parse_sess().span_diagnostic,
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+
macro_rules! my_precioooous {
12+
$($t:tt)* => (1);
13+
}
14+
15+
fn main() {
16+
my_precioooous!(); //~ ERROR malformed macro lhs
17+
}

0 commit comments

Comments
 (0)