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

Align: add bytes_usize and bits_usize #124579

Merged
merged 1 commit into from
May 2, 2024

Conversation

RalfJung
Copy link
Member

@RalfJung RalfJung commented May 1, 2024

This matches Size::bytes/bits_usize. I recently wanted this in Miri as well.

@rustbot
Copy link
Collaborator

rustbot commented May 1, 2024

r? @fmease

rustbot has assigned @fmease.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 1, 2024
#[inline]
pub fn bits(self) -> u64 {
self.bytes() * 8
}

#[inline]
pub fn bits_usize(self) -> usize {
Copy link
Member

@fmease fmease May 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how I feel about adding a yet unused public method but if you plan on using it soon(tm) in miri, then I'd say it's fine.

Copy link
Member Author

@RalfJung RalfJung May 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW I don't plan to use bits_usize (only bytes_usize), but it exists for Size and I think having a somewhat symmetric API surface here is valuable. It's not always good to remove a function just because it is not used right now, in a large codebase like ours that constantly changes.

@fmease
Copy link
Member

fmease commented May 2, 2024

@bors r+ rollup

@bors
Copy link
Contributor

bors commented May 2, 2024

📌 Commit 65d7478 has been approved by fmease

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 May 2, 2024
fmease added a commit to fmease/rust that referenced this pull request May 2, 2024
Align: add bytes_usize and bits_usize

This matches `Size::bytes/bits_usize`. I recently wanted this in Miri as well.
bors added a commit to rust-lang-ci/rust that referenced this pull request May 2, 2024
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#124138 (Ignore LLVM ABI in dlltool tests since those targets don't use dlltool)
 - rust-lang#124414 (remove extraneous note on `UnableToRunDsymutil` diagnostic)
 - rust-lang#124579 (Align: add bytes_usize and bits_usize)
 - rust-lang#124622 (Cleanup: Rid the `rmake` test runners of `extern crate run_make_support;`)
 - rust-lang#124623 (shallow resolve in orphan check)
 - rust-lang#124624 (Use `tcx.types.unit` instead of `Ty::new_unit(tcx)`)
 - rust-lang#124627 (interpret: hide some reexports in rustdoc)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 490c0d6 into rust-lang:master May 2, 2024
6 checks passed
@rustbot rustbot added this to the 1.80.0 milestone May 2, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request May 2, 2024
Rollup merge of rust-lang#124579 - RalfJung:align-bytes-usize, r=fmease

Align: add bytes_usize and bits_usize

This matches `Size::bytes/bits_usize`. I recently wanted this in Miri as well.
@RalfJung RalfJung deleted the align-bytes-usize branch May 3, 2024 06:15
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-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants