@@ -36,7 +36,8 @@ impl ConstantCx {
3636 }
3737}
3838
39- pub ( crate ) fn check_constants ( fx : & mut FunctionCx < ' _ , ' _ , impl Module > ) {
39+ pub ( crate ) fn check_constants ( fx : & mut FunctionCx < ' _ , ' _ , impl Module > ) -> bool {
40+ let mut all_constants_ok = true ;
4041 for constant in & fx. mir . required_consts {
4142 let const_ = fx. monomorphize ( constant. literal ) ;
4243 match const_. val {
@@ -46,6 +47,7 @@ pub(crate) fn check_constants(fx: &mut FunctionCx<'_, '_, impl Module>) {
4647 fx. tcx
4748 . const_eval_resolve ( ParamEnv :: reveal_all ( ) , def, substs, promoted, None )
4849 {
50+ all_constants_ok = false ;
4951 match err {
5052 ErrorHandled :: Reported ( ErrorReported ) | ErrorHandled :: Linted => {
5153 fx. tcx
@@ -69,6 +71,7 @@ pub(crate) fn check_constants(fx: &mut FunctionCx<'_, '_, impl Module>) {
6971 | ConstKind :: Error ( _) => unreachable ! ( "{:?}" , const_) ,
7072 }
7173 }
74+ all_constants_ok
7275}
7376
7477pub ( crate ) fn codegen_static ( constants_cx : & mut ConstantCx , def_id : DefId ) {
@@ -134,14 +137,7 @@ pub(crate) fn codegen_constant<'tcx>(
134137 {
135138 Ok ( const_val) => const_val,
136139 Err ( _) => {
137- fx. tcx
138- . sess
139- . span_err ( constant. span , "erroneous constant encountered" ) ;
140- return crate :: trap:: trap_unreachable_ret_value (
141- fx,
142- fx. layout_of ( const_. ty ) ,
143- "erroneous constant encountered" ,
144- ) ;
140+ span_bug ! ( constant. span, "erroneous constant not captured by required_consts" ) ;
145141 }
146142 }
147143 }
0 commit comments