rust/src/test/compile-fail/issue-6804.rs
Chris Morgan d9874c0885 Rename the NaN and is_NaN methods to lowercase.
This is for consistency in naming conventions.

- ``std::num::Float::NaN()`` is changed to ``nan()``;
- ``std::num::Float.is_NaN()`` is changed to ``is_nan()``; and
- ``std::num::strconv::NumStrConv::NaN()`` is changed to ``nan()``.

Fixes #9319.
2013-09-19 23:59:51 +10:00

22 lines
541 B
Rust

// Matching against NaN should result in a warning
use std::float::NaN;
fn main() {
let x = NaN;
match x {
NaN => {},
_ => {},
};
//~^^^ WARNING unmatchable NaN in pattern, use the is_nan method in a guard instead
match [x, 1.0] {
[NaN, _] => {},
_ => {},
};
//~^^^ WARNING unmatchable NaN in pattern, use the is_nan method in a guard instead
}
// At least one error is needed so that compilation fails
#[static_assert]
static b: bool = false; //~ ERROR static assertion failed