@@ -5,6 +5,7 @@ use rustc::ty;
5
5
use rustc_front:: hir:: * ;
6
6
use rustc_front:: intravisit:: { FnKind , Visitor , walk_ty} ;
7
7
use rustc_front:: util:: { is_comparison_binop, binop_to_string} ;
8
+ use std:: cmp:: Ordering ;
8
9
use syntax:: ast:: { IntTy , UintTy , FloatTy } ;
9
10
use syntax:: codemap:: Span ;
10
11
use utils:: * ;
@@ -803,8 +804,6 @@ enum FullInt {
803
804
U ( u64 ) ,
804
805
}
805
806
806
- use std:: cmp:: Ordering ;
807
-
808
807
impl FullInt {
809
808
#[ allow( cast_sign_loss) ]
810
809
fn cmp_s_u ( s : i64 , u : u64 ) -> Ordering {
@@ -843,8 +842,7 @@ impl Ord for FullInt {
843
842
844
843
fn numeric_cast_precast_bounds < ' a > ( cx : & LateContext , expr : & ' a Expr ) -> Option < ( FullInt , FullInt ) > {
845
844
use rustc:: ty:: TypeVariants :: { TyInt , TyUint } ;
846
- use syntax:: ast:: UintTy ;
847
- use syntax:: ast:: IntTy ;
845
+ use syntax:: ast:: { IntTy , UintTy } ;
848
846
use std:: * ;
849
847
850
848
if let ExprCast ( ref cast_exp, _) = expr. node {
@@ -912,21 +910,21 @@ fn upcast_comparison_bounds_err(
912
910
lhs_bounds : Option < ( FullInt , FullInt ) > , lhs : & Expr , rhs : & Expr , invert : bool ) {
913
911
use utils:: comparisons:: * ;
914
912
915
- if let Some ( nlb ) = lhs_bounds {
913
+ if let Some ( ( lb , ub ) ) = lhs_bounds {
916
914
if let Some ( norm_rhs_val) = node_as_const_fullint ( cx, rhs) {
917
915
if rel == Rel :: Eq || rel == Rel :: Ne {
918
- if norm_rhs_val < nlb . 0 || norm_rhs_val > nlb . 0 {
916
+ if norm_rhs_val < lb || norm_rhs_val > ub {
919
917
err_upcast_comparison ( cx, & span, lhs, rel == Rel :: Ne ) ;
920
918
}
921
919
} else if match rel {
922
- Rel :: Lt => if invert { norm_rhs_val < nlb . 0 } else { nlb . 1 < norm_rhs_val } ,
923
- Rel :: Le => if invert { norm_rhs_val <= nlb . 0 } else { nlb . 1 <= norm_rhs_val } ,
920
+ Rel :: Lt => if invert { norm_rhs_val < lb } else { ub < norm_rhs_val } ,
921
+ Rel :: Le => if invert { norm_rhs_val <= lb } else { ub <= norm_rhs_val } ,
924
922
Rel :: Eq | Rel :: Ne => unreachable ! ( ) ,
925
923
} {
926
924
err_upcast_comparison ( cx, & span, lhs, true )
927
925
} else if match rel {
928
- Rel :: Lt => if invert { norm_rhs_val >= nlb . 1 } else { nlb . 0 >= norm_rhs_val } ,
929
- Rel :: Le => if invert { norm_rhs_val > nlb . 1 } else { nlb . 0 > norm_rhs_val } ,
926
+ Rel :: Lt => if invert { norm_rhs_val >= ub } else { lb >= norm_rhs_val } ,
927
+ Rel :: Le => if invert { norm_rhs_val > ub } else { lb > norm_rhs_val } ,
930
928
Rel :: Eq | Rel :: Ne => unreachable ! ( ) ,
931
929
} {
932
930
err_upcast_comparison ( cx, & span, lhs, false )
0 commit comments