Skip to content

Commit

Permalink
Add test of trailing brace in a cast expression
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed May 12, 2024
1 parent f493143 commit 75a34ca
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
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

0 comments on commit 75a34ca

Please sign in to comment.