Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow cast with trailing braced macro in let-else #125049

Merged
merged 3 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add test of trailing brace in a cast expression
  • Loading branch information
dtolnay committed May 12, 2024
commit 75a34ca26294cb79bd8b126c0fc18f4c207faaf0
14 changes: 14 additions & 0 deletions tests/ui/parser/bad-let-else-statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 196,18 @@ fn s() {
b!(2);
}

fn t() {
macro_rules! primitive {
(8) => { u8 };
}

let foo = &std::ptr::null as &'static dyn std::ops::Fn() -> *const primitive! {
//~^ WARN irrefutable `let...else` pattern
8
} else {
// FIXME: right curly brace `}` before `else` in a `let...else` statement not allowed
return;
};
}

fn main() {}
14 changes: 13 additions & 1 deletion tests/ui/parser/bad-let-else-statement.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -299,5 299,17 @@ LL | let bad = format_args! {""} else { return; };
= note: this pattern will always match, so the `else` clause is useless
= help: consider removing the `else` clause

error: aborting due to 19 previous errors; 4 warnings emitted
warning: irrefutable `let...else` pattern
--> $DIR/bad-let-else-statement.rs:204:5
|
LL | / let foo = &std::ptr::null as &'static dyn std::ops::Fn() -> *const primitive! {
LL | |
LL | | 8
LL | | } else {
| |_____^
|
= note: this pattern will always match, so the `else` clause is useless
= help: consider removing the `else` clause

error: aborting due to 19 previous errors; 5 warnings emitted