Skip to content

silenced a bunch of misleading Clippy warnings #176

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

Merged
merged 1 commit into from
Nov 17, 2020

Conversation

BartMassey
Copy link

@BartMassey BartMassey commented Nov 14, 2020

  • There were a bunch of code quality Clippy warnings that didn't apply for various reasons.

  • There was an ok_or() that could have been an ok_or_else() that Clippy caught. Turns out it's for a ZST, so doesn't matter, but was "fixed" anyway to silence Clippy.

This will hopefully make "cargo clippy" more useful for the next person.

@BartMassey
Copy link
Author

@cuviper These diffs are a bit gratuitous but I think they'll be a net positive. I chose to silence Clippy rather than change working code any more than necessary. Hopefully cutting down the Clippy noise will help the next person.

Copy link
Member

@cuviper cuviper left a comment

Choose a reason for hiding this comment

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

👍 for making clippy more useful here.

@@ -347,6 +347,7 @@ fn bigint_from_slice(slice: &[BigDigit]) -> BigInt {
BigInt::from(biguint_from_vec(slice.to_vec()))
}

#[allow(clippy::many_single_char_names)]
Copy link
Member

Choose a reason for hiding this comment

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

Style-wise, I'd prefer attributes to be placed after doc comments, directly before the code they modify.

Copy link
Author

Choose a reason for hiding this comment

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

Got all these, I think.

value.to_biguint().ok_or(TryFromBigIntError::new(()))
value
.to_biguint()
.ok_or_else(|| TryFromBigIntError::new(()))
Copy link
Member

Choose a reason for hiding this comment

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

I think clippy is being overly fussy here since TryFromBigIntError<()> is a ZST, and new isn't doing anything significant, but I guess there's no harm in wrapping this. Another option would be to write this as a direct struct initialization for the ZST, but I think it won't matter for performance either way.

Copy link
Author

Choose a reason for hiding this comment

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

Ah. Yeah, I think it's probably the cleanest way to shut Clippy up.

1 => u64::from(v.data[0]),
1 =>
{
#[allow(clippy::useless_conversion)]
Copy link
Member

Choose a reason for hiding this comment

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

Why is the attribute repeated here?

Copy link
Author

Choose a reason for hiding this comment

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

Mistake. Fixed.

@BartMassey BartMassey changed the title silenced a bunch of misleading Clippy warnings; fixed a possible perf bug silenced a bunch of misleading Clippy warnings Nov 17, 2020
@cuviper
Copy link
Member

cuviper commented Nov 17, 2020

bors r+

@bors
Copy link
Contributor

bors bot commented Nov 17, 2020

@bors bors bot merged commit d782512 into rust-num:master Nov 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants