diff options
| author | Isaac Chen <isaacjchen1@gmail.com> | 2025-08-02 16:53:06 -0400 |
|---|---|---|
| committer | Isaac Chen <isaacjchen1@gmail.com> | 2025-08-02 17:04:08 -0400 |
| commit | 8a0438fee86b7dc566d0758b3aee050b84edc842 (patch) | |
| tree | 08aaea120a4da65250102cae8a3a6e5810ea07c2 | |
| parent | 557737062d1a65b25f9bbb257f07755078e5cdae (diff) | |
moved new test to updated test location
| -rw-r--r-- | library/core/tests/panic/location.rs | 39 | ||||
| -rw-r--r-- | library/coretests/tests/panic/location.rs | 8 |
2 files changed, 8 insertions, 39 deletions
diff --git a/library/core/tests/panic/location.rs b/library/core/tests/panic/location.rs deleted file mode 100644 index 35017612f00..00000000000 --- a/library/core/tests/panic/location.rs +++ /dev/null @@ -1,39 +0,0 @@ -use core::panic::Location; - -// Note: Some of the following tests depend on the source location, -// so please be careful when editing this file. - -#[test] -fn location_const_caller() { - const _CALLER_REFERENCE: &Location<'static> = Location::caller(); - const _CALLER: Location<'static> = *Location::caller(); -} - -#[test] -fn location_const_file() { - const CALLER: &Location<'static> = Location::caller(); - const FILE: &str = CALLER.file(); - assert_eq!(FILE, file!()); -} - -#[test] -fn location_const_line() { - const CALLER: &Location<'static> = Location::caller(); - const LINE: u32 = CALLER.line(); - assert_eq!(LINE, 21); -} - -#[test] -fn location_const_column() { - const CALLER: &Location<'static> = Location::caller(); - const COLUMN: u32 = CALLER.column(); - assert_eq!(COLUMN, 40); -} - -#[test] -fn location_file_lifetime<'x>() { - // Verify that the returned `&str`s lifetime is derived from the generic - // lifetime 'a, not the lifetime of `&self`, when calling `Location::file`. - // Test failure is indicated by a compile failure, not a runtime panic. - let _: for<'a> fn(&'a Location<'x>) -> &'x str = Location::file; -} diff --git a/library/coretests/tests/panic/location.rs b/library/coretests/tests/panic/location.rs index 910001bcc1c..2174ac854e9 100644 --- a/library/coretests/tests/panic/location.rs +++ b/library/coretests/tests/panic/location.rs @@ -48,6 +48,14 @@ fn location_const_column() { } #[test] +fn location_file_lifetime<'x>() { + // Verify that the returned `&str`s lifetime is derived from the generic + // lifetime 'a, not the lifetime of `&self`, when calling `Location::file`. + // Test failure is indicated by a compile failure, not a runtime panic. + let _: for<'a> fn(&'a Location<'x>) -> &'x str = Location::file; +} + +#[test] fn location_debug() { let f = format!("{:?}", Location::caller()); assert!(f.contains(&format!("{:?}", file!()))); |
