0

Stabilize `const_caller_location` and `const_location_fields` by lilasta · Pull...

 1 week ago
source link: https://github.com/rust-lang/rust/pull/122291
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Stabilize `const_caller_location` and `const_location_fields` by lilasta · Pull Request #122291 · rust-lang/rust · GitHub

Conversation

Contributor

@lilasta lilasta

commented

Mar 10, 2024

edited by dtolnay

Closes #102911. Closes #76156.

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

// 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;
}
tuguzT and joseluis reacted with thumbs up emoji

Collaborator

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

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

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

Member

This still needs FCP.

Contributor

Author

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

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

Member

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 reacted with thumbs up emoji

lilasta

changed the title Stabilize const_location_fields

Stabilize const_caller_location and const_location_fields

Mar 21, 2024

Member

FCP started in #76156.

Member

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

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

Contributor

Isn't it already included in the PR?

Member

@dtolnay dtolnay

left a comment

Thank you!

Member

@bors r+

Contributor

📌 Commit d324d6d has been approved by dtolnay

It is now in the queue for this repository.

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

bors

merged commit cb7f1ee into

rust-lang:master

Apr 6, 2024

11 checks passed

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

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

Reviewers

dtolnay

dtolnay approved these changes
Assignees

dtolnay

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

Milestone

1.79.0

9 participants

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK