Closed dtolnay closed 2 months ago
let is not valid as an expression on its own:
let
macro_rules! expr { ($e:expr) => {}; } expr!(let _ = Struct {});
error: no rules expected the token `let` --> src/lib.rs:4:7 | 1 | macro_rules! expr { | ----------------- when calling this macro ... 4 | expr!(let _ = Struct {}); | ^^^ no rules expected this token in macro call
It is only allowed in combination with something like if let … or while let … or if foo() && let …, and none of those allow { in the let expression.
if let …
while let …
if foo() && let …
{
But match … { … if let … => … } (match guards) does allow it.
match … { … if let … => … }
Closes #1670.
let
is not valid as an expression on its own:It is only allowed in combination with something like
if let …
orwhile let …
orif foo() && let …
, and none of those allow{
in thelet
expression.But
match … { … if let … => … }
(match guards) does allow it.Closes #1670.