-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Fix - Upcoming arithmetic_side_effects lints
#33000
Fix - Upcoming arithmetic_side_effects lints
#33000
Conversation
|
i'd like to review some of the introduced unwraps here before merging |
I think the main ones that stood out to me are the ones with the compute budget. Those appear to be defined as constants initialized in Other unwraps involving |
a32b94d to
9a84379
Compare
|
I made all the divisions which have a non-constant divisor (those used in CU consumption) to be |
t-nelson
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pushed a few more commits to wrap up arithmetic_side_effects compatibility
| compute_budget | ||
| .sha256_byte_cost | ||
| .saturating_mul((val.len() as u64).saturating_div(2)), | ||
| .saturating_mul((val.len() as u64).checked_div(2).unwrap()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's annoying that the lint can't resolve non-zero literals. compiler can know this div is safe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it generate a linter warning?
At -O it is compiled to a bit shift:
pub fn square(num: u64) -> u64 {
num.checked_div(2).unwrap()
}example::square:
mov rax, rdi
shr rax
retThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that happens in LLVM, not in rustc. In other words, rustc is probably unaware.
513596b to
0b2e923
Compare
0b2e923 to
7643cbb
Compare
|
was the commit that switched unwraps to expects dropped intentionally/ |
n/m, i see that it was squashed in. more rebase hell than i was hoping for this early in the day 😅 |
|
Yes, I reordered and squashed the commits to reduce the forward / backward changes. |
7643cbb to
bbc8981
Compare
Problem
This PR is another preparation for #32961.
saturatingandwrappingversions ofdivandremwill no longer be accepted.Summary of Changes
Replaces them with their
checkedversion.