Skip to content

Commit

Permalink
Rollup merge of #103159 - cuviper:check_pow-final-try_opt, r=Mark-Sim…
Browse files Browse the repository at this point in the history
…ulacrum

Remove the redundant `Some(try_opt!(..))` in `checked_pow`

The final return value doesn't need to be tried at all -- we can just
return the checked option directly. The optimizer can probably figure
this out anyway, but there's no need to make it work here.
  • Loading branch information
Dylan-DPC authored Oct 18, 2022
2 parents 4934f6f + d7fd1d5 commit b753ffd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion library/core/src/num/int_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ macro_rules! int_impl {
// Deal with the final bit of the exponent separately, since
// squaring the base afterwards is not necessary and may cause a
// needless overflow.
Some(try_opt!(acc.checked_mul(base)))
acc.checked_mul(base)
}

/// Saturating integer addition. Computes `self + rhs`, saturating at the numeric
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/num/uint_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ macro_rules! uint_impl {
// squaring the base afterwards is not necessary and may cause a
// needless overflow.

Some(try_opt!(acc.checked_mul(base)))
acc.checked_mul(base)
}

/// Saturating integer addition. Computes `self + rhs`, saturating at
Expand Down

0 comments on commit b753ffd

Please sign in to comment.