mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
refactor(codegen): clarify safety comments in CodeBuffer (#6494)
This commit is contained in:
parent
84a51ee576
commit
951def6e35
1 changed files with 2 additions and 4 deletions
|
|
@ -339,9 +339,7 @@ impl CodeBuffer {
|
|||
}
|
||||
#[cfg(not(debug_assertions))]
|
||||
{
|
||||
// SAFETY: `buf` is valid UTF-8 because of invariants upheld by
|
||||
// CodeBuffer. If, for some reason, it is not, this is caused by
|
||||
// improper use of `unsafe` printing methods.
|
||||
// SAFETY: All methods of `CodeBuffer` ensure `buf` is valid UTF-8
|
||||
unsafe { String::from_utf8_unchecked(take(&mut self.buf)) }
|
||||
}
|
||||
}
|
||||
|
|
@ -359,7 +357,7 @@ impl From<CodeBuffer> for String {
|
|||
if cfg!(debug_assertions) {
|
||||
String::from_utf8(buffer.buf).unwrap()
|
||||
} else {
|
||||
// SAFETY: `buf` is valid UTF-8 because of invariants upheld by `CodeBuffer`
|
||||
// SAFETY: All methods of `CodeBuffer` ensure `buf` is valid UTF-8
|
||||
unsafe { String::from_utf8_unchecked(buffer.buf) }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue