Skip to content

Commit

Permalink
remove assertion from file_with_nul
Browse files Browse the repository at this point in the history
  • Loading branch information
Darksonn committed Oct 17, 2024
1 parent 0ab3051 commit 1bdb606
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions library/core/src/panic/location.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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) }
Expand Down

0 comments on commit 1bdb606

Please sign in to comment.