]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-41255.rs
Pass cflags rather than cxxflags to LLVM as CMAKE_C_FLAGS
[rust.git] / src / test / ui / issues / issue-41255.rs
1 // Matching against float literals should result in a linter error
2
3 #![feature(exclusive_range_pattern)]
4 #![allow(unused)]
5 #![forbid(illegal_floating_point_literal_pattern)]
6
7 fn main() {
8     let x = 42.0;
9     match x {
10         5.0 => {}, //~ ERROR floating-point types cannot be used in patterns
11                    //~| WARNING hard error
12                    //~| ERROR floating-point types cannot be used in patterns
13                    //~| WARNING this was previously accepted by the compiler but is being
14         5.0f32 => {}, //~ ERROR floating-point types cannot be used in patterns
15                       //~| WARNING hard error
16         -5.0 => {}, //~ ERROR floating-point types cannot be used in patterns
17                     //~| WARNING hard error
18         1.0 .. 33.0 => {}, //~ ERROR floating-point types cannot be used in patterns
19                            //~| WARNING hard error
20                            //~| ERROR floating-point types cannot be used in patterns
21                            //~| WARNING hard error
22         39.0 ..= 70.0 => {}, //~ ERROR floating-point types cannot be used in patterns
23                              //~| WARNING hard error
24                              //~| ERROR floating-point types cannot be used in patterns
25                              //~| WARNING hard error
26         _ => {},
27     };
28     let y = 5.0;
29     // Same for tuples
30     match (x, 5) {
31         (3.14, 1) => {}, //~ ERROR floating-point types cannot be used
32                          //~| WARNING hard error
33         _ => {},
34     }
35     // Or structs
36     struct Foo { x: f32 };
37     match (Foo { x }) {
38         Foo { x: 2.0 } => {}, //~ ERROR floating-point types cannot be used
39                               //~| WARNING hard error
40         _ => {},
41     }
42 }