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