about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-03-04 17:31:08 +0100
committerGitHub <noreply@github.com>2022-03-04 17:31:08 +0100
commitf9b4976d60b51d6006c869e6362ce5b178e0f55e (patch)
tree24e6d7a0b9f63577c0a620a2035da801f0a13eb9 /src/test
parent4014e159c902f2ceba9274b8d2c0d83a899b989b (diff)
parent004f2ed219378235c24a5d6bdb34337200e6eeed (diff)
downloadrust-f9b4976d60b51d6006c869e6362ce5b178e0f55e.tar.gz
rust-f9b4976d60b51d6006c869e6362ce5b178e0f55e.zip
Rollup merge of #94593 - estebank:issue-94510, r=davidtwco
Do not recover from `Ty?` in macro parsing

Follow up to #92746. Address #94510.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/parser/trailing-question-in-macro-type.rs14
-rw-r--r--src/test/ui/parser/trailing-question-in-macro-type.stderr9
2 files changed, 23 insertions, 0 deletions
diff --git a/src/test/ui/parser/trailing-question-in-macro-type.rs b/src/test/ui/parser/trailing-question-in-macro-type.rs
new file mode 100644
index 00000000000..e2a681ddd11
--- /dev/null
+++ b/src/test/ui/parser/trailing-question-in-macro-type.rs
@@ -0,0 +1,14 @@
+macro_rules! fn_expr {
+    ($return_type:ty : $body:expr) => {
+        (|| -> $return_type { $body })()
+    };
+    ($body:expr) => {
+        (|| $body)()
+    };
+}
+
+
+fn main() {
+    fn_expr!{ o?.when(|&i| i > 0)?.when(|&i| i%2 == 0) };
+    //~^ ERROR cannot find value `o` in this scope
+}
diff --git a/src/test/ui/parser/trailing-question-in-macro-type.stderr b/src/test/ui/parser/trailing-question-in-macro-type.stderr
new file mode 100644
index 00000000000..c096ae04fbb
--- /dev/null
+++ b/src/test/ui/parser/trailing-question-in-macro-type.stderr
@@ -0,0 +1,9 @@
+error[E0425]: cannot find value `o` in this scope
+  --> $DIR/trailing-question-in-macro-type.rs:12:15
+   |
+LL |     fn_expr!{ o?.when(|&i| i > 0)?.when(|&i| i%2 == 0) };
+   |               ^ not found in this scope
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0425`.