about summary refs log tree commit diff
path: root/src/test/ui/parser
diff options
context:
space:
mode:
authorEsteban Kuber <esteban@kuber.com.ar>2022-03-04 02:03:55 +0000
committerEsteban Kuber <esteban@kuber.com.ar>2022-03-04 02:03:55 +0000
commit004f2ed219378235c24a5d6bdb34337200e6eeed (patch)
tree522a9f7069f5099bda0f7f8077773baa2a61f86d /src/test/ui/parser
parent32cbc7630b2d6b7141e2588f91380c1a58cf0016 (diff)
downloadrust-004f2ed219378235c24a5d6bdb34337200e6eeed.tar.gz
rust-004f2ed219378235c24a5d6bdb34337200e6eeed.zip
Do not recover from `Ty?` in macro parsing
Follow up to #92746. Address #94510.
Diffstat (limited to 'src/test/ui/parser')
-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`.