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