@@ -172,7 +172,7 @@ use rustc::ty::{self, subst::SubstsRef, Ty, TyCtxt, TypeFoldable, Const};
172
172
use rustc:: ty:: layout:: { Integer , IntegerExt , VariantIdx , Size } ;
173
173
174
174
use rustc:: mir:: Field ;
175
- use rustc:: mir:: interpret:: { ConstValue , Scalar } ;
175
+ use rustc:: mir:: interpret:: { ConstValue , Scalar , truncate } ;
176
176
use rustc:: util:: common:: ErrorReported ;
177
177
178
178
use syntax:: attr:: { SignedInt , UnsignedInt } ;
@@ -678,16 +678,14 @@ fn all_constructors<'a, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
678
678
]
679
679
}
680
680
ty:: Int ( ity) => {
681
- // FIXME(49937): refactor these bit manipulations into interpret.
682
681
let bits = Integer :: from_attr ( & cx. tcx , SignedInt ( ity) ) . size ( ) . bits ( ) as u128 ;
683
682
let min = 1u128 << ( bits - 1 ) ;
684
- let max = ( 1u128 << ( bits - 1 ) ) - 1 ;
683
+ let max = min - 1 ;
685
684
vec ! [ ConstantRange ( min, max, pcx. ty, RangeEnd :: Included ) ]
686
685
}
687
686
ty:: Uint ( uty) => {
688
- // FIXME(49937): refactor these bit manipulations into interpret.
689
- let bits = Integer :: from_attr ( & cx. tcx , UnsignedInt ( uty) ) . size ( ) . bits ( ) as u128 ;
690
- let max = !0u128 >> ( 128 - bits) ;
687
+ let size = Integer :: from_attr ( & cx. tcx , UnsignedInt ( uty) ) . size ( ) ;
688
+ let max = truncate ( u128:: max_value ( ) , size) ;
691
689
vec ! [ ConstantRange ( 0 , max, pcx. ty, RangeEnd :: Included ) ]
692
690
}
693
691
_ => {
0 commit comments