@@ -157,8 +157,8 @@ impl StrDrive for &str {
157157#[ inline]
158158unsafe fn next_code_point ( ptr : & mut * const u8 ) -> u32 {
159159 // Decode UTF-8
160- let x = * * ptr;
161- * ptr = ptr. offset ( 1 ) ;
160+ let x = unsafe { * * ptr} ;
161+ * ptr = unsafe { ptr. offset ( 1 ) } ;
162162
163163 if x < 128 {
164164 return x as u32 ;
@@ -170,25 +170,25 @@ unsafe fn next_code_point(ptr: &mut *const u8) -> u32 {
170170 let init = utf8_first_byte ( x, 2 ) ;
171171 // SAFETY: `bytes` produces an UTF-8-like string,
172172 // so the iterator must produce a value here.
173- let y = * * ptr;
174- * ptr = ptr. offset ( 1 ) ;
173+ let y = unsafe { * * ptr } ;
174+ * ptr = unsafe { ptr. offset ( 1 ) } ;
175175 let mut ch = utf8_acc_cont_byte ( init, y) ;
176176 if x >= 0xE0 {
177177 // [[x y z] w] case
178178 // 5th bit in 0xE0 .. 0xEF is always clear, so `init` is still valid
179179 // SAFETY: `bytes` produces an UTF-8-like string,
180180 // so the iterator must produce a value here.
181- let z = * * ptr;
182- * ptr = ptr. offset ( 1 ) ;
181+ let z = unsafe { * * ptr } ;
182+ * ptr = unsafe { ptr. offset ( 1 ) } ;
183183 let y_z = utf8_acc_cont_byte ( ( y & CONT_MASK ) as u32 , z) ;
184184 ch = ( init << 12 ) | y_z;
185185 if x >= 0xF0 {
186186 // [x y z w] case
187187 // use only the lower 3 bits of `init`
188188 // SAFETY: `bytes` produces an UTF-8-like string,
189189 // so the iterator must produce a value here.
190- let w = * * ptr;
191- * ptr = ptr. offset ( 1 ) ;
190+ let w = unsafe { * * ptr} ;
191+ * ptr = unsafe { ptr. offset ( 1 ) } ;
192192 ch = ( ( init & 7 ) << 18 ) | utf8_acc_cont_byte ( y_z, w) ;
193193 }
194194 }
@@ -205,8 +205,8 @@ unsafe fn next_code_point(ptr: &mut *const u8) -> u32 {
205205#[ inline]
206206unsafe fn next_code_point_reverse ( ptr : & mut * const u8 ) -> u32 {
207207 // Decode UTF-8
208- * ptr = ptr. offset ( -1 ) ;
209- let w = match * * ptr {
208+ * ptr = unsafe { ptr. offset ( -1 ) } ;
209+ let w = match unsafe { * * ptr } {
210210 next_byte if next_byte < 128 => return next_byte as u32 ,
211211 back_byte => back_byte,
212212 } ;
@@ -216,20 +216,20 @@ unsafe fn next_code_point_reverse(ptr: &mut *const u8) -> u32 {
216216 let mut ch;
217217 // SAFETY: `bytes` produces an UTF-8-like string,
218218 // so the iterator must produce a value here.
219- * ptr = ptr. offset ( -1 ) ;
220- let z = * * ptr;
219+ * ptr = unsafe { ptr. offset ( -1 ) } ;
220+ let z = unsafe { * * ptr } ;
221221 ch = utf8_first_byte ( z, 2 ) ;
222222 if utf8_is_cont_byte ( z) {
223223 // SAFETY: `bytes` produces an UTF-8-like string,
224224 // so the iterator must produce a value here.
225- * ptr = ptr. offset ( -1 ) ;
226- let y = * * ptr;
225+ * ptr = unsafe { ptr. offset ( -1 ) } ;
226+ let y = unsafe { * * ptr } ;
227227 ch = utf8_first_byte ( y, 3 ) ;
228228 if utf8_is_cont_byte ( y) {
229229 // SAFETY: `bytes` produces an UTF-8-like string,
230230 // so the iterator must produce a value here.
231- * ptr = ptr. offset ( -1 ) ;
232- let x = * * ptr;
231+ * ptr = unsafe { ptr. offset ( -1 ) } ;
232+ let x = unsafe { * * ptr } ;
233233 ch = utf8_first_byte ( x, 4 ) ;
234234 ch = utf8_acc_cont_byte ( ch, y) ;
235235 }
0 commit comments