@@ -188,26 +188,22 @@ fn turn_into_const<'tcx>(
188
188
tcx : TyCtxt < ' tcx > ,
189
189
constant : RawConst < ' tcx > ,
190
190
key : ty:: ParamEnvAnd < ' tcx , GlobalId < ' tcx > > ,
191
- ) -> :: rustc_middle :: mir :: interpret :: ConstEvalResult < ' tcx > {
191
+ ) -> ConstValue < ' tcx > {
192
192
let cid = key. value ;
193
193
let def_id = cid. instance . def . def_id ( ) ;
194
194
let is_static = tcx. is_static ( def_id) ;
195
195
let ecx = mk_eval_cx ( tcx, tcx. def_span ( key. value . instance . def_id ( ) ) , key. param_env , is_static) ;
196
196
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
+ ) ;
205
201
assert ! (
206
202
!is_static || cid. promoted. is_some( ) ,
207
203
"the const eval query should not be used for statics, use `const_eval_raw` instead"
208
204
) ;
209
205
// Turn this into a proper constant.
210
- Ok ( op_to_const ( & ecx, mplace. into ( ) ) )
206
+ op_to_const ( & ecx, mplace. into ( ) )
211
207
}
212
208
213
209
pub fn const_eval_validated_provider < ' tcx > (
@@ -241,7 +237,7 @@ pub fn const_eval_validated_provider<'tcx>(
241
237
} ) ;
242
238
}
243
239
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) )
245
241
}
246
242
247
243
pub fn const_eval_raw_provider < ' tcx > (
0 commit comments