about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-04-06 13:00:05 +0200
committerGitHub <noreply@github.com>2024-04-06 13:00:05 +0200
commitcb7f1eec043141db54acc1bc406d0e1c32938e26 (patch)
tree3aadb998ffef3bcd2bad0311f20cab1fbd18318a
parent3bcf402322d4df4ad31ddcc28fc1b8814716795d (diff)
parentd324d6de0e9a0c3f2413b75de71b175e74057b59 (diff)
downloadrust-cb7f1eec043141db54acc1bc406d0e1c32938e26.tar.gz
rust-cb7f1eec043141db54acc1bc406d0e1c32938e26.zip
Rollup merge of #122291 - lilasta:stabilize_const_location_fields, r=dtolnay
Stabilize `const_caller_location` and `const_location_fields`

Closes #102911. Closes #76156.

tests: [library/core/tests/panic/location.rs](https://github.com/rust-lang/rust/blob/3521a2f2f317cb978063842485c7d1bc86ec82b6/library/core/tests/panic/location.rs)

API:
```rust
// core::panic::location
impl Location {
    pub const fn caller() -> &'static Location<'static>;
    pub const fn file(&self) -> &str;
    pub const fn line(&self) -> u32;
    pub const fn column(&self) -> u32;
}
```
-rw-r--r--library/core/src/intrinsics.rs2
-rw-r--r--library/core/src/lib.rs1
-rw-r--r--library/core/src/panic/location.rs8
-rw-r--r--library/core/tests/lib.rs2
-rw-r--r--tests/ui/rfcs/rfc-2091-track-caller/caller-location-fnptr-rt-ctfe-equiv.rs2
-rw-r--r--tests/ui/rfcs/rfc-2091-track-caller/const-caller-location.rs12
6 files changed, 11 insertions, 16 deletions
diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs
index b09d9fab8a7..0b22f3dc374 100644
--- a/library/core/src/intrinsics.rs
+++ b/library/core/src/intrinsics.rs
@@ -1128,7 +1128,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>;
diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs
index ba19ca1f45d..2bc2c649a6d 100644
--- a/library/core/src/lib.rs
+++ b/library/core/src/lib.rs
@@ -125,7 +125,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)]
diff --git a/library/core/src/panic/location.rs b/library/core/src/panic/location.rs
index 6dcf23dde87..4ad507d8b86 100644
--- a/library/core/src/panic/location.rs
+++ b/library/core/src/panic/location.rs
@@ -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
diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs
index 8c5e5ecf5fe..0c87860096f 100644
--- a/library/core/tests/lib.rs
+++ b/library/core/tests/lib.rs
@@ -11,7 +11,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)]
@@ -25,7 +24,6 @@
 #![cfg_attr(not(bootstrap), feature(const_three_way_compare))]
 #![feature(const_trait_impl)]
 #![feature(const_likely)]
-#![feature(const_location_fields)]
 #![feature(core_intrinsics)]
 #![feature(core_io_borrowed_buf)]
 #![feature(core_private_bignum)]
diff --git a/tests/ui/rfcs/rfc-2091-track-caller/caller-location-fnptr-rt-ctfe-equiv.rs b/tests/ui/rfcs/rfc-2091-track-caller/caller-location-fnptr-rt-ctfe-equiv.rs
index 2ae8eb9c56d..ef970ebd14b 100644
--- a/tests/ui/rfcs/rfc-2091-track-caller/caller-location-fnptr-rt-ctfe-equiv.rs
+++ b/tests/ui/rfcs/rfc-2091-track-caller/caller-location-fnptr-rt-ctfe-equiv.rs
@@ -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>;
 
diff --git a/tests/ui/rfcs/rfc-2091-track-caller/const-caller-location.rs b/tests/ui/rfcs/rfc-2091-track-caller/const-caller-location.rs
index 2c699437c83..c4e1f3ae48a 100644
--- a/tests/ui/rfcs/rfc-2091-track-caller/const-caller-location.rs
+++ b/tests/ui/rfcs/rfc-2091-track-caller/const-caller-location.rs
@@ -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);
 }