@@ -36,7 +36,8 @@ impl ConstantCx {
36
36
}
37
37
}
38
38
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 ;
40
41
for constant in & fx. mir . required_consts {
41
42
let const_ = fx. monomorphize ( constant. literal ) ;
42
43
match const_. val {
@@ -46,6 +47,7 @@ pub(crate) fn check_constants(fx: &mut FunctionCx<'_, '_, impl Module>) {
46
47
fx. tcx
47
48
. const_eval_resolve ( ParamEnv :: reveal_all ( ) , def, substs, promoted, None )
48
49
{
50
+ all_constants_ok = false ;
49
51
match err {
50
52
ErrorHandled :: Reported ( ErrorReported ) | ErrorHandled :: Linted => {
51
53
fx. tcx
@@ -69,6 +71,7 @@ pub(crate) fn check_constants(fx: &mut FunctionCx<'_, '_, impl Module>) {
69
71
| ConstKind :: Error ( _) => unreachable ! ( "{:?}" , const_) ,
70
72
}
71
73
}
74
+ all_constants_ok
72
75
}
73
76
74
77
pub ( crate ) fn codegen_static ( constants_cx : & mut ConstantCx , def_id : DefId ) {
@@ -134,14 +137,7 @@ pub(crate) fn codegen_constant<'tcx>(
134
137
{
135
138
Ok ( const_val) => const_val,
136
139
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" ) ;
145
141
}
146
142
}
147
143
}
0 commit comments