2015-05-06 03:01:49 -05:00
|
|
|
#![feature(plugin)]
|
|
|
|
#![plugin(clippy)]
|
|
|
|
|
|
|
|
use std::ops::Add;
|
|
|
|
|
|
|
|
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 {
|
2015-08-11 13:22:20 -05:00
|
|
|
x + x
|
2015-05-06 03:01:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[deny(float_cmp)]
|
|
|
|
#[allow(unused)]
|
|
|
|
fn main() {
|
2015-08-13 01:12:07 -05:00
|
|
|
ZERO == 0f32; //~ERROR ==-comparison of f32 or f64
|
|
|
|
ZERO == 0.0; //~ERROR ==-comparison of f32 or f64
|
|
|
|
ZERO + ZERO != 1.0; //~ERROR !=-comparison of f32 or f64
|
2015-08-11 13:22:20 -05:00
|
|
|
|
|
|
|
ONE != 0.0; //~ERROR
|
2015-08-13 01:12:07 -05:00
|
|
|
twice(ONE) != ONE; //~ERROR !=-comparison of f32 or f64
|
|
|
|
ONE as f64 != 0.0; //~ERROR !=-comparison of f32 or f64
|
2015-08-11 13:22:20 -05:00
|
|
|
|
|
|
|
let x : f64 = 1.0;
|
|
|
|
|
2015-08-13 01:12:07 -05:00
|
|
|
x == 1.0; //~ERROR ==-comparison of f32 or f64
|
|
|
|
x != 0f64; //~ERROR !=-comparison of f32 or f64
|
2015-08-11 13:22:20 -05:00
|
|
|
|
2015-08-13 01:12:07 -05:00
|
|
|
twice(x) != twice(ONE as f64); //~ERROR !=-comparison of f32 or f64
|
2015-08-11 13:22:20 -05:00
|
|
|
|
|
|
|
x < 0.0;
|
|
|
|
x > 0.0;
|
|
|
|
x <= 0.0;
|
|
|
|
x >= 0.0;
|
2015-05-06 03:01:49 -05:00
|
|
|
}
|