mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Auto merge of #153480 - RaphiMuehlbacher:track-caller, r=Mark-Simulacrum
Add missing `track_caller` to overflowing trait methods Fixes rust-lang/rust#152599 by adding `#[track_caller]` to arithmetic trait methods (`Neg`, `Shl`, `ShlAssign`, `Shr` and `ShrAssign`) so overflow panics report the correct call site instead of the trait definition.
This commit is contained in:
@@ -716,6 +716,7 @@ impl const Neg for $t {
|
||||
type Output = $t;
|
||||
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
#[rustc_inherit_overflow_checks]
|
||||
fn neg(self) -> $t { -self }
|
||||
}
|
||||
|
||||
@@ -484,6 +484,7 @@ impl const Shl<$f> for $t {
|
||||
type Output = $t;
|
||||
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
#[rustc_inherit_overflow_checks]
|
||||
fn shl(self, other: $f) -> $t {
|
||||
self << other
|
||||
@@ -606,6 +607,7 @@ impl const Shr<$f> for $t {
|
||||
type Output = $t;
|
||||
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
#[rustc_inherit_overflow_checks]
|
||||
fn shr(self, other: $f) -> $t {
|
||||
self >> other
|
||||
@@ -958,6 +960,7 @@ macro_rules! shl_assign_impl {
|
||||
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
|
||||
impl const ShlAssign<$f> for $t {
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
#[rustc_inherit_overflow_checks]
|
||||
fn shl_assign(&mut self, other: $f) {
|
||||
*self <<= other
|
||||
@@ -1044,6 +1047,7 @@ macro_rules! shr_assign_impl {
|
||||
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
|
||||
impl const ShrAssign<$f> for $t {
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
#[rustc_inherit_overflow_checks]
|
||||
fn shr_assign(&mut self, other: $f) {
|
||||
*self >>= other
|
||||
|
||||
Reference in New Issue
Block a user