Repository: rust
Issue: Can show operands at runtime when 'attempt to multiply with overflow' panic ?
Labels: T-lang,T-libs-api,C-feature-accepted

Is it possible to show the two operands at runtime when this panic occurs ?
thread 'main' panicked at 'attempt to multiply with overflow', src/main.rs:7
So maybe we can see `2*122` in the panic message?

[example code](https://play.rust-lang.org/?gist=3d3739913cd5cbbff6159d1b9687427f&version=stable)

[code with backtrace](https://play.rust-lang.org/?gist=50435a8845bd16bd4bf3a4995ddaff81&version=nightly)
<details><summary>output</summary>

```rust
  Compiling playground v0.0.1 (file:///playground)
    Finished dev [unoptimized + debuginfo] target(s) in 0.62 secs
     Running `target/debug/playground`
thread 'main' panicked at 'attempt to multiply with overflow', src/main.rs:9:20
stack backtrace:
   0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
             at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::_print
             at /checkout/src/libstd/sys_common/backtrace.rs:71
   2: std::panicking::default_hook::{{closure}}
             at /checkout/src/libstd/sys_common/backtrace.rs:60
             at /checkout/src/libstd/panicking.rs:380
   3: std::panicking::default_hook
             at /checkout/src/libstd/panicking.rs:396
   4: std::panicking::rust_panic_with_hook
             at /checkout/src/libstd/panicking.rs:610
   5: std::panicking::begin_panic
             at /checkout/src/libstd/panicking.rs:571
   6: std::panicking::begin_panic_fmt
             at /checkout/src/libstd/panicking.rs:521
   7: rust_begin_unwind
             at /checkout/src/libstd/panicking.rs:497
   8: core::panicking::panic_fmt
             at /checkout/src/libcore/panicking.rs:71
   9: core::panicking::panic
             at /checkout/src/libcore/panicking.rs:51
  10: playground::main
             at src/main.rs:9
  11: __rust_maybe_catch_panic
             at /checkout/src/libpanic_unwind/lib.rs:98
  12: std::rt::lang_start
             at /checkout/src/libstd/panicking.rs:458
             at /checkout/src/libstd/panic.rs:361
             at /checkout/src/libstd/rt.rs:61
  13: main
  14: __libc_start_main
  15: _start
```
</details>


----------

**EDIT:** what I tried and had no effect whatsoever:
```patch
diff --git a/src/librustc_const_math/int.rs b/src/librustc_const_math/int.rs
index 65471416e8..1c05352aec 100644
--- a/src/librustc_const_math/int.rs
+++ b/src/librustc_const_math/int.rs
@@ -329,7 +329,10 @@ impl ::std::fmt::Display for ConstInt {
 macro_rules! overflowing {
     ($e:expr, $err:expr) => {{
         if $e.1 {
-            return Err(Overflow($err));
+            return {
+                eprintln!("!!!moo3:{:?}!{:?}!",$e,$err);
+                Err(Overflow($err))
+            }
         } else {
             $e.0
         }
@@ -341,6 +344,7 @@ macro_rules! impl_binop {
         impl ::std::ops::$op for ConstInt {
             type Output = Result<Self, ConstMathErr>;
             fn $func(self, rhs: Self) -> Result<Self, ConstMathErr> {
+                eprintln!("!!!moo4:{:?}!{:?}!",self,rhs);
                 match (self, rhs) {
                     (I8(a), I8(b)) => a.$checked_func(b).map(I8),
                     (I16(a), I16(b)) => a.$checked_func(b).map(I16),
@@ -428,7 +432,10 @@ fn check_division(
         (Usize(_), Usize(Us32(0))) => Err(zerr),
         (Usize(_), Usize(Us64(0))) => Err(zerr),
 
-        (I8(::std::i8::MIN), I8(-1)) => Err(Overflow(op)),
+        (I8(::std::i8::MIN), I8(-1)) => {
+            eprintln!("!!!moo2{:?}!",op);
+            Err(Overflow(op))
+        },
         (I16(::std::i16::MIN), I16(-1)) => Err(Overflow(op)),
         (I32(::std::i32::MIN), I32(-1)) => Err(Overflow(op)),
         (I64(::std::i64::MIN), I64(-1)) => Err(Overflow(op)),
diff --git a/src/librustc_mir/build/expr/as_rvalue.rs b/src/librustc_mir/build/expr/as_rvalue.rs
index 2512291f1a..f8fd8315c5 100644
--- a/src/librustc_mir/build/expr/as_rvalue.rs
+++ b/src/librustc_mir/build/expr/as_rvalue.rs
@@ -285,6 +285,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
                     bug!("MIR build_binary_op: {:?} is not checkable", op)
                 }
             });
+            eprintln!("!!!moo{:?}!",err);
 
             block = self.assert(block, Operand::Consume(of), false,
                                 AssertMessage::Math(err), span);

diff --git a/src/librustc_trans/mir/constant.rs b/src/librustc_trans/mir/constant.rs
index 53469689bc..783aea003d 100644
--- a/src/librustc_trans/mir/constant.rs
+++ b/src/librustc_trans/mir/constant.rs
@@ -932,6 +932,7 @@ pub fn const_scalar_checked_binop<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                 bug!("Operator `{:?}` is not a checkable operator", op)
             }
         };
+        eprintln!("!!!moo5:{:?}!", result);
 
         let of = match result {
             Ok(_) => false,
```