about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--library/core/src/str/validations.rs10
1 files changed, 4 insertions, 6 deletions
diff --git a/library/core/src/str/validations.rs b/library/core/src/str/validations.rs
index fc8f47dced4..a078bf92a27 100644
--- a/library/core/src/str/validations.rs
+++ b/library/core/src/str/validations.rs
@@ -163,7 +163,7 @@ pub(super) fn run_utf8_validation(v: &[u8]) -> Result<(), Utf8Error> {
             //               %xF4 %x80-8F 2( UTF8-tail )
             match w {
                 2 => {
-                    if next!() & !CONT_MASK != TAG_CONT_U8 {
+                    if !utf8_is_cont_byte(next!()) {
                         err!(Some(1))
                     }
                 }
@@ -175,7 +175,7 @@ pub(super) fn run_utf8_validation(v: &[u8]) -> Result<(), Utf8Error> {
                         | (0xEE..=0xEF, 0x80..=0xBF) => {}
                         _ => err!(Some(1)),
                     }
-                    if next!() & !CONT_MASK != TAG_CONT_U8 {
+                    if !utf8_is_cont_byte(next!()) {
                         err!(Some(2))
                     }
                 }
@@ -184,10 +184,10 @@ pub(super) fn run_utf8_validation(v: &[u8]) -> Result<(), Utf8Error> {
                         (0xF0, 0x90..=0xBF) | (0xF1..=0xF3, 0x80..=0xBF) | (0xF4, 0x80..=0x8F) => {}
                         _ => err!(Some(1)),
                     }
-                    if next!() & !CONT_MASK != TAG_CONT_U8 {
+                    if !utf8_is_cont_byte(next!()) {
                         err!(Some(2))
                     }
-                    if next!() & !CONT_MASK != TAG_CONT_U8 {
+                    if !utf8_is_cont_byte(next!()) {
                         err!(Some(3))
                     }
                 }
@@ -258,8 +258,6 @@ pub fn utf8_char_width(b: u8) -> usize {
 
 /// Mask of the value bits of a continuation byte.
 const CONT_MASK: u8 = 0b0011_1111;
-/// Value of the tag bits (tag mask is !CONT_MASK) of a continuation byte.
-const TAG_CONT_U8: u8 = 0b1000_0000;
 
 // truncate `&str` to length at most equal to `max`
 // return `true` if it were truncated, and the new str.