Skip to content

Commit d1eb3b1

Browse files
Added regression test for issue rust-lang#67062
1 parent 852f15c commit d1eb3b1

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
extern crate proc_macro;
2+
3+
use proc_macro::{Literal, Punct, Spacing, TokenStream, TokenTree};
4+
5+
#[proc_macro]
6+
pub fn add_mul(input: TokenStream) -> TokenStream {
7+
let mul_2 = vec![
8+
TokenTree::from(Punct::new('*', Spacing::Alone)),
9+
TokenTree::from(Literal::u8_unsuffixed(2)),
10+
];
11+
input.into_iter().chain(mul_2.into_iter()).collect()
12+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//@ run-pass
2+
//@ proc-macro: delimiter-none-issue-67062.rs
3+
4+
// Regression test for #67062.
5+
6+
#[macro_use]
7+
extern crate delimiter_none_issue_67062;
8+
9+
macro_rules! mbe {
10+
($e: expr) => ( add_mul!($e) )
11+
}
12+
13+
fn main() {
14+
// Order of operations check. This should evalue to (2 + 2) * 2, but using
15+
// Delimiter::None instead of parentheses.
16+
let x = mbe!(2 + 2);
17+
assert_eq!(x, 8);
18+
}

0 commit comments

Comments
 (0)