Skip to content

Conversation

falk-hueffner
Copy link

The value is at most 128, and this is consistent with using u32 for small values elsewhere (e.g. BITS, count_ones, leading_zeros).

most 128, and this is consistent with using u32 for small values
elsewhere (e.g. BITS, count_ones, leading_zeros).
@rust-highfive
Copy link
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Mark-Simulacrum (or someone else) soon.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 5, 2021
@falk-hueffner
Copy link
Author

See also the comment here #70887 (comment)

@scottmcm
Copy link
Member

scottmcm commented Sep 6, 2021

I think this makes good sense to me. u32::log2 for me is just the more useful version of leading_zeros, so having the same return type there seems logical. And I saw that @joshtriplett 👍'd the comment so I'll count that as a libs "seems reasonable" for the change, since this is just unstable anyway.

r? @scottmcm
@bors r+

@bors
Copy link
Collaborator

bors commented Sep 6, 2021

📌 Commit d760c33 has been approved by scottmcm

@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 Sep 6, 2021
@bors
Copy link
Collaborator

bors commented Sep 6, 2021

⌛ Testing commit d760c33 with merge b2d9bcd...

@bors
Copy link
Collaborator

bors commented Sep 6, 2021

☀️ Test successful - checks-actions
Approved by: scottmcm
Pushing b2d9bcd to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 6, 2021
@bors bors merged commit b2d9bcd into rust-lang:master Sep 6, 2021
@rustbot rustbot added this to the 1.57.0 milestone Sep 6, 2021
@agausmann
Copy link
Contributor

agausmann commented Nov 19, 2021

Super late, but I think it's worth specifically pointing out: this change also agrees with the signature of integer power functions (e.g. u64::pow). All of them use u32 for the exponent argument.

So with this change, this (albeit contrived) expression passes typechecking, if x: u32:
2u64.pow(x).log2() == x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants