constify Location methods

This commit is contained in:
woppopo 2022-08-26 18:14:12 +09:00
parent 4a24f08ba4
commit 4e3b9ed337

View File

@ -123,8 +123,9 @@ pub const fn caller() -> &'static Location<'static> {
/// ```
#[must_use]
#[stable(feature = "panic_hooks", since = "1.10.0")]
#[rustc_const_unstable(feature = "const_caller_location", issue = "76156")]
#[inline]
pub fn file(&self) -> &str {
pub const fn file(&self) -> &str {
self.file
}
@ -147,8 +148,9 @@ pub fn file(&self) -> &str {
/// ```
#[must_use]
#[stable(feature = "panic_hooks", since = "1.10.0")]
#[rustc_const_unstable(feature = "const_caller_location", issue = "76156")]
#[inline]
pub fn line(&self) -> u32 {
pub const fn line(&self) -> u32 {
self.line
}
@ -171,8 +173,9 @@ pub fn line(&self) -> u32 {
/// ```
#[must_use]
#[stable(feature = "panic_col", since = "1.25.0")]
#[rustc_const_unstable(feature = "const_caller_location", issue = "76156")]
#[inline]
pub fn column(&self) -> u32 {
pub const fn column(&self) -> u32 {
self.col
}
}