Skip to content

Commit fa34de3

Browse files
authored
Merge pull request #2101 from davidhewitt/always-track-caller
cleanup: always enable #[track_caller]
2 parents 2449df5 + 1d50a7c commit fa34de3

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

build.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,6 @@ fn configure_pyo3() -> Result<()> {
140140

141141
let rustc_minor_version = rustc_minor_version().unwrap_or(0);
142142

143-
// Enable use of #[track_caller] on Rust 1.46 and greater
144-
if rustc_minor_version >= 46 {
145-
println!("cargo:rustc-cfg=track_caller");
146-
}
147-
148143
// Enable use of const generics on Rust 1.51 and greater
149144
if rustc_minor_version >= 51 {
150145
println!("cargo:rustc-cfg=min_const_generics");

src/internal_tricks.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ macro_rules! index_impls {
6565
// Always PyAny output (even if the slice operation returns something else)
6666
type Output = PyAny;
6767

68-
#[cfg_attr(track_caller, track_caller)]
68+
#[track_caller]
6969
fn index(&self, index: usize) -> &Self::Output {
7070
self.get_item(index).unwrap_or_else(|_| {
7171
crate::internal_tricks::index_len_fail(index, $ty_name, $len(self))
@@ -76,7 +76,7 @@ macro_rules! index_impls {
7676
impl std::ops::Index<std::ops::Range<usize>> for $ty {
7777
type Output = $ty;
7878

79-
#[cfg_attr(track_caller, track_caller)]
79+
#[track_caller]
8080
fn index(
8181
&self,
8282
std::ops::Range { start, end }: std::ops::Range<usize>,
@@ -97,7 +97,7 @@ macro_rules! index_impls {
9797
impl std::ops::Index<std::ops::RangeFrom<usize>> for $ty {
9898
type Output = $ty;
9999

100-
#[cfg_attr(track_caller, track_caller)]
100+
#[track_caller]
101101
fn index(
102102
&self,
103103
std::ops::RangeFrom { start }: std::ops::RangeFrom<usize>,
@@ -114,7 +114,7 @@ macro_rules! index_impls {
114114
impl std::ops::Index<std::ops::RangeFull> for $ty {
115115
type Output = $ty;
116116

117-
#[cfg_attr(track_caller, track_caller)]
117+
#[track_caller]
118118
fn index(&self, _: std::ops::RangeFull) -> &Self::Output {
119119
let len = $len(self);
120120
$get_slice(self, 0, len)
@@ -124,7 +124,7 @@ macro_rules! index_impls {
124124
impl std::ops::Index<std::ops::RangeInclusive<usize>> for $ty {
125125
type Output = $ty;
126126

127-
#[cfg_attr(track_caller, track_caller)]
127+
#[track_caller]
128128
fn index(&self, range: std::ops::RangeInclusive<usize>) -> &Self::Output {
129129
let exclusive_end = range
130130
.end()
@@ -137,7 +137,7 @@ macro_rules! index_impls {
137137
impl std::ops::Index<std::ops::RangeTo<usize>> for $ty {
138138
type Output = $ty;
139139

140-
#[cfg_attr(track_caller, track_caller)]
140+
#[track_caller]
141141
fn index(&self, std::ops::RangeTo { end }: std::ops::RangeTo<usize>) -> &Self::Output {
142142
&self[0..end]
143143
}
@@ -146,7 +146,7 @@ macro_rules! index_impls {
146146
impl std::ops::Index<std::ops::RangeToInclusive<usize>> for $ty {
147147
type Output = $ty;
148148

149-
#[cfg_attr(track_caller, track_caller)]
149+
#[track_caller]
150150
fn index(
151151
&self,
152152
std::ops::RangeToInclusive { end }: std::ops::RangeToInclusive<usize>,
@@ -161,7 +161,7 @@ macro_rules! index_impls {
161161

162162
#[inline(never)]
163163
#[cold]
164-
#[cfg_attr(track_caller, track_caller)]
164+
#[track_caller]
165165
pub(crate) fn index_len_fail(index: usize, ty_name: &str, len: usize) -> ! {
166166
panic!(
167167
"index {} out of range for {} of length {}",
@@ -171,7 +171,7 @@ pub(crate) fn index_len_fail(index: usize, ty_name: &str, len: usize) -> ! {
171171

172172
#[inline(never)]
173173
#[cold]
174-
#[cfg_attr(track_caller, track_caller)]
174+
#[track_caller]
175175
pub(crate) fn slice_start_index_len_fail(index: usize, ty_name: &str, len: usize) -> ! {
176176
panic!(
177177
"range start index {} out of range for {} of length {}",
@@ -181,7 +181,7 @@ pub(crate) fn slice_start_index_len_fail(index: usize, ty_name: &str, len: usize
181181

182182
#[inline(never)]
183183
#[cold]
184-
#[cfg_attr(track_caller, track_caller)]
184+
#[track_caller]
185185
pub(crate) fn slice_end_index_len_fail(index: usize, ty_name: &str, len: usize) -> ! {
186186
panic!(
187187
"range end index {} out of range for {} of length {}",
@@ -191,7 +191,7 @@ pub(crate) fn slice_end_index_len_fail(index: usize, ty_name: &str, len: usize)
191191

192192
#[inline(never)]
193193
#[cold]
194-
#[cfg_attr(track_caller, track_caller)]
194+
#[track_caller]
195195
pub(crate) fn slice_index_order_fail(index: usize, end: usize) -> ! {
196196
panic!("slice index starts at {} but ends at {}", index, end);
197197
}

0 commit comments

Comments
 (0)