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

Fix new Clippy lints #1511

Merged
merged 2 commits into from
Oct 15, 2024
Merged

Fix new Clippy lints #1511

merged 2 commits into from
Oct 15, 2024

Conversation

newpavlov
Copy link
Member

No description provided.

@newpavlov newpavlov requested a review from dhardy October 14, 2024 14:01
@@ -123,7 +123,7 @@ pub trait CryptoBlockRng: BlockRngCore {}
bound = "for<'x> R: Serialize + Deserialize<'x> + Sized, for<'x> R::Results: Serialize + Deserialize<'x>"
)
)]
pub struct BlockRng<R: BlockRngCore + ?Sized> {
pub struct BlockRng<R: BlockRngCore> {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is changed because of the following warning:

warning: `?Sized` bound is ignored because of a `Sized` requirement
note: ...because `Deserialize` has the bound `Sized`

AFAIK we can not use this trait with DSTs either way, since we store core by value, so the ?Sized bound is not needed.

Copy link
Member

Choose a reason for hiding this comment

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

Rust does permit the last field of a struct to be unsized, but I can't see it being useful.

In this case we can drop the + Sized bound three lines up.

Copy link
Member Author

@newpavlov newpavlov Oct 15, 2024

Choose a reason for hiding this comment

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

Rust does permit the last field of a struct to be unsized,

Huh, TIL. I guess it's not surprising I did not encounter it in practice since in its current form it's a virtually useless feature and even docs state that:

Yes, custom DSTs are a largely half-baked feature for now.

@@ -123,7 +123,7 @@ pub trait CryptoBlockRng: BlockRngCore {}
bound = "for<'x> R: Serialize + Deserialize<'x> + Sized, for<'x> R::Results: Serialize + Deserialize<'x>"
)
)]
pub struct BlockRng<R: BlockRngCore + ?Sized> {
pub struct BlockRng<R: BlockRngCore> {
Copy link
Member

Choose a reason for hiding this comment

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

Rust does permit the last field of a struct to be unsized, but I can't see it being useful.

In this case we can drop the + Sized bound three lines up.

impl<'a, T, D: Distribution<T> + ?Sized> Distribution<T> for &'a D {
impl<T, D: Distribution<T> + ?Sized> Distribution<T> for &D {
Copy link
Member

Choose a reason for hiding this comment

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

Clippy is pedantically complaining that we're being too pedantic?

(Sorry, I'll drop the sarcasm! This is fine.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Heh, to be fair, it's a good lint for raising awareness that such elision is allowed. As an "old-timer" who was using Rust since before 1.31, I automatically was using the "pedantic" style everywhere.

@newpavlov newpavlov merged commit 695fc9a into master Oct 15, 2024
14 checks passed
@newpavlov newpavlov deleted the clippy_fix branch October 15, 2024 23:54
benjamin-lieser pushed a commit to benjamin-lieser/rand that referenced this pull request Oct 24, 2024
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