Skip to content

Commit 9219d87

Browse files
authored
Unrolled build for #153548
Rollup merge of #153548 - cyrgani:closuretest, r=JohnTitor add test for closure precedence in `TokenStream`s A test for a regression found by the #151830 crater run in several different crates.
2 parents 052b9c2 + 1ff7ed5 commit 9219d87

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//! Make sure that the closure still gets the correct precedence when round-tripping
2+
//! through a proc macro.
3+
//! The correct precendence is `(|| ()) as fn()`, even though these parentheses are not
4+
//! directly part of the code.
5+
//! If it would get lost, the code would be `|| () as fn()`, get parsed as
6+
//! `|| (() as fn())` and fail to compile.
7+
//! Notably, this will also fail to compile if we use `recollect` instead of `identity`.
8+
//! Regression test for https://github.com/rust-lang/rust/pull/151830#issuecomment-4010899019.
9+
//@ proc-macro: test-macros.rs
10+
//@ check-pass
11+
12+
macro_rules! operator_impl {
13+
($target_expr:expr) => {
14+
test_macros::identity! {
15+
$target_expr as fn()
16+
};
17+
};
18+
}
19+
20+
fn main() {
21+
operator_impl!(|| ());
22+
}

0 commit comments

Comments
 (0)