Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More IS_ZST in library #110635

Merged
merged 1 commit into from
Apr 22, 2023
Merged

More IS_ZST in library #110635

merged 1 commit into from
Apr 22, 2023

Conversation

scottmcm
Copy link
Member

I noticed that post_inc_start and pre_dec_end were doing this check in different ways

if mem::size_of::<T>() == 0 {
zst_shrink!(self, offset);
self.ptr.as_ptr()
} else {
let old = self.ptr.as_ptr();
// SAFETY: the caller guarantees that `offset` doesn't exceed `self.len()`,
// so this new pointer is inside `self` and thus guaranteed to be non-null.
self.ptr = unsafe { NonNull::new_unchecked(self.ptr.as_ptr().add(offset)) };
old
}
}
// Helper function for moving the end of the iterator backwards by `offset` elements,
// returning the new end.
// Unsafe because the offset must not exceed `self.len()`.
#[inline(always)]
unsafe fn pre_dec_end(&mut self, offset: usize) -> * $raw_mut T {
if T::IS_ZST {

so started making this PR, then added a few more I found since I was already making changes anyway.

@rustbot
Copy link
Collaborator

rustbot commented Apr 21, 2023

r? @Mark-Simulacrum

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Apr 21, 2023
@rustbot

This comment was marked as resolved.

I noticed that `post_inc_start` and `pre_dec_end` were doing this check in different ways

https://github.com/rust-lang/rust/blob/d19b64fb54391b64ce99981577c67c93ac2a9ffa/library/core/src/slice/iter/macros.rs#L76-L93

so started making this PR, then added a few more I found since I was already making changes anyway.
@the8472
Copy link
Member

the8472 commented Apr 21, 2023

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Apr 21, 2023

📌 Commit 56613f8 has been approved by the8472

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 21, 2023
@scottmcm
Copy link
Member Author

scottmcm commented Apr 22, 2023

Oops, pushed commits to the wrong branch, sorry.

I've forced it back to the one in the bors approval.

bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 22, 2023
Rollup of 7 pull requests

Successful merges:

 - rust-lang#109949 (rustdoc: migrate `document_type_layout` to askama)
 - rust-lang#110622 (Stable hash tag (discriminant) of `GenericArg`)
 - rust-lang#110635 (More `IS_ZST` in `library`)
 - rust-lang#110640 (compiler/rustc_target: Raise m68k-linux-gnu baseline to 68020)
 - rust-lang#110657 (nit: consistent naming for SimplifyConstCondition)
 - rust-lang#110659 (rustdoc: clean up JS)
 - rust-lang#110660 (Print ty placeholders pretty)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 581e741 into rust-lang:master Apr 22, 2023
@rustbot rustbot added this to the 1.71.0 milestone Apr 22, 2023
@scottmcm scottmcm deleted the zst-checks branch April 22, 2023 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants