diff options
| author | Jacob Pratt <jacob@jhpratt.dev> | 2025-08-22 22:00:44 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-22 22:00:44 -0400 |
| commit | dbc38eed1dc7fba0a6c3d6c3edc4ec1f8fa88099 (patch) | |
| tree | bf585068c5f5726305731a6740becefdb298f38f /library/coretests | |
| parent | 6545b056388a727c2ac4a4e70fb01d60a11398b1 (diff) | |
| parent | 792ec3bdd42800bfbf16ee1d570efc398bf30f30 (diff) | |
| download | rust-dbc38eed1dc7fba0a6c3d6c3edc4ec1f8fa88099.tar.gz rust-dbc38eed1dc7fba0a6c3d6c3edc4ec1f8fa88099.zip | |
Rollup merge of #132087 - ijchen:issue-131770-fix, r=dtolnay
Fix overly restrictive lifetime in `core::panic::Location::file` return type Fixes #131770 by relaxing the lifetime to match what's stored in the struct. See that issue for more details and discussion. Since this is a breaking change, I think a crater run is in order. Since this change should only have an effect at compile-time, I think just a check run is sufficient.
Diffstat (limited to 'library/coretests')
| -rw-r--r-- | library/coretests/tests/panic/location.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/library/coretests/tests/panic/location.rs b/library/coretests/tests/panic/location.rs index 910001bcc1c..a7db05a15c6 100644 --- a/library/coretests/tests/panic/location.rs +++ b/library/coretests/tests/panic/location.rs @@ -48,10 +48,18 @@ 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!()))); - assert!(f.contains("52")); + assert!(f.contains("60")); assert!(f.contains("29")); } |
