From 1bdb6064ed0c4ded29a4d8a3c463bffa972b679d Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Thu, 17 Oct 2024 15:01:45 +0200 Subject: [PATCH] remove assertion from file_with_nul --- library/core/src/panic/location.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/library/core/src/panic/location.rs b/library/core/src/panic/location.rs index 7e31e98704673..2f0ac1811b6a1 100644 --- a/library/core/src/panic/location.rs +++ b/library/core/src/panic/location.rs @@ -145,7 +145,7 @@ impl<'a> Location<'a> { #[cfg(debug_assertions)] if !matches!(s.as_bytes().last(), Some(0)) { - panic!("filename is not nul terminated"); + panic!("filename is not nul-terminated"); } // SAFETY: The string contains a nul-byte, so the length is at least one. @@ -221,11 +221,6 @@ impl<'a> Location<'a> { pub fn file_with_nul(&self) -> &CStr { let file_with_nul = self.file_with_nul.as_bytes(); - #[cfg(debug_assertions)] - if !matches!(file_with_nul.last(), Some(0)) { - panic!("filename is not nul terminated"); - } - // SAFETY: This struct is only ever constructed by the compiler, which always inserts a // nul-terminator in this string. unsafe { CStr::from_bytes_with_nul_unchecked(file_with_nul) }