about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/coroutine/postfix-yield-after-cast.rs10
-rw-r--r--tests/ui/coroutine/postfix-yield-after-cast.stderr13
2 files changed, 23 insertions, 0 deletions
diff --git a/tests/ui/coroutine/postfix-yield-after-cast.rs b/tests/ui/coroutine/postfix-yield-after-cast.rs
new file mode 100644
index 00000000000..472efb9f513
--- /dev/null
+++ b/tests/ui/coroutine/postfix-yield-after-cast.rs
@@ -0,0 +1,10 @@
+// Regression test for <https://github.com/rust-lang/rust/issues/144527>.
+
+#![feature(yield_expr, coroutines)]
+
+fn main() {
+    #[coroutine] || {
+        0 as u8.yield
+        //~^ ERROR cast cannot be followed by `.yield`
+    };
+}
diff --git a/tests/ui/coroutine/postfix-yield-after-cast.stderr b/tests/ui/coroutine/postfix-yield-after-cast.stderr
new file mode 100644
index 00000000000..a4de064fdf8
--- /dev/null
+++ b/tests/ui/coroutine/postfix-yield-after-cast.stderr
@@ -0,0 +1,13 @@
+error: cast cannot be followed by `.yield`
+  --> $DIR/postfix-yield-after-cast.rs:7:9
+   |
+LL |         0 as u8.yield
+   |         ^^^^^^^
+   |
+help: try surrounding the expression in parentheses
+   |
+LL |         (0 as u8).yield
+   |         +       +
+
+error: aborting due to 1 previous error
+