Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion compiler/rustc_parse/src/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -785,9 +785,13 @@ impl<'a> Parser<'a> {
ExprKind::Call(_, _) => "a function call",
ExprKind::Await(_, _) => "`.await`",
ExprKind::Use(_, _) => "`.use`",
ExprKind::Yield(YieldKind::Postfix(_)) => "`.yield`",
ExprKind::Match(_, _, MatchKind::Postfix) => "a postfix match",
ExprKind::Err(_) => return Ok(with_postfix),
_ => unreachable!("parse_dot_or_call_expr_with_ shouldn't produce this"),
_ => unreachable!(
"did not expect {:?} as an illegal postfix operator following cast",
with_postfix.kind
),
}
);
let mut err = self.dcx().struct_span_err(span, msg);
Expand Down
10 changes: 10 additions & 0 deletions tests/ui/coroutine/postfix-yield-after-cast.rs
Original file line number Diff line number Diff line change
@@ -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`
};
}
13 changes: 13 additions & 0 deletions tests/ui/coroutine/postfix-yield-after-cast.stderr
Original file line number Diff line number Diff line change
@@ -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

Loading