Skip to content

Conversation

@Eligioo
Copy link
Member

@Eligioo Eligioo commented Jul 26, 2024

Various Clippy fixes with Rust 1.80.

Noticeable changes causing most new Clippy warnings:

The unexpected cfg condition value parallel will be addressed in a separate PR.

@Eligioo Eligioo force-pushed the stefan/clippy-fixes branch from 6e7a0f3 to 728f67e Compare July 26, 2024 09:54
Copy link
Contributor

@hrxi hrxi left a comment

Choose a reason for hiding this comment

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

Can you add the names of the clippy warnings that you fix to the commit description?

Cow::Borrowed(slice::from_raw_parts(
self as *const $typ as *const u8,
mem::size_of::<$typ>(),
size_of::<$typ>(),
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the minimum required Rust version for this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Hm. Sounds a bit annoying to bump up our MSRV just to silence a warning. Perhaps we can simply disable the warning for now?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed by allowing this Clippy lint

/// * AddStake
/// The type of transaction, parameters and proof are given in the data field of the transaction.
///
/// The type of transaction, parameters and proof are given in the data field of the transaction.
Copy link
Contributor

Choose a reason for hiding this comment

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

This fix seems incorrect(?). It looks like it should belong inside the 1..

Copy link
Member Author

Choose a reason for hiding this comment

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

It's part of 1. but being on the next line directly after * AddStake it thinks its part of the list thus needs to be indented up to the same level.

Copy link
Contributor

Choose a reason for hiding this comment

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

Before: image.
After: image.

Both are incorrect, as far as I can tell.

Before, it was part of * AddStake which is clearly incorrect. Afterwards, it's now a free-standing text, but it should be part of the first enumeration item "1.".

I don't know if that can be fixed properly.

If not, perhaps we could reword the text so that

The type of transaction, parameters and proof are given in the data field of the transaction.

can right after the "1."?

Copy link
Member Author

Choose a reason for hiding this comment

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

Addressed

/// * RemoveStake
/// The type of transaction, parameters and proof are given in the proof field of the transaction.
///
/// The type of transaction, parameters and proof are given in the proof field of the transaction.
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above.

Copy link
Member Author

Choose a reason for hiding this comment

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

Commented above

Copy link
Member Author

Choose a reason for hiding this comment

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

Addressed

fn from(signature: G1Projective) -> Self {
let mut buffer = [0u8; SIZE];
CanonicalSerialize::serialize_compressed(&signature.into_affine(), &mut &mut buffer[..])
CanonicalSerialize::serialize_compressed(&signature.into_affine(), &mut buffer[..])
Copy link
Contributor

Choose a reason for hiding this comment

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

What warning does this fix?

Copy link
Member Author

Choose a reason for hiding this comment

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

warning: the borrowed expression implements the required traits
  --> bls/src/types/compressed_signature.rs:96:76
   |
96 |         CanonicalSerialize::serialize_compressed(&signature.into_affine(), &mut &mut buffer[..])
   |                                                                            ^^^^^^^^^^^^^^^^^^^^ help: change this to: `&mut buffer[..]`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrows_for_generic_args
   = note: `#[warn(clippy::needless_borrows_for_generic_args)]` on by default

@Eligioo Eligioo force-pushed the stefan/clippy-fixes branch from 728f67e to fb9ee0b Compare July 26, 2024 12:50
@Eligioo Eligioo marked this pull request as ready for review July 26, 2024 12:54
@Eligioo Eligioo force-pushed the stefan/clippy-fixes branch 3 times, most recently from e223b8b to ac7a4f3 Compare July 31, 2024 12:18
Fixes: unexpected `cfg` condition name: `tokio_unstable` by setting `workspace.lints.rust.unexpected_cfgs`
Fixes: doc list item missing indentation
Ignore lint until MSVR 1.80: unnecessary qualification of `mem` in `mem::size_of`
Fixes: unnecessary qualification of `nimiq_database::mdbx` in `nimiq_database::mdbx::MdbxDatabase`
Fixes: the borrowed expression implements the required traits in case of `&mut &mut buffer`

The unexpected cfg condition value 'parallel' in the primitives crate will be addressed in a separate PR by @ii-cruz
@Eligioo Eligioo force-pushed the stefan/clippy-fixes branch from ac7a4f3 to b0eff5c Compare August 1, 2024 11:37
@Eligioo Eligioo requested a review from hrxi August 1, 2024 11:43
Copy link
Contributor

@hrxi hrxi left a comment

Choose a reason for hiding this comment

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

Thanks!

@hrxi hrxi merged commit b0eff5c into albatross Aug 1, 2024
@hrxi hrxi deleted the stefan/clippy-fixes branch August 1, 2024 14:40
@jsdanielh jsdanielh added this to the Nimiq PoS Mainnet milestone Aug 7, 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.

4 participants