Add #[track_caller] to Duration Div impl
Previously the location of the divide-by-zero error condition would be attributed to the code in the rust standard library, eg: thread 'main' panicked at /home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/time.rs:1172:31: divide by zero error when dividing duration by scalar With #[track_caller] the error is correctly attributed to the callee.
This commit is contained in:
parent
de91711756
commit
4e4cb10b84
1 changed files with 2 additions and 0 deletions
|
|
@ -1168,6 +1168,7 @@ impl Div<u32> for Duration {
|
|||
type Output = Duration;
|
||||
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
fn div(self, rhs: u32) -> Duration {
|
||||
self.checked_div(rhs).expect("divide by zero error when dividing duration by scalar")
|
||||
}
|
||||
|
|
@ -1176,6 +1177,7 @@ impl Div<u32> for Duration {
|
|||
#[stable(feature = "time_augmented_assignment", since = "1.9.0")]
|
||||
impl DivAssign<u32> for Duration {
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
fn div_assign(&mut self, rhs: u32) {
|
||||
*self = *self / rhs;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue