Stabilize const_caller_location and const_location_fields

This commit is contained in:
lilasta 2024-03-21 22:19:57 +09:00
parent 3521a2f2f3
commit d324d6de0e
6 changed files with 11 additions and 16 deletions

View File

@ -1132,7 +1132,7 @@ extern "rust-intrinsic" {
/// any safety invariants.
///
/// Consider using [`core::panic::Location::caller`] instead.
#[rustc_const_unstable(feature = "const_caller_location", issue = "76156")]
#[rustc_const_stable(feature = "const_caller_location", since = "CURRENT_RUSTC_VERSION")]
#[rustc_safe_intrinsic]
#[rustc_nounwind]
pub fn caller_location() -> &'static crate::panic::Location<'static>;

View File

@ -122,7 +122,6 @@
#![feature(const_array_into_iter_constructors)]
#![feature(const_bigint_helper_methods)]
#![feature(const_black_box)]
#![feature(const_caller_location)]
#![feature(const_cell_into_inner)]
#![feature(const_char_from_u32_unchecked)]
#![feature(const_eval_select)]

View File

@ -81,7 +81,7 @@ impl<'a> Location<'a> {
/// ```
#[must_use]
#[stable(feature = "track_caller", since = "1.46.0")]
#[rustc_const_unstable(feature = "const_caller_location", issue = "76156")]
#[rustc_const_stable(feature = "const_caller_location", since = "CURRENT_RUSTC_VERSION")]
#[track_caller]
#[inline]
pub const fn caller() -> &'static Location<'static> {
@ -123,7 +123,7 @@ impl<'a> Location<'a> {
/// ```
#[must_use]
#[stable(feature = "panic_hooks", since = "1.10.0")]
#[rustc_const_unstable(feature = "const_location_fields", issue = "102911")]
#[rustc_const_stable(feature = "const_location_fields", since = "CURRENT_RUSTC_VERSION")]
#[inline]
pub const fn file(&self) -> &str {
self.file
@ -148,7 +148,7 @@ impl<'a> Location<'a> {
/// ```
#[must_use]
#[stable(feature = "panic_hooks", since = "1.10.0")]
#[rustc_const_unstable(feature = "const_location_fields", issue = "102911")]
#[rustc_const_stable(feature = "const_location_fields", since = "CURRENT_RUSTC_VERSION")]
#[inline]
pub const fn line(&self) -> u32 {
self.line
@ -173,7 +173,7 @@ impl<'a> Location<'a> {
/// ```
#[must_use]
#[stable(feature = "panic_col", since = "1.25.0")]
#[rustc_const_unstable(feature = "const_location_fields", issue = "102911")]
#[rustc_const_stable(feature = "const_location_fields", since = "CURRENT_RUSTC_VERSION")]
#[inline]
pub const fn column(&self) -> u32 {
self.col

View File

@ -10,7 +10,6 @@
#![feature(const_align_offset)]
#![feature(const_align_of_val_raw)]
#![feature(const_black_box)]
#![feature(const_caller_location)]
#![feature(const_cell_into_inner)]
#![feature(const_hash)]
#![feature(const_heap)]
@ -22,7 +21,6 @@
#![feature(const_ptr_write)]
#![feature(const_trait_impl)]
#![feature(const_likely)]
#![feature(const_location_fields)]
#![feature(core_intrinsics)]
#![feature(core_io_borrowed_buf)]
#![feature(core_private_bignum)]

View File

@ -6,7 +6,7 @@
//@ run-pass
//@ compile-flags: -Z unleash-the-miri-inside-of-you
#![feature(core_intrinsics, const_caller_location)]
#![feature(core_intrinsics)]
type L = &'static std::panic::Location<'static>;

View File

@ -2,15 +2,13 @@
//@ revisions: default mir-opt
//@[mir-opt] compile-flags: -Zmir-opt-level=4
#![feature(const_caller_location)]
use std::panic::Location;
const LOCATION: &Location = Location::caller();
const TRACKED: &Location = tracked();
#[track_caller]
const fn tracked() -> &'static Location <'static> {
const fn tracked() -> &'static Location<'static> {
Location::caller()
}
@ -26,18 +24,18 @@ const fn contained() -> &'static Location<'static> {
fn main() {
assert_eq!(LOCATION.file(), file!());
assert_eq!(LOCATION.line(), 9);
assert_eq!(LOCATION.line(), 7);
assert_eq!(LOCATION.column(), 29);
assert_eq!(TRACKED.file(), file!());
assert_eq!(TRACKED.line(), 11);
assert_eq!(TRACKED.line(), 9);
assert_eq!(TRACKED.column(), 28);
assert_eq!(NESTED.file(), file!());
assert_eq!(NESTED.line(), 19);
assert_eq!(NESTED.line(), 17);
assert_eq!(NESTED.column(), 5);
assert_eq!(CONTAINED.file(), file!());
assert_eq!(CONTAINED.line(), 24);
assert_eq!(CONTAINED.line(), 22);
assert_eq!(CONTAINED.column(), 5);
}