about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2020-02-09 16:54:40 +0100
committerRalf Jung <post@ralfj.de>2020-02-13 10:56:38 +0100
commit17a8cfd605fb8d43dc61496a522cf3b84988d69d (patch)
tree9934c53a9b6999102a12323c2dc036f7ad627c61
parentf3ff02bdd85255ad75bae40aad53e520e37a8e4a (diff)
downloadrust-17a8cfd605fb8d43dc61496a522cf3b84988d69d.tar.gz
rust-17a8cfd605fb8d43dc61496a522cf3b84988d69d.zip
no need for hook_panic_fn to return a bool
-rw-r--r--src/librustc_mir/const_eval/machine.rs18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/librustc_mir/const_eval/machine.rs b/src/librustc_mir/const_eval/machine.rs
index e0f146c6dc0..7fd96ec2d1a 100644
--- a/src/librustc_mir/const_eval/machine.rs
+++ b/src/librustc_mir/const_eval/machine.rs
@@ -60,13 +60,13 @@ impl<'mir, 'tcx> InterpCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>> {
 
     /// "Intercept" a function call to a panic-related function
     /// because we have something special to do for it.
-    /// Returns `true` if an intercept happened.
-    pub fn hook_panic_fn(
+    /// If this returns successfully (`Ok`), the function should just be evaluated normally.
+    fn hook_panic_fn(
         &mut self,
         span: Span,
         instance: ty::Instance<'tcx>,
         args: &[OpTy<'tcx>],
-    ) -> InterpResult<'tcx, bool> {
+    ) -> InterpResult<'tcx> {
         let def_id = instance.def_id();
         if Some(def_id) == self.tcx.lang_items().panic_fn()
             || Some(def_id) == self.tcx.lang_items().begin_panic_fn()
@@ -80,7 +80,7 @@ impl<'mir, 'tcx> InterpCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>> {
             let (file, line, col) = self.location_triple_for_span(span);
             Err(ConstEvalErrKind::Panic { msg, file, line, col }.into())
         } else {
-            Ok(false)
+            Ok(())
         }
     }
 }
@@ -225,13 +225,11 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
                 }
             } else {
                 // Some functions we support even if they are non-const -- but avoid testing
-                // that for const fn!  We certainly do *not* want to actually call the fn
+                // that for const fn!
+                ecx.hook_panic_fn(span, instance, args)?;
+                // We certainly do *not* want to actually call the fn
                 // though, so be sure we return here.
-                return if ecx.hook_panic_fn(span, instance, args)? {
-                    Ok(None)
-                } else {
-                    throw_unsup_format!("calling non-const function `{}`", instance)
-                };
+                throw_unsup_format!("calling non-const function `{}`", instance)
             }
         }
         // This is a const fn. Call it.