Skip to content

Commit 579d268

Browse files
committed
Auto merge of rust-lang#96348 - overdrivenpotato:inline-location, r=the8472
Inline core::panic::Location methods This avoids the overhead of a function call when used.
2 parents d201c81 + 92a5841 commit 579d268

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

library/core/src/panic/location.rs

+4
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ impl<'a> Location<'a> {
8383
#[stable(feature = "track_caller", since = "1.46.0")]
8484
#[rustc_const_unstable(feature = "const_caller_location", issue = "76156")]
8585
#[track_caller]
86+
#[inline]
8687
pub const fn caller() -> &'static Location<'static> {
8788
crate::intrinsics::caller_location()
8889
}
@@ -122,6 +123,7 @@ impl<'a> Location<'a> {
122123
/// ```
123124
#[must_use]
124125
#[stable(feature = "panic_hooks", since = "1.10.0")]
126+
#[inline]
125127
pub fn file(&self) -> &str {
126128
self.file
127129
}
@@ -145,6 +147,7 @@ impl<'a> Location<'a> {
145147
/// ```
146148
#[must_use]
147149
#[stable(feature = "panic_hooks", since = "1.10.0")]
150+
#[inline]
148151
pub fn line(&self) -> u32 {
149152
self.line
150153
}
@@ -168,6 +171,7 @@ impl<'a> Location<'a> {
168171
/// ```
169172
#[must_use]
170173
#[stable(feature = "panic_col", since = "1.25.0")]
174+
#[inline]
171175
pub fn column(&self) -> u32 {
172176
self.col
173177
}

0 commit comments

Comments
 (0)