Skip to content

Commit 3e4b701

Browse files
committed
Updated future-proofing test, removed outdated test, and added
run-pass test for some new functionality.
1 parent 3703ef5 commit 3e4b701

File tree

3 files changed

+28
-18
lines changed

3 files changed

+28
-18
lines changed

src/test/compile-fail/macro-input-future-proofing.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ macro_rules! errors_everywhere {
2525
($($ty:ty)* -) => (); //~ ERROR `$ty:ty` is followed by `-`
2626
($($a:ty, $b:ty)* -) => (); //~ ERROR `$b:ty` is followed by `-`
2727
($($ty:ty)-+) => (); //~ ERROR `$ty:ty` is followed by `-`, which is not allowed for `ty`
28+
( $($a:expr)* $($b:tt)* ) => { };
29+
//~^ ERROR `$a:expr` is followed by `$b:tt`, which is not allowed for `expr` fragments
2830
}
2931

3032
fn main() { }

src/test/compile-fail/macro-seq-followed-by-seq.rs

Lines changed: 0 additions & 18 deletions
This file was deleted.
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+
// Test of allowing two sequences repetitions in a row,
12+
// functionality added as byproduct of RFC amendment #1384
13+
// https://github.com/rust-lang/rfcs/pull/1384
14+
15+
// Old version of Rust would reject this macro definition, even though
16+
// there are no local ambiguities (the initial `banana` and `orange`
17+
// tokens are enough for the expander to distinguish which case is
18+
// intended).
19+
macro_rules! foo {
20+
( $(banana $a:ident)* $(orange $b:tt)* ) => { };
21+
}
22+
23+
fn main() {
24+
foo!( banana id1 banana id2
25+
orange hi orange (hello world) );
26+
}

0 commit comments

Comments
 (0)