rust/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-6804.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

22 lines
572 B
Rust
Raw Normal View History

2016-10-26 16:38:18 -05:00
// Matching against NaN should result in a warning
#![allow(unused)]
2018-01-16 02:31:48 -06:00
#![deny(illegal_floating_point_literal_pattern)]
const NAN: f64 = f64::NAN;
2016-10-26 16:38:18 -05:00
fn main() {
let x = NAN;
match x {
2018-01-16 02:31:48 -06:00
NAN => {}, //~ ERROR floating-point types cannot be used
//~| WARN this was previously accepted by the compiler but is being phased out
2016-10-26 16:38:18 -05:00
_ => {},
};
match [x, 1.0] {
2018-01-16 02:31:48 -06:00
[NAN, _] => {}, //~ ERROR floating-point types cannot be used
2020-01-08 11:02:10 -06:00
//~| WARN this was previously accepted by the compiler but is being phased out
2016-10-26 16:38:18 -05:00
_ => {},
};
}