1 // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // Matching against float literals should result in a linter error
13 #![feature(exclusive_range_pattern)]
15 #![forbid(illegal_floating_point_literal_pattern)]
20 5.0 => {}, //~ ERROR floating-point types cannot be used in patterns
21 //~| WARNING hard error
22 5.0f32 => {}, //~ ERROR floating-point types cannot be used in patterns
23 //~| WARNING hard error
24 -5.0 => {}, //~ ERROR floating-point types cannot be used in patterns
25 //~| WARNING hard error
26 1.0 .. 33.0 => {}, //~ ERROR floating-point types cannot be used in patterns
27 //~| WARNING hard error
28 //~| ERROR floating-point types cannot be used in patterns
29 //~| WARNING hard error
30 39.0 ..= 70.0 => {}, //~ ERROR floating-point types cannot be used in patterns
31 //~| WARNING hard error
32 //~| ERROR floating-point types cannot be used in patterns
33 //~| WARNING hard error
39 (3.14, 1) => {}, //~ ERROR floating-point types cannot be used
40 //~| WARNING hard error
44 struct Foo { x: f32 };
46 Foo { x: 2.0 } => {}, //~ ERROR floating-point types cannot be used
47 //~| WARNING hard error