@@ -6,9 +6,8 @@ use crate::glue;
66use crate :: traits:: * ;
77use crate :: MemFlags ;
88
9- use rustc_errors:: ErrorReported ;
109use rustc_middle:: mir;
11- use rustc_middle:: mir:: interpret:: { ConstValue , ErrorHandled , Pointer , Scalar } ;
10+ use rustc_middle:: mir:: interpret:: { ConstValue , Pointer , Scalar } ;
1211use rustc_middle:: ty:: layout:: TyAndLayout ;
1312use rustc_middle:: ty:: Ty ;
1413use rustc_target:: abi:: { Abi , Align , LayoutOf , Size } ;
@@ -439,25 +438,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
439438 }
440439
441440 mir:: Operand :: Constant ( ref constant) => {
442- self . eval_mir_constant_to_operand ( bx, constant) . unwrap_or_else ( |err| {
443- match err {
444- // errored or at least linted
445- ErrorHandled :: Reported ( ErrorReported ) | ErrorHandled :: Linted => { }
446- ErrorHandled :: TooGeneric => {
447- bug ! ( "codegen encountered polymorphic constant" )
448- }
449- }
450- // Allow RalfJ to sleep soundly knowing that even refactorings that remove
451- // the above error (or silence it under some conditions) will not cause UB.
452- bx. abort ( ) ;
453- // We still have to return an operand but it doesn't matter,
454- // this code is unreachable.
455- let ty = self . monomorphize ( constant. literal . ty ) ;
456- let layout = bx. cx ( ) . layout_of ( ty) ;
457- bx. load_operand ( PlaceRef :: new_sized (
458- bx. cx ( ) . const_undef ( bx. cx ( ) . type_ptr_to ( bx. cx ( ) . backend_type ( layout) ) ) ,
459- layout,
460- ) )
441+ // This cannot fail because we checked all required_consts in advance.
442+ self . eval_mir_constant_to_operand ( bx, constant) . unwrap_or_else ( |_err| {
443+ span_bug ! ( constant. span, "erroneous constant not captured by required_consts" )
461444 } )
462445 }
463446 }
0 commit comments