Skip to content

Commit 5a67292

Browse files
committed
replace as usize casts with usize::from in slice sort
1 parent fff92d5 commit 5a67292

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

library/core/src/slice/sort.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -365,12 +365,12 @@ where
365365
if count > 0 {
366366
macro_rules! left {
367367
() => {
368-
l.add(*start_l as usize)
368+
l.add(usize::from(*start_l))
369369
};
370370
}
371371
macro_rules! right {
372372
() => {
373-
r.sub((*start_r as usize) + 1)
373+
r.sub(usize::from(*start_r) + 1)
374374
};
375375
}
376376

@@ -458,7 +458,7 @@ where
458458
// the last block, so the `l.offset` calls are valid.
459459
unsafe {
460460
end_l = end_l.sub(1);
461-
ptr::swap(l.add(*end_l as usize), r.sub(1));
461+
ptr::swap(l.add(usize::from(*end_l)), r.sub(1));
462462
r = r.sub(1);
463463
}
464464
}
@@ -471,7 +471,7 @@ where
471471
// SAFETY: See the reasoning in [remaining-elements-safety].
472472
unsafe {
473473
end_r = end_r.sub(1);
474-
ptr::swap(l, r.sub((*end_r as usize) + 1));
474+
ptr::swap(l, r.sub(usize::from(*end_r) + 1));
475475
l = l.add(1);
476476
}
477477
}

0 commit comments

Comments
 (0)