Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/test-utils/src/minicore.rs')
-rw-r--r--crates/test-utils/src/minicore.rs34
1 files changed, 33 insertions, 1 deletions
diff --git a/crates/test-utils/src/minicore.rs b/crates/test-utils/src/minicore.rs
index 0588b1c77d..f9be47551c 100644
--- a/crates/test-utils/src/minicore.rs
+++ b/crates/test-utils/src/minicore.rs
@@ -59,6 +59,7 @@
//! option: panic
//! ord: eq, option
//! panic: fmt
+//! panic_location: panic
//! pat: panic
//! phantom_data:
//! pin:
@@ -2093,7 +2094,38 @@ pub mod str {
// endregion:str
// region:panic
-mod panic {
+pub mod panic {
+ // region:panic_location
+ #[rustc_intrinsic]
+ pub const fn caller_location() -> &'static Location<'static>;
+
+ #[lang = "panic_location"]
+ pub struct Location<'a> {
+ file: &'a str,
+ line: u32,
+ col: u32,
+ }
+
+ impl<'a> Location<'a> {
+ #[track_caller]
+ pub const fn caller() -> &'static Location<'static> {
+ caller_location()
+ }
+
+ pub const fn file(&self) -> &str {
+ self.file
+ }
+
+ pub const fn line(&self) -> u32 {
+ self.line
+ }
+
+ pub const fn column(&self) -> u32 {
+ self.col
+ }
+ }
+ // endregion:panic_location
+
pub macro panic_2021 {
() => ({
const fn panic_cold_explicit() -> ! {