@@ -172,7 +172,7 @@ use rustc::ty::{self, subst::SubstsRef, Ty, TyCtxt, TypeFoldable, Const};
172172use rustc:: ty:: layout:: { Integer , IntegerExt , VariantIdx , Size } ;
173173
174174use rustc:: mir:: Field ;
175- use rustc:: mir:: interpret:: { ConstValue , Scalar } ;
175+ use rustc:: mir:: interpret:: { ConstValue , Scalar , truncate } ;
176176use rustc:: util:: common:: ErrorReported ;
177177
178178use syntax:: attr:: { SignedInt , UnsignedInt } ;
@@ -678,16 +678,14 @@ fn all_constructors<'a, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
678678 ]
679679 }
680680 ty:: Int ( ity) => {
681- // FIXME(49937): refactor these bit manipulations into interpret.
682681 let bits = Integer :: from_attr ( & cx. tcx , SignedInt ( ity) ) . size ( ) . bits ( ) as u128 ;
683682 let min = 1u128 << ( bits - 1 ) ;
684- let max = ( 1u128 << ( bits - 1 ) ) - 1 ;
683+ let max = min - 1 ;
685684 vec ! [ ConstantRange ( min, max, pcx. ty, RangeEnd :: Included ) ]
686685 }
687686 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) ;
691689 vec ! [ ConstantRange ( 0 , max, pcx. ty, RangeEnd :: Included ) ]
692690 }
693691 _ => {
0 commit comments