@@ -173,8 +173,14 @@ impl fmt::Display for PanicInfo<'_> {
173
173
///
174
174
/// panic!("Normal panic");
175
175
/// ```
176
+ ///
177
+ /// # Comparisons
178
+ ///
179
+ /// Comparisons for equality and ordering are made in file, line, then column priority. Such
180
+ /// comparisons can occasionally have surprising results. See [`Location::file`]'s documentation for
181
+ /// more discussion.
176
182
#[ lang = "panic_location" ]
177
- #[ derive( Debug ) ]
183
+ #[ derive( Copy , Clone , Debug , Eq , Hash , Ord , PartialEq , PartialOrd ) ]
178
184
#[ stable( feature = "panic_hooks" , since = "1.10.0" ) ]
179
185
pub struct Location < ' a > {
180
186
file : & ' a str ,
@@ -252,6 +258,22 @@ impl<'a> Location<'a> {
252
258
253
259
/// Returns the name of the source file from which the panic originated.
254
260
///
261
+ /// # `&str`, not `&Path`
262
+ ///
263
+ /// The returned name refers to a source path on the compiling system, but it isn't valid to
264
+ /// represent this directly as a `&Path`. The compiled code may run on a different system with
265
+ /// a different `Path` implementation than the system providing the contents and this library
266
+ /// does not currently have a different "host path" type.
267
+ ///
268
+ /// The most surprising behavior occurs when "the same" file is reachable via multiple paths in
269
+ /// the module system (usually using the `#[path = "..."]` attribute or similar), which can
270
+ /// cause what appears to be identical code to return differing values from this function.
271
+ ///
272
+ /// # Cross-compilation
273
+ ///
274
+ /// This value is not suitable for passing to `Path::new` or similar constructors when the host
275
+ /// platform and target platform differ.
276
+ ///
255
277
/// # Examples
256
278
///
257
279
/// ```should_panic
0 commit comments