We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents cc0a60f + 1ff7ed5 commit 9886a13Copy full SHA for 9886a13
1 file changed
tests/ui/proc-macro/identity-closure-preserving.rs
@@ -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