@@ -1396,21 +1396,19 @@ impl<'tcx> IntRange<'tcx> {
13961396 ) -> Option < IntRange < ' tcx > > {
13971397 if let Some ( ( target_size, bias) ) = Self :: integral_size_and_signed_bias ( tcx, value. ty ) {
13981398 let ty = value. ty ;
1399- let val = if let ty:: ConstKind :: Value ( ConstValue :: Scalar ( Scalar :: Raw { data, size } ) ) =
1400- value. val
1401- {
1402- // For this specific pattern we can skip a lot of effort and go
1403- // straight to the result, after doing a bit of checking. (We
1404- // could remove this branch and just use the next branch, which
1405- // is more general but much slower.)
1406- Scalar :: < ( ) > :: check_raw ( data, size, target_size) ;
1407- data
1408- } else if let Some ( val) = value. try_eval_bits ( tcx, param_env, ty) {
1409- // This is a more general form of the previous branch.
1410- val
1411- } else {
1412- return None ;
1413- } ;
1399+ let val = ( || {
1400+ if let ty:: ConstKind :: Value ( ConstValue :: Scalar ( scalar) ) = value. val {
1401+ // For this specific pattern we can skip a lot of effort and go
1402+ // straight to the result, after doing a bit of checking. (We
1403+ // could remove this branch and just fall through, which
1404+ // is more general but much slower.)
1405+ if let Ok ( bits) = scalar. to_bits_or_ptr ( target_size, & tcx) {
1406+ return Some ( bits) ;
1407+ }
1408+ }
1409+ // This is a more general form of the previous case.
1410+ value. try_eval_bits ( tcx, param_env, ty)
1411+ } ) ( ) ?;
14141412 let val = val ^ bias;
14151413 Some ( IntRange { range : val..=val, ty, span } )
14161414 } else {
0 commit comments