File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -46,4 +46,17 @@ fn main() {
4646 v != w;
4747 v == 1.0 ;
4848 v != 1.0 ;
49+
50+ const ZERO_ARRAY : [ f32 ; 3 ] = [ 0.0 , 0.0 , 0.0 ] ;
51+ const ZERO_INF_ARRAY : [ f32 ; 3 ] = [ 0.0 , :: std:: f32:: INFINITY , :: std:: f32:: NEG_INFINITY ] ;
52+ const NON_ZERO_ARRAY : [ f32 ; 3 ] = [ 0.0 , 0.1 , 0.2 ] ;
53+ const NON_ZERO_ARRAY2 : [ f32 ; 3 ] = [ 0.2 , 0.1 , 0.0 ] ;
54+
55+ // no errors, zero and infinity values
56+ NON_ZERO_ARRAY [ 0 ] == NON_ZERO_ARRAY2 [ 1 ] ; // lhs is 0.0
57+ ZERO_ARRAY == NON_ZERO_ARRAY ; // lhs is all zeros
58+ ZERO_INF_ARRAY == NON_ZERO_ARRAY ; // lhs is all zeros or infinities
59+
60+ // has errors
61+ NON_ZERO_ARRAY == NON_ZERO_ARRAY2 ;
4962}
Original file line number Diff line number Diff line change @@ -83,5 +83,17 @@ note: `f32::EPSILON` and `f64::EPSILON` are available.
8383LL | v != ONE;
8484 | ^^^^^^^^
8585
86- error: aborting due to 7 previous errors
86+ error: strict comparison of `f32` or `f64` constant
87+ --> $DIR/float_cmp_const.rs:61:5
88+ |
89+ LL | NON_ZERO_ARRAY == NON_ZERO_ARRAY2;
90+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
91+ |
92+ note: `std::f32::EPSILON` and `std::f64::EPSILON` are available.
93+ --> $DIR/float_cmp_const.rs:61:5
94+ |
95+ LL | NON_ZERO_ARRAY == NON_ZERO_ARRAY2;
96+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
97+
98+ error: aborting due to 8 previous errors
8799
You can’t perform that action at this time.
0 commit comments