Skip to content

Commit 17a8cfd

Browse files
committed
no need for hook_panic_fn to return a bool
1 parent f3ff02b commit 17a8cfd

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/librustc_mir/const_eval/machine.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ impl<'mir, 'tcx> InterpCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>> {
6060

6161
/// "Intercept" a function call to a panic-related function
6262
/// 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(
6565
&mut self,
6666
span: Span,
6767
instance: ty::Instance<'tcx>,
6868
args: &[OpTy<'tcx>],
69-
) -> InterpResult<'tcx, bool> {
69+
) -> InterpResult<'tcx> {
7070
let def_id = instance.def_id();
7171
if Some(def_id) == self.tcx.lang_items().panic_fn()
7272
|| Some(def_id) == self.tcx.lang_items().begin_panic_fn()
@@ -80,7 +80,7 @@ impl<'mir, 'tcx> InterpCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>> {
8080
let (file, line, col) = self.location_triple_for_span(span);
8181
Err(ConstEvalErrKind::Panic { msg, file, line, col }.into())
8282
} else {
83-
Ok(false)
83+
Ok(())
8484
}
8585
}
8686
}
@@ -225,13 +225,11 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
225225
}
226226
} else {
227227
// 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
229231
// 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)
235233
}
236234
}
237235
// This is a const fn. Call it.

0 commit comments

Comments
 (0)