@@ -5,6 +5,7 @@ use rustc::ty;
55use rustc_front:: hir:: * ;
66use rustc_front:: intravisit:: { FnKind , Visitor , walk_ty} ;
77use rustc_front:: util:: { is_comparison_binop, binop_to_string} ;
8+ use std:: cmp:: Ordering ;
89use syntax:: ast:: { IntTy , UintTy , FloatTy } ;
910use syntax:: codemap:: Span ;
1011use utils:: * ;
@@ -803,8 +804,6 @@ enum FullInt {
803804 U ( u64 ) ,
804805}
805806
806- use std:: cmp:: Ordering ;
807-
808807impl FullInt {
809808 #[ allow( cast_sign_loss) ]
810809 fn cmp_s_u ( s : i64 , u : u64 ) -> Ordering {
@@ -843,8 +842,7 @@ impl Ord for FullInt {
843842
844843fn numeric_cast_precast_bounds < ' a > ( cx : & LateContext , expr : & ' a Expr ) -> Option < ( FullInt , FullInt ) > {
845844 use rustc:: ty:: TypeVariants :: { TyInt , TyUint } ;
846- use syntax:: ast:: UintTy ;
847- use syntax:: ast:: IntTy ;
845+ use syntax:: ast:: { IntTy , UintTy } ;
848846 use std:: * ;
849847
850848 if let ExprCast ( ref cast_exp, _) = expr. node {
@@ -912,21 +910,21 @@ fn upcast_comparison_bounds_err(
912910 lhs_bounds : Option < ( FullInt , FullInt ) > , lhs : & Expr , rhs : & Expr , invert : bool ) {
913911 use utils:: comparisons:: * ;
914912
915- if let Some ( nlb ) = lhs_bounds {
913+ if let Some ( ( lb , ub ) ) = lhs_bounds {
916914 if let Some ( norm_rhs_val) = node_as_const_fullint ( cx, rhs) {
917915 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 {
919917 err_upcast_comparison ( cx, & span, lhs, rel == Rel :: Ne ) ;
920918 }
921919 } 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 } ,
924922 Rel :: Eq | Rel :: Ne => unreachable ! ( ) ,
925923 } {
926924 err_upcast_comparison ( cx, & span, lhs, true )
927925 } 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 } ,
930928 Rel :: Eq | Rel :: Ne => unreachable ! ( ) ,
931929 } {
932930 err_upcast_comparison ( cx, & span, lhs, false )
0 commit comments