]> git.proxmox.com Git - rustc.git/blame - src/test/compile-fail/issue-41255.rs
New upstream version 1.23.0+dfsg1
[rustc.git] / src / test / compile-fail / issue-41255.rs
CommitLineData
7cac9316
XL
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.
4//
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.
10
11// Matching against float literals should result in a linter error
12
13#![feature(slice_patterns)]
14#![feature(exclusive_range_pattern)]
15#![allow(unused)]
16#![forbid(illegal_floating_point_literal_pattern)]
17
18fn main() {
19 let x = 42.0;
20 match x {
21 5.0 => {}, //~ ERROR floating-point literals cannot be used
22 //~| WARNING hard error
23 5.0f32 => {}, //~ ERROR floating-point literals cannot be used
24 //~| WARNING hard error
25 -5.0 => {}, //~ ERROR floating-point literals cannot be used
26 //~| WARNING hard error
27 1.0 .. 33.0 => {}, //~ ERROR floating-point literals cannot be used
28 //~| WARNING hard error
29 //~| ERROR floating-point literals cannot be used
30 //~| WARNING hard error
31 39.0 ... 70.0 => {}, //~ ERROR floating-point literals cannot be used
32 //~| WARNING hard error
33 //~| ERROR floating-point literals cannot be used
34 //~| WARNING hard error
35 _ => {},
36 };
37 let y = 5.0;
38 // Same for tuples
39 match (x, 5) {
40 (3.14, 1) => {}, //~ ERROR floating-point literals cannot be used
41 //~| WARNING hard error
7cac9316
XL
42 _ => {},
43 }
44 // Or structs
45 struct Foo { x: f32 };
46 match (Foo { x }) {
47 Foo { x: 2.0 } => {}, //~ ERROR floating-point literals cannot be used
48 //~| WARNING hard error
7cac9316
XL
49 _ => {},
50 }
51}