Skip to content

Conversation

@newpavlov
Copy link
Member

No description provided.

@newpavlov newpavlov requested a review from dhardy October 14, 2024 14:01
)
)]
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.

)
)]
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
benjamin-lieser pushed a commit to benjamin-lieser/rand that referenced this pull request Feb 5, 2025
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.

3 participants