@@ -157,8 +157,8 @@ impl StrDrive for &str {
157
157
#[ inline]
158
158
unsafe fn next_code_point ( ptr : & mut * const u8 ) -> u32 {
159
159
// Decode UTF-8
160
- let x = * * ptr;
161
- * ptr = ptr. offset ( 1 ) ;
160
+ let x = unsafe { * * ptr} ;
161
+ * ptr = unsafe { ptr. offset ( 1 ) } ;
162
162
163
163
if x < 128 {
164
164
return x as u32 ;
@@ -170,25 +170,25 @@ unsafe fn next_code_point(ptr: &mut *const u8) -> u32 {
170
170
let init = utf8_first_byte ( x, 2 ) ;
171
171
// SAFETY: `bytes` produces an UTF-8-like string,
172
172
// 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 ) } ;
175
175
let mut ch = utf8_acc_cont_byte ( init, y) ;
176
176
if x >= 0xE0 {
177
177
// [[x y z] w] case
178
178
// 5th bit in 0xE0 .. 0xEF is always clear, so `init` is still valid
179
179
// SAFETY: `bytes` produces an UTF-8-like string,
180
180
// 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 ) } ;
183
183
let y_z = utf8_acc_cont_byte ( ( y & CONT_MASK ) as u32 , z) ;
184
184
ch = ( init << 12 ) | y_z;
185
185
if x >= 0xF0 {
186
186
// [x y z w] case
187
187
// use only the lower 3 bits of `init`
188
188
// SAFETY: `bytes` produces an UTF-8-like string,
189
189
// 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 ) } ;
192
192
ch = ( ( init & 7 ) << 18 ) | utf8_acc_cont_byte ( y_z, w) ;
193
193
}
194
194
}
@@ -205,8 +205,8 @@ unsafe fn next_code_point(ptr: &mut *const u8) -> u32 {
205
205
#[ inline]
206
206
unsafe fn next_code_point_reverse ( ptr : & mut * const u8 ) -> u32 {
207
207
// 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 } {
210
210
next_byte if next_byte < 128 => return next_byte as u32 ,
211
211
back_byte => back_byte,
212
212
} ;
@@ -216,20 +216,20 @@ unsafe fn next_code_point_reverse(ptr: &mut *const u8) -> u32 {
216
216
let mut ch;
217
217
// SAFETY: `bytes` produces an UTF-8-like string,
218
218
// 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 } ;
221
221
ch = utf8_first_byte ( z, 2 ) ;
222
222
if utf8_is_cont_byte ( z) {
223
223
// SAFETY: `bytes` produces an UTF-8-like string,
224
224
// 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 } ;
227
227
ch = utf8_first_byte ( y, 3 ) ;
228
228
if utf8_is_cont_byte ( y) {
229
229
// SAFETY: `bytes` produces an UTF-8-like string,
230
230
// 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 } ;
233
233
ch = utf8_first_byte ( x, 4 ) ;
234
234
ch = utf8_acc_cont_byte ( ch, y) ;
235
235
}
0 commit comments