@@ -296,7 +296,7 @@ macro_rules! asm {
296
296
297
297
/// Gets the C string file name of a [`Location`].
298
298
///
299
- /// If `file_with_nul ()` is not available, returns a string that warns about it.
299
+ /// If `Location::file_as_c_str ()` is not available, returns a string that warns about it.
300
300
///
301
301
/// [`Location`]: core::panic::Location
302
302
///
@@ -310,8 +310,8 @@ macro_rules! asm {
310
310
/// let caller = core::panic::Location::caller();
311
311
///
312
312
/// // Output:
313
- /// // - A path like "rust/kernel/example.rs" if file_with_nul() is available.
314
- /// // - "<Location::file_with_nul () not supported>" otherwise.
313
+ /// // - A path like "rust/kernel/example.rs" if `file_as_c_str()` is available.
314
+ /// // - "<Location::file_as_c_str () not supported>" otherwise.
315
315
/// let caller_file = file_from_location(caller);
316
316
///
317
317
/// // Prints out the message with caller's file name.
@@ -326,14 +326,19 @@ macro_rules! asm {
326
326
/// ```
327
327
#[ inline]
328
328
pub fn file_from_location < ' a > ( loc : & ' a core:: panic:: Location < ' a > ) -> & ' a core:: ffi:: CStr {
329
- #[ cfg( CONFIG_RUSTC_HAS_FILE_WITH_NUL ) ]
329
+ #[ cfg( CONFIG_RUSTC_HAS_FILE_AS_C_STR ) ]
330
+ {
331
+ loc. file_as_c_str ( )
332
+ }
333
+
334
+ #[ cfg( all( CONFIG_RUSTC_HAS_FILE_WITH_NUL , not( CONFIG_RUSTC_HAS_FILE_AS_C_STR ) ) ) ]
330
335
{
331
336
loc. file_with_nul ( )
332
337
}
333
338
334
339
#[ cfg( not( CONFIG_RUSTC_HAS_FILE_WITH_NUL ) ) ]
335
340
{
336
341
let _ = loc;
337
- c"<Location::file_with_nul () not supported>"
342
+ c"<Location::file_as_c_str () not supported>"
338
343
}
339
344
}
0 commit comments