@@ -188,26 +188,22 @@ fn turn_into_const<'tcx>(
188188 tcx : TyCtxt < ' tcx > ,
189189 constant : RawConst < ' tcx > ,
190190 key : ty:: ParamEnvAnd < ' tcx , GlobalId < ' tcx > > ,
191- ) -> :: rustc_middle :: mir :: interpret :: ConstEvalResult < ' tcx > {
191+ ) -> ConstValue < ' tcx > {
192192 let cid = key. value ;
193193 let def_id = cid. instance . def . def_id ( ) ;
194194 let is_static = tcx. is_static ( def_id) ;
195195 let ecx = mk_eval_cx ( tcx, tcx. def_span ( key. value . instance . def_id ( ) ) , key. param_env , is_static) ;
196196
197- let mplace = ecx. raw_const_to_mplace ( constant) . map_err ( |error| {
198- // FIXME: Can the above ever error and not be a compiler bug or can we just ICE here?
199- let err = ConstEvalErr :: new ( & ecx, error, None ) ;
200- err. struct_error ( ecx. tcx , "it is undefined behavior to use this value" , |mut diag| {
201- diag. note ( note_on_undefined_behavior_error ( ) ) ;
202- diag. emit ( ) ;
203- } )
204- } ) ?;
197+ let mplace = ecx. raw_const_to_mplace ( constant) . expect (
198+ "can only fail if layout computation failed, \
199+ which should have given a good error before ever invoking this function",
200+ ) ;
205201 assert ! (
206202 !is_static || cid. promoted. is_some( ) ,
207203 "the const eval query should not be used for statics, use `const_eval_raw` instead"
208204 ) ;
209205 // Turn this into a proper constant.
210- Ok ( op_to_const ( & ecx, mplace. into ( ) ) )
206+ op_to_const ( & ecx, mplace. into ( ) )
211207}
212208
213209pub fn const_eval_validated_provider < ' tcx > (
@@ -241,7 +237,7 @@ pub fn const_eval_validated_provider<'tcx>(
241237 } ) ;
242238 }
243239
244- tcx. const_eval_raw ( key) . and_then ( |val| turn_into_const ( tcx, val, key) )
240+ tcx. const_eval_raw ( key) . map ( |val| turn_into_const ( tcx, val, key) )
245241}
246242
247243pub fn const_eval_raw_provider < ' tcx > (
0 commit comments