Skip to content

Commit b399e7e

Browse files
Correct safety reasoning in str::make_ascii_{lower,upper}case()
1 parent 2310da4 commit b399e7e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

library/core/src/str/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2407,7 +2407,7 @@ impl str {
24072407
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
24082408
#[inline]
24092409
pub fn make_ascii_uppercase(&mut self) {
2410-
// SAFETY: safe because we transmute two types with the same layout.
2410+
// SAFETY: changing ASCII letters only does not invalidate UTF-8.
24112411
let me = unsafe { self.as_bytes_mut() };
24122412
me.make_ascii_uppercase()
24132413
}
@@ -2434,7 +2434,7 @@ impl str {
24342434
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
24352435
#[inline]
24362436
pub fn make_ascii_lowercase(&mut self) {
2437-
// SAFETY: safe because we transmute two types with the same layout.
2437+
// SAFETY: changing ASCII letters only does not invalidate UTF-8.
24382438
let me = unsafe { self.as_bytes_mut() };
24392439
me.make_ascii_lowercase()
24402440
}

0 commit comments

Comments
 (0)