rust/src/test/ui/while-let.rs
varkor afcb938116 Stabilise irrefutable if-let and while-let patterns
This stabilises RFC 2086 (https://github.com/rust-lang/rust/issues/44495).

Co-Authored-By: Sebastian Malton <sebastian@malton.name>
2019-01-12 03:10:59 +00:00

29 lines
582 B
Rust

// run-pass
fn macros() {
macro_rules! foo{
($p:pat, $e:expr, $b:block) => {{
while let $p = $e $b
}}
}
macro_rules! bar{
($p:pat, $e:expr, $b:block) => {{
foo!($p, $e, $b)
}}
}
foo!(a, 1, { //~ WARN irrefutable while-let
println!("irrefutable pattern");
});
bar!(a, 1, { //~ WARN irrefutable while-let
println!("irrefutable pattern");
});
}
pub fn main() {
while let a = 1 { //~ WARN irrefutable while-let
println!("irrefutable pattern");
break;
}
}