Skip to content

Commit 8afebc0

Browse files
committed
Stabilize #[track_caller].
Does not yet make its constness stable, though. Use of `Location::caller` in const contexts is still gated by `#![feature(const_caller_location)]`.
1 parent e070765 commit 8afebc0

38 files changed

+36
-99
lines changed

src/doc/unstable-book/src/language-features/track-caller.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/libcore/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
#![feature(staged_api)]
119119
#![feature(std_internals)]
120120
#![feature(stmt_expr_attributes)]
121-
#![feature(track_caller)]
121+
#![cfg_attr(bootstrap, feature(track_caller))]
122122
#![feature(transparent_unions)]
123123
#![feature(unboxed_closures)]
124124
#![feature(unsized_locals)]

src/libcore/macros/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#[doc(include = "panic.md")]
22
#[macro_export]
3-
#[allow_internal_unstable(core_panic, track_caller)]
3+
#[allow_internal_unstable(core_panic, const_caller_location)]
44
#[stable(feature = "core", since = "1.6.0")]
55
macro_rules! panic {
66
() => (

src/libcore/panic.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ impl<'a> Location<'a> {
190190
/// # Examples
191191
///
192192
/// ```
193-
/// #![feature(track_caller)]
194193
/// use core::panic::Location;
195194
///
196195
/// /// Returns the [`Location`] at which it is called.
@@ -206,7 +205,7 @@ impl<'a> Location<'a> {
206205
///
207206
/// let fixed_location = get_just_one_location();
208207
/// assert_eq!(fixed_location.file(), file!());
209-
/// assert_eq!(fixed_location.line(), 15);
208+
/// assert_eq!(fixed_location.line(), 14);
210209
/// assert_eq!(fixed_location.column(), 5);
211210
///
212211
/// // running the same untracked function in a different location gives us the same result
@@ -217,7 +216,7 @@ impl<'a> Location<'a> {
217216
///
218217
/// let this_location = get_caller_location();
219218
/// assert_eq!(this_location.file(), file!());
220-
/// assert_eq!(this_location.line(), 29);
219+
/// assert_eq!(this_location.line(), 28);
221220
/// assert_eq!(this_location.column(), 21);
222221
///
223222
/// // running the tracked function in a different location produces a different value
@@ -226,13 +225,8 @@ impl<'a> Location<'a> {
226225
/// assert_ne!(this_location.line(), another_location.line());
227226
/// assert_ne!(this_location.column(), another_location.column());
228227
/// ```
229-
// FIXME: When stabilizing this method, please also update the documentation
230-
// of `intrinsics::caller_location`.
231-
#[unstable(
232-
feature = "track_caller",
233-
reason = "uses #[track_caller] which is not yet stable",
234-
issue = "47809"
235-
)]
228+
#[stable(feature = "track_caller", since = "1.46.0")]
229+
#[rustc_const_unstable(feature = "const_caller_location", issue = "47809")]
236230
#[track_caller]
237231
pub const fn caller() -> &'static Location<'static> {
238232
crate::intrinsics::caller_location()

src/librustc_error_codes/error_codes/E0736.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
Erroneous code example:
44

55
```compile_fail,E0736
6-
#![feature(track_caller)]
7-
86
#[naked]
97
#[track_caller]
108
fn foo() {}

src/librustc_error_codes/error_codes/E0737.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ restrictions.
55
Erroneous code example:
66

77
```compile_fail,E0737
8-
#![feature(track_caller)]
9-
108
#[track_caller]
119
extern "C" fn foo() {}
1210
```

src/librustc_error_codes/error_codes/E0739.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
Erroneous code example:
44

55
```compile_fail,E0739
6-
#![feature(track_caller)]
76
#[track_caller]
87
struct Bar {
98
a: u8,

src/librustc_errors/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
66
#![feature(crate_visibility_modifier)]
77
#![feature(nll)]
8-
#![feature(track_caller)]
8+
#![cfg_attr(bootstrap, feature(track_caller))]
99

1010
pub use emitter::ColorConfig;
1111

src/librustc_feature/accepted.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,9 @@ declare_features! (
265265
(accepted, const_if_match, "1.45.0", Some(49146), None),
266266
/// Allows the use of `loop` and `while` in constants.
267267
(accepted, const_loop, "1.45.0", Some(52000), None),
268+
/// Allows `#[track_caller]` to be used which provides
269+
/// accurate caller location reporting during panic (RFC 2091).
270+
(accepted, track_caller, "1.46.0", Some(47809), None),
268271

269272
// -------------------------------------------------------------------------
270273
// feature-group-end: accepted features

src/librustc_feature/active.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -494,10 +494,6 @@ declare_features! (
494494
/// Allows the use of raw-dylibs (RFC 2627).
495495
(active, raw_dylib, "1.40.0", Some(58713), None),
496496

497-
/// Allows `#[track_caller]` to be used which provides
498-
/// accurate caller location reporting during panic (RFC 2091).
499-
(active, track_caller, "1.40.0", Some(47809), None),
500-
501497
/// Allows making `dyn Trait` well-formed even if `Trait` is not object safe.
502498
/// In that case, `dyn Trait: Trait` does not hold. Moreover, coercions and
503499
/// casts in safe Rust to `dyn Trait` for such a `Trait` is also forbidden.

0 commit comments

Comments
 (0)