@@ -60,13 +60,13 @@ impl<'mir, 'tcx> InterpCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>> {
60
60
61
61
/// "Intercept" a function call to a panic-related function
62
62
/// because we have something special to do for it.
63
- /// Returns `true` if an intercept happened .
64
- pub fn hook_panic_fn (
63
+ /// If this returns successfully (`Ok`), the function should just be evaluated normally .
64
+ fn hook_panic_fn (
65
65
& mut self ,
66
66
span : Span ,
67
67
instance : ty:: Instance < ' tcx > ,
68
68
args : & [ OpTy < ' tcx > ] ,
69
- ) -> InterpResult < ' tcx , bool > {
69
+ ) -> InterpResult < ' tcx > {
70
70
let def_id = instance. def_id ( ) ;
71
71
if Some ( def_id) == self . tcx . lang_items ( ) . panic_fn ( )
72
72
|| Some ( def_id) == self . tcx . lang_items ( ) . begin_panic_fn ( )
@@ -80,7 +80,7 @@ impl<'mir, 'tcx> InterpCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>> {
80
80
let ( file, line, col) = self . location_triple_for_span ( span) ;
81
81
Err ( ConstEvalErrKind :: Panic { msg, file, line, col } . into ( ) )
82
82
} else {
83
- Ok ( false )
83
+ Ok ( ( ) )
84
84
}
85
85
}
86
86
}
@@ -225,13 +225,11 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
225
225
}
226
226
} else {
227
227
// Some functions we support even if they are non-const -- but avoid testing
228
- // that for const fn! We certainly do *not* want to actually call the fn
228
+ // that for const fn!
229
+ ecx. hook_panic_fn ( span, instance, args) ?;
230
+ // We certainly do *not* want to actually call the fn
229
231
// though, so be sure we return here.
230
- return if ecx. hook_panic_fn ( span, instance, args) ? {
231
- Ok ( None )
232
- } else {
233
- throw_unsup_format ! ( "calling non-const function `{}`" , instance)
234
- } ;
232
+ throw_unsup_format ! ( "calling non-const function `{}`" , instance)
235
233
}
236
234
}
237
235
// This is a const fn. Call it.
0 commit comments