]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/float_cmp.rs
Auto merge of #3603 - xfix:random-state-lint, r=phansch
[rust.git] / tests / ui / float_cmp.rs
index d5b02fb706f1c81d120f514d791096c38681d368..2d55e30a2d3d06319f1cf4fbce3abd14f27979cf 100644 (file)
@@ -1,27 +1,47 @@
-#![feature(tool_lints)]
-
+// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
 
 #![warn(clippy::float_cmp)]
 #![allow(unused, clippy::no_effect, clippy::unnecessary_operation, clippy::cast_lossless)]
 
 use std::ops::Add;
 
-const ZERO : f32 = 0.0;
-const ONE : f32 = ZERO + 1.0;
+const ZERO: f32 = 0.0;
+const ONE: f32 = ZERO + 1.0;
 
-fn twice<T>(x : T) -> T where T : Add<T, Output = T>, T : Copy {
+fn twice<T>(x: T) -> T
+where
+    T: Add<T, Output = T>,
+    T: Copy,
+{
     x + x
 }
 
 fn eq_fl(x: f32, y: f32) -> bool {
-    if x.is_nan() { y.is_nan() } else { x == y } // no error, inside "eq" fn
+    if x.is_nan() {
+        y.is_nan()
+    } else {
+        x == y
+    } // no error, inside "eq" fn
 }
 
 fn fl_eq(x: f32, y: f32) -> bool {
-    if x.is_nan() { y.is_nan() } else { x == y } // no error, inside "eq" fn
+    if x.is_nan() {
+        y.is_nan()
+    } else {
+        x == y
+    } // no error, inside "eq" fn
 }
 
-struct X { val: f32 }
+struct X {
+    val: f32,
+}
 
 impl PartialEq for X {
     fn eq(&self, o: &X) -> bool {
@@ -49,7 +69,7 @@ fn main() {
     ONE as f64 != 2.0;
     ONE as f64 != 0.0; // no error, comparison with zero is ok
 
-    let x : f64 = 1.0;
+    let x: f64 = 1.0;
 
     x == 1.0;
     x != 0f64; // no error, comparison with zero is ok
@@ -61,7 +81,7 @@ fn main() {
     x <= 0.0;
     x >= 0.0;
 
-    let xs : [f32; 1] = [0.0];
+    let xs: [f32; 1] = [0.0];
     let a: *const f32 = xs.as_ptr();
     let b: *const f32 = xs.as_ptr();