Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stabilize #[track_caller]. #72445

Merged
merged 1 commit into from
Jul 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions src/doc/unstable-book/src/language-features/track-caller.md

This file was deleted.

2 changes: 1 addition & 1 deletion src/libcore/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
#![feature(staged_api)]
#![feature(std_internals)]
#![feature(stmt_expr_attributes)]
#![feature(track_caller)]
#![cfg_attr(bootstrap, feature(track_caller))]
#![feature(transparent_unions)]
#![feature(unboxed_closures)]
#![feature(unsized_locals)]
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/macros/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#[doc(include = "panic.md")]
#[macro_export]
#[allow_internal_unstable(core_panic, track_caller)]
#[allow_internal_unstable(core_panic, const_caller_location)]
#[stable(feature = "core", since = "1.6.0")]
macro_rules! panic {
() => (
Expand Down
14 changes: 4 additions & 10 deletions src/libcore/panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ impl<'a> Location<'a> {
/// # Examples
///
/// ```
/// #![feature(track_caller)]
/// use core::panic::Location;
///
/// /// Returns the [`Location`] at which it is called.
Expand All @@ -206,7 +205,7 @@ impl<'a> Location<'a> {
///
/// let fixed_location = get_just_one_location();
/// assert_eq!(fixed_location.file(), file!());
/// assert_eq!(fixed_location.line(), 15);
/// assert_eq!(fixed_location.line(), 14);
/// assert_eq!(fixed_location.column(), 5);
///
/// // running the same untracked function in a different location gives us the same result
Expand All @@ -217,7 +216,7 @@ impl<'a> Location<'a> {
///
/// let this_location = get_caller_location();
/// assert_eq!(this_location.file(), file!());
/// assert_eq!(this_location.line(), 29);
/// assert_eq!(this_location.line(), 28);
/// assert_eq!(this_location.column(), 21);
///
/// // running the tracked function in a different location produces a different value
Expand All @@ -226,13 +225,8 @@ impl<'a> Location<'a> {
/// assert_ne!(this_location.line(), another_location.line());
/// assert_ne!(this_location.column(), another_location.column());
/// ```
// FIXME: When stabilizing this method, please also update the documentation
// of `intrinsics::caller_location`.
#[unstable(
feature = "track_caller",
reason = "uses #[track_caller] which is not yet stable",
issue = "47809"
)]
#[stable(feature = "track_caller", since = "1.46.0")]
#[rustc_const_unstable(feature = "const_caller_location", issue = "47809")]
#[track_caller]
pub const fn caller() -> &'static Location<'static> {
crate::intrinsics::caller_location()
Expand Down
2 changes: 0 additions & 2 deletions src/librustc_error_codes/error_codes/E0736.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
Erroneous code example:

```compile_fail,E0736
#![feature(track_caller)]
#[naked]
#[track_caller]
fn foo() {}
Expand Down
2 changes: 0 additions & 2 deletions src/librustc_error_codes/error_codes/E0737.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ restrictions.
Erroneous code example:

```compile_fail,E0737
#![feature(track_caller)]
#[track_caller]
extern "C" fn foo() {}
```
Expand Down
1 change: 0 additions & 1 deletion src/librustc_error_codes/error_codes/E0739.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
Erroneous code example:

```compile_fail,E0739
#![feature(track_caller)]
#[track_caller]
struct Bar {
a: u8,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_errors/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
#![feature(crate_visibility_modifier)]
#![feature(nll)]
#![feature(track_caller)]
#![cfg_attr(bootstrap, feature(track_caller))]

pub use emitter::ColorConfig;

Expand Down
3 changes: 3 additions & 0 deletions src/librustc_feature/accepted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@ declare_features! (
(accepted, const_if_match, "1.45.0", Some(49146), None),
/// Allows the use of `loop` and `while` in constants.
(accepted, const_loop, "1.45.0", Some(52000), None),
/// Allows `#[track_caller]` to be used which provides
/// accurate caller location reporting during panic (RFC 2091).
(accepted, track_caller, "1.46.0", Some(47809), None),

// -------------------------------------------------------------------------
// feature-group-end: accepted features
Expand Down
4 changes: 0 additions & 4 deletions src/librustc_feature/active.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,10 +494,6 @@ declare_features! (
/// Allows the use of raw-dylibs (RFC 2627).
(active, raw_dylib, "1.40.0", Some(58713), None),

/// Allows `#[track_caller]` to be used which provides
/// accurate caller location reporting during panic (RFC 2091).
(active, track_caller, "1.40.0", Some(47809), None),

/// Allows making `dyn Trait` well-formed even if `Trait` is not object safe.
/// In that case, `dyn Trait: Trait` does not hold. Moreover, coercions and
/// casts in safe Rust to `dyn Trait` for such a `Trait` is also forbidden.
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_feature/builtin_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
ungated!(cold, Whitelisted, template!(Word)),
ungated!(no_builtins, Whitelisted, template!(Word)),
ungated!(target_feature, Whitelisted, template!(List: r#"enable = "name""#)),
ungated!(track_caller, Whitelisted, template!(Word)),
gated!(
no_sanitize, Whitelisted,
template!(List: "address, memory, thread"),
Expand Down Expand Up @@ -333,7 +334,6 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
gated!(ffi_returns_twice, Whitelisted, template!(Word), experimental!(ffi_returns_twice)),
gated!(ffi_pure, Whitelisted, template!(Word), experimental!(ffi_pure)),
gated!(ffi_const, Whitelisted, template!(Word), experimental!(ffi_const)),
gated!(track_caller, Whitelisted, template!(Word), experimental!(track_caller)),
gated!(
register_attr, CrateLevel, template!(List: "attr1, attr2, ..."),
experimental!(register_attr),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_middle/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#![feature(or_patterns)]
#![feature(range_is_empty)]
#![feature(min_specialization)]
#![feature(track_caller)]
#![cfg_attr(bootstrap, feature(track_caller))]
#![feature(trusted_len)]
#![feature(stmt_expr_attributes)]
#![feature(test)]
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@
#![feature(toowned_clone_into)]
#![feature(total_cmp)]
#![feature(trace_macros)]
#![feature(track_caller)]
#![cfg_attr(bootstrap, feature(track_caller))]
#![feature(try_reserve)]
#![feature(unboxed_closures)]
#![feature(untagged_unions)]
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/asm/sym.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// only-linux
// run-pass

#![feature(asm, track_caller, thread_local)]
#![feature(asm, thread_local)]

extern "C" fn f1() -> i32 {
111
Expand Down
5 changes: 0 additions & 5 deletions src/test/ui/feature-gates/feature-gate-track_caller.rs

This file was deleted.

12 changes: 0 additions & 12 deletions src/test/ui/feature-gates/feature-gate-track_caller.stderr

This file was deleted.

2 changes: 0 additions & 2 deletions src/test/ui/macros/issue-68060.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(track_caller)]

fn main() {
(0..)
.map(
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/macros/issue-68060.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0658]: `#[target_feature(..)]` can only be applied to `unsafe` functions
--> $DIR/issue-68060.rs:6:13
--> $DIR/issue-68060.rs:4:13
|
LL | #[target_feature(enable = "")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -11,13 +11,13 @@ LL | |_| (),
= help: add `#![feature(target_feature_11)]` to the crate attributes to enable

error: the feature named `` is not valid for this target
--> $DIR/issue-68060.rs:6:30
--> $DIR/issue-68060.rs:4:30
|
LL | #[target_feature(enable = "")]
| ^^^^^^^^^^^ `` is not valid for this target

error[E0737]: `#[track_caller]` requires Rust ABI
--> $DIR/issue-68060.rs:9:13
--> $DIR/issue-68060.rs:7:13
|
LL | #[track_caller]
| ^^^^^^^^^^^^^^^
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/numbers-arithmetic/saturating-float-casts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
// merged.

#![feature(test, stmt_expr_attributes)]
#![feature(track_caller)]
#![deny(overflowing_literals)]
extern crate test;

Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/rfc-2091-track-caller/call-chain.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// run-pass

#![feature(track_caller)]

use std::panic::Location;

struct Foo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// run-pass
// compile-flags: -Z unleash-the-miri-inside-of-you

#![feature(core_intrinsics, const_caller_location, track_caller, const_fn)]
#![feature(core_intrinsics, const_caller_location, const_fn)]

type L = &'static std::panic::Location<'static>;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// run-pass

#![feature(track_caller)]

#[inline(never)]
#[track_caller]
fn codegen_caller_loc() -> &'static core::panic::Location<'static> {
Expand All @@ -15,13 +13,13 @@ macro_rules! caller_location_from_macro {
fn main() {
let loc = codegen_caller_loc();
assert_eq!(loc.file(), file!());
assert_eq!(loc.line(), 16);
assert_eq!(loc.line(), 14);
assert_eq!(loc.column(), 15);

// `Location::caller()` in a macro should behave similarly to `file!` and `line!`,
// i.e. point to where the macro was invoked, instead of the macro itself.
let loc2 = caller_location_from_macro!();
assert_eq!(loc2.file(), file!());
assert_eq!(loc2.line(), 23);
assert_eq!(loc2.line(), 21);
assert_eq!(loc2.column(), 16);
}
2 changes: 1 addition & 1 deletion src/test/ui/rfc-2091-track-caller/const-caller-location.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// run-pass

#![feature(const_fn, track_caller)]
#![feature(const_caller_location, const_fn)]

use std::panic::Location;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
//! we don't inspect the location returned -- it would be difficult to distinguish between the
//! explicit panic and a failed assertion. That it compiles and runs is enough for this one.
#![feature(track_caller)]

#[track_caller]
fn doesnt_return() -> ! {
let _location = core::panic::Location::caller();
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/rfc-2091-track-caller/error-odd-syntax.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(track_caller)]

#[track_caller(1)]
fn f() {}
//~^^ ERROR malformed `track_caller` attribute input
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/rfc-2091-track-caller/error-odd-syntax.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: malformed `track_caller` attribute input
--> $DIR/error-odd-syntax.rs:3:1
--> $DIR/error-odd-syntax.rs:1:1
|
LL | #[track_caller(1)]
| ^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[track_caller]`
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/rfc-2091-track-caller/error-with-invalid-abi.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(track_caller)]

#[track_caller]
extern "C" fn f() {}
//~^^ ERROR `#[track_caller]` requires Rust ABI
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
error[E0737]: `#[track_caller]` requires Rust ABI
--> $DIR/error-with-invalid-abi.rs:3:1
--> $DIR/error-with-invalid-abi.rs:1:1
|
LL | #[track_caller]
| ^^^^^^^^^^^^^^^

error[E0737]: `#[track_caller]` requires Rust ABI
--> $DIR/error-with-invalid-abi.rs:8:5
--> $DIR/error-with-invalid-abi.rs:6:5
|
LL | #[track_caller]
| ^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/rfc-2091-track-caller/error-with-naked.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(naked_functions, track_caller)]
#![feature(naked_functions)]

#[track_caller] //~ ERROR cannot use `#[track_caller]` with `#[naked]`
#[naked]
Expand Down
6 changes: 2 additions & 4 deletions src/test/ui/rfc-2091-track-caller/intrinsic-wrapper.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
// run-pass

#![feature(track_caller)]

macro_rules! caller_location_from_macro {
() => (core::panic::Location::caller());
}

fn main() {
let loc = core::panic::Location::caller();
assert_eq!(loc.file(), file!());
assert_eq!(loc.line(), 10);
assert_eq!(loc.line(), 8);
assert_eq!(loc.column(), 15);

// `Location::caller()` in a macro should behave similarly to `file!` and `line!`,
// i.e. point to where the macro was invoked, instead of the macro itself.
let loc2 = caller_location_from_macro!();
assert_eq!(loc2.file(), file!());
assert_eq!(loc2.line(), 17);
assert_eq!(loc2.line(), 15);
assert_eq!(loc2.column(), 16);
}
2 changes: 0 additions & 2 deletions src/test/ui/rfc-2091-track-caller/only-for-fns.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(track_caller)]

#[track_caller]
struct S;
//~^^ ERROR attribute should be applied to function
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/rfc-2091-track-caller/only-for-fns.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0739]: attribute should be applied to function
--> $DIR/only-for-fns.rs:3:1
--> $DIR/only-for-fns.rs:1:1
|
LL | #[track_caller]
| ^^^^^^^^^^^^^^^
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/rfc-2091-track-caller/pass.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// run-pass
#![feature(track_caller)]

#[track_caller]
fn f() {}

Expand Down
10 changes: 4 additions & 6 deletions src/test/ui/rfc-2091-track-caller/track-caller-attribute.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// run-pass

#![feature(track_caller)]

use std::panic::Location;

#[track_caller]
Expand All @@ -20,21 +18,21 @@ fn nested_tracked() -> &'static Location<'static> {
fn main() {
let location = Location::caller();
assert_eq!(location.file(), file!());
assert_eq!(location.line(), 21);
assert_eq!(location.line(), 19);
assert_eq!(location.column(), 20);

let tracked = tracked();
assert_eq!(tracked.file(), file!());
assert_eq!(tracked.line(), 26);
assert_eq!(tracked.line(), 24);
assert_eq!(tracked.column(), 19);

let nested = nested_intrinsic();
assert_eq!(nested.file(), file!());
assert_eq!(nested.line(), 13);
assert_eq!(nested.line(), 11);
assert_eq!(nested.column(), 5);

let contained = nested_tracked();
assert_eq!(contained.file(), file!());
assert_eq!(contained.line(), 17);
assert_eq!(contained.line(), 15);
assert_eq!(contained.column(), 5);
}
Loading