Closed
Description
Given the following code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=f974e7cf48544a6625e0ff9e11af9a76
use std::time::Duration;
fn main() {
let _ = Duration::from_secs_f32(-12.3_f32);
}
The current output is:
thread 'main' panicked at 'underflow when converting float to duration', /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/time.rs:754:23
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Ideally the output should look like:
thread 'main' panicked at 'negative floats cannot be used as a duration', /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/time.rs:754:23
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
while the current error message might still give a hint as to what could be going on, if you have genuinely large numbers passed to the function, you may go in a completely wrong path while debugging (testing the input to be within limits, rather than checking if it is negative or not).