rust/tests/ui/rfcs/rfc-2497-if-let-chains/auxiliary/macro-in-2021.rs
est31 eb1639bd33 Add tests to check the situation with heterogenous spans
The edition gate is a bit stricter than the drop behaviour,
which is fine. The cases we want to avoid are the opposite:
not gated but 2021 drop behaviour.
2025-04-18 15:57:29 +02:00

26 lines
566 B
Rust

//@ edition: 2021
#[macro_export]
macro_rules! make_if {
(($($tt:tt)*) { $body:expr } { $else:expr }) => {{
if $($tt)* {
$body
} else {
$else
}
}};
(let ($expr:expr) { $body:expr } { $else:expr }) => {{
if let None = $expr {
$body
} else {
$else
}
}};
(let ($expr:expr) let ($expr2:expr) { $body:expr } { $else:expr }) => {{
if let None = $expr && let None = $expr2 {
$body
} else {
$else
}
}};
}