@@ -27,7 +27,6 @@ use tracing::{debug, instrument};
27
27
28
28
use crate :: builder:: ForGuard :: { self , OutsideGuard , RefWithinGuard } ;
29
29
use crate :: builder:: expr:: as_place:: PlaceBuilder ;
30
- use crate :: builder:: interpret:: ErrorHandled ;
31
30
use crate :: builder:: matches:: user_ty:: ProjectedUserTypesNode ;
32
31
use crate :: builder:: scope:: DropKind ;
33
32
use crate :: builder:: {
@@ -2908,18 +2907,18 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
2908
2907
fn eval_unevaluated_mir_constant_to_valtree (
2909
2908
& self ,
2910
2909
constant : ConstOperand < ' tcx > ,
2911
- ) -> Result < ( ty:: ValTree < ' tcx > , Ty < ' tcx > ) , ErrorHandled > {
2910
+ ) -> ( ty:: ValTree < ' tcx > , Ty < ' tcx > ) {
2912
2911
assert ! ( !constant. const_. ty( ) . has_param( ) ) ;
2913
2912
let ( uv, ty) = match constant. const_ {
2914
2913
mir:: Const :: Unevaluated ( uv, ty) => ( uv. shrink ( ) , ty) ,
2915
2914
mir:: Const :: Ty ( _, c) => match c. kind ( ) {
2916
2915
// A constant that came from a const generic but was then used as an argument to
2917
2916
// old-style simd_shuffle (passing as argument instead of as a generic param).
2918
- ty:: ConstKind :: Value ( cv) => return Ok ( ( cv. valtree , cv. ty ) ) ,
2917
+ ty:: ConstKind :: Value ( cv) => return ( cv. valtree , cv. ty ) ,
2919
2918
other => span_bug ! ( constant. span, "{other:#?}" ) ,
2920
2919
} ,
2921
2920
mir:: Const :: Val ( mir:: ConstValue :: Scalar ( mir:: interpret:: Scalar :: Int ( val) ) , ty) => {
2922
- return Ok ( ( ValTree :: from_scalar_int ( self . tcx , val) , ty) ) ;
2921
+ return ( ValTree :: from_scalar_int ( self . tcx , val) , ty) ;
2923
2922
}
2924
2923
// We should never encounter `Const::Val` unless MIR opts (like const prop) evaluate
2925
2924
// a constant and write that value back into `Operand`s. This could happen, but is
@@ -2932,9 +2931,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
2932
2931
other => span_bug ! ( constant. span, "{other:#?}" ) ,
2933
2932
} ;
2934
2933
2935
- match self . tcx . const_eval_resolve_for_typeck ( self . typing_env ( ) , uv, constant. span ) ? {
2936
- Ok ( valtree) => Ok ( ( valtree, ty) ) ,
2937
- Err ( ty) => bug ! ( "could not convert {ty:?} to a valtree" ) ,
2934
+ match self . tcx . const_eval_resolve_for_typeck ( self . typing_env ( ) , uv, constant. span ) {
2935
+ Ok ( Ok ( valtree) ) => ( valtree, ty) ,
2936
+ Ok ( Err ( ty) ) => span_bug ! ( constant. span, "could not convert {ty:?} to a valtree" ) ,
2937
+ Err ( _) => span_bug ! ( constant. span, "unable to evaluate this constant" ) ,
2938
2938
}
2939
2939
}
2940
2940
@@ -2946,7 +2946,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
2946
2946
use rustc_pattern_analysis:: constructor:: { IntRange , MaybeInfiniteInt } ;
2947
2947
use rustc_pattern_analysis:: rustc:: Constructor ;
2948
2948
2949
- let ( valtree, ty) = self . eval_unevaluated_mir_constant_to_valtree ( constant) . unwrap ( ) ;
2949
+ let ( valtree, ty) = self . eval_unevaluated_mir_constant_to_valtree ( constant) ;
2950
2950
assert ! ( !ty. has_param( ) ) ;
2951
2951
2952
2952
match pat. ctor ( ) {
0 commit comments