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 const_caller_location and const_location_fields #122291

Merged
merged 1 commit into from
Apr 6, 2024

Conversation

lilasta
Copy link
Contributor

@lilasta lilasta commented Mar 10, 2024

Closes #102911. Closes #76156.

tests: library/core/tests/panic/location.rs

API:

// 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;
}

@rustbot
Copy link
Collaborator

rustbot commented Mar 10, 2024

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Mar 10, 2024
@clubby789 clubby789 added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. and removed T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Mar 10, 2024
@jhpratt
Copy link
Member

jhpratt commented Mar 11, 2024

This still needs FCP.

@lilasta
Copy link
Contributor Author

lilasta commented Mar 12, 2024

I've written a stabilization report. Is the content sufficient to request the initiation of FCP? (I apologize as it's my first time submitting a stabilization PR)

Stabilization Report

Summary

The const_location_fields feature enables the utilization of the file, line, and column fields of core::location::Location in a const context.

use core::panic::Location;

const LOCATION: &Location<'static> = Location::caller();
const FILE: &str = LOCATION.file();
const LINE: u32 = LOCATION.line();
const COLUMN: u32 = LOCATION.column();

This feature is used in conjunction with Location::caller (tracked in const_caller_location #76156). It has the potential to be useful for embedding debug information during compilation.

Location::{file, line, column} simply returns the fields of the struct as they are, so it can be safely made const.

Tests

@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 16, 2024
@Amanieu
Copy link
Member

Amanieu commented Mar 19, 2024

We discussed this in the libs-api meeting today. We are happy to const-stabilize these methods, but this should happen alongside the const-stabilization of Location::caller, not separately.

@lilasta lilasta force-pushed the stabilize_const_location_fields branch from c6f8b7d to d324d6d Compare March 21, 2024 13:20
@lilasta lilasta changed the title Stabilize const_location_fields Stabilize const_caller_location and const_location_fields Mar 21, 2024
@Amanieu
Copy link
Member

Amanieu commented Mar 22, 2024

FCP started in #76156.

@Amanieu
Copy link
Member

Amanieu commented Apr 2, 2024

FCP has finished, this PR should be changed to also stabilize const_caller_location.

@Amanieu Amanieu added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). labels Apr 2, 2024
@slanterns
Copy link
Contributor

Isn't it already included in the PR?

@dtolnay dtolnay assigned dtolnay and unassigned Mark-Simulacrum Apr 5, 2024
Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@dtolnay
Copy link
Member

dtolnay commented Apr 5, 2024

@bors r+

@bors
Copy link
Contributor

bors commented Apr 5, 2024

📌 Commit d324d6d has been approved by dtolnay

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 5, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Apr 6, 2024
…ields, r=dtolnay

Stabilize `const_caller_location` and `const_location_fields`

Closes rust-lang#102911. Closes rust-lang#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;
}
```
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Apr 6, 2024
…ields, r=dtolnay

Stabilize `const_caller_location` and `const_location_fields`

Closes rust-lang#102911. Closes rust-lang#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;
}
```
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 6, 2024
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#114788 (impl get_mut_or_init and get_mut_or_try_init for OnceCell and OnceLock)
 - rust-lang#122291 (Stabilize `const_caller_location` and `const_location_fields`)
 - rust-lang#123321 (Bump dependencies)
 - rust-lang#123339 (optimize tidy check on `src/tools/tidy/src/issues.txt`)
 - rust-lang#123357 (CI: Redirect stderr to stdout to order GHA logs)
 - rust-lang#123504 (bootstrap: split cargo-miri test into separate Step)

r? `@ghost`
`@rustbot` modify labels: rollup
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Apr 6, 2024
…ields, r=dtolnay

Stabilize `const_caller_location` and `const_location_fields`

Closes rust-lang#102911. Closes rust-lang#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;
}
```
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 6, 2024
…iaskrgr

Rollup of 5 pull requests

Successful merges:

 - rust-lang#114788 (impl get_mut_or_init and get_mut_or_try_init for OnceCell and OnceLock)
 - rust-lang#122291 (Stabilize `const_caller_location` and `const_location_fields`)
 - rust-lang#123339 (optimize tidy check on `src/tools/tidy/src/issues.txt`)
 - rust-lang#123357 (CI: Redirect stderr to stdout to order GHA logs)
 - rust-lang#123504 (bootstrap: split cargo-miri test into separate Step)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 6, 2024
…iaskrgr

Rollup of 4 pull requests

Successful merges:

 - rust-lang#114788 (impl get_mut_or_init and get_mut_or_try_init for OnceCell and OnceLock)
 - rust-lang#122291 (Stabilize `const_caller_location` and `const_location_fields`)
 - rust-lang#123357 (CI: Redirect stderr to stdout to order GHA logs)
 - rust-lang#123504 (bootstrap: split cargo-miri test into separate Step)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit cb7f1ee into rust-lang:master Apr 6, 2024
11 checks passed
@rustbot rustbot added this to the 1.79.0 milestone Apr 6, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Apr 6, 2024
Rollup merge of rust-lang#122291 - lilasta:stabilize_const_location_fields, r=dtolnay

Stabilize `const_caller_location` and `const_location_fields`

Closes rust-lang#102911. Closes rust-lang#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;
}
```
@lilasta lilasta deleted the stabilize_const_location_fields branch April 8, 2024 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tracking Issue for const_location_fields Tracking Issue for const_caller_location
9 participants