Skip to content

Commit

Permalink
Auto merge of #111447 - scottmcm:remove-more-assumes, r=thomcc
Browse files Browse the repository at this point in the history
Remove useless `assume`s from `slice::iter(_mut)`

You were right in rust-lang/rust#111395 (comment),
r? `@the8472`

LLVM already removes these assumes while optimizing, as can be seen in <https://rust.godbolt.org/z/KTfWKbdEM>.
  • Loading branch information
bors committed May 13, 2023
2 parents 971ef73 + f032a84 commit f86db5e
Showing 1 changed file with 0 additions and 4 deletions.
4 changes: 0 additions & 4 deletions core/src/slice/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ impl<'a, T> Iter<'a, T> {
let ptr = slice.as_ptr();
// SAFETY: Similar to `IterMut::new`.
unsafe {
assume(!ptr.is_null());

let end = if T::IS_ZST { invalid(slice.len()) } else { ptr.add(slice.len()) };

Self { ptr: NonNull::new_unchecked(ptr as *mut T), end, _marker: PhantomData }
Expand Down Expand Up @@ -228,8 +226,6 @@ impl<'a, T> IterMut<'a, T> {
// See the `next_unchecked!` and `is_empty!` macros as well as the
// `post_inc_start` method for more information.
unsafe {
assume(!ptr.is_null());

let end = if T::IS_ZST { invalid_mut(slice.len()) } else { ptr.add(slice.len()) };

Self { ptr: NonNull::new_unchecked(ptr), end, _marker: PhantomData }
Expand Down

0 comments on commit f86db5e

Please sign in to comment.