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

Enable pedantic lints #159

Merged
merged 2 commits into from
Mar 7, 2025
Merged

Conversation

tcharding
Copy link
Member

Configure clippy to warn for pedantic lints. Leave the missing_errors_doc one for a soon-to-come docs PR.

@tcharding tcharding force-pushed the 02-21-pedantic-lints branch from 590f945 to 4697da8 Compare February 21, 2025 03:25
@apoelstra
Copy link
Member

Checked that the let () = const thing works the same as let _ = const did. There is a clippy issue saying that this case is a false positive for the lint so I wanted to be sure.

@tcharding
Copy link
Member Author

FTR I didn't know about for () = until this PR. Thanks

Copy link
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

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

ACK 4697da8; successfully ran local tests

@tcharding
Copy link
Member Author

Bump, this guy too please.

@apoelstra
Copy link
Member

Needs rebase now.

Copy the current nightly version from `rust-bitcoin`.
Configure `clippy` to do warn for pedantic lints and fix warnings.
@tcharding tcharding force-pushed the 02-21-pedantic-lints branch from 4697da8 to a05406c Compare March 6, 2025 00:30
@tcharding
Copy link
Member Author

Rebased and squashed. No other changes.

Copy link
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

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

ACK a05406c; successfully ran local tests

@apoelstra apoelstra merged commit 55bbf0b into rust-bitcoin:master Mar 7, 2025
13 checks passed
@@ -51,7 +51,7 @@ impl<const CAP: usize> BufEncoder<CAP> {
#[inline]
#[allow(clippy::let_unit_value)] // Allow the unit value of the const check
pub fn new(case: Case) -> Self {
let _ = Self::_CHECK_EVEN_CAPACITY;
let () = Self::_CHECK_EVEN_CAPACITY;
Copy link
Collaborator

Choose a reason for hiding this comment

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

You forgot to remove the allow

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, thanks.

OddLengthString(ref e) =>
E::InvalidChar(ref e) =>
write_err!(f, "invalid char, failed to create bytes from hex"; e),
E::OddLengthString(ref e) =>
Copy link
Collaborator

Choose a reason for hiding this comment

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

IMO the problems the original way causes are too unlikely to bother but I'm also not going to change it back.

Copy link
Member

Choose a reason for hiding this comment

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

I also don't like the original way stylistically. It's hard to tell where the symbols are coming from because of the wildcard import.

Copy link
Collaborator

Choose a reason for hiding this comment

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

OK, though note that for me this, as opposed to other wildcard cases, is an easily-recognizable pattern. The match is matching on what's clearly an enum, based on its structure and if the variants don't have the X:: prefix then it's clear it must be wildcard imported in the statement above match. Of course one could uselessly import a different enum but that would cause other warnings. It does require a bit of discipline - to only put the use in the same function. But I have no problem with such discipline.

Anyway, not a big deal.

Copy link
Member Author

Choose a reason for hiding this comment

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

As everyone knows I'm a sucker for uniformity. Sometimes the variant names clash and then the wildcard cannot be used which means breaking uniformity. The new style is always valid and stomps the lint warning - seems like a win. It is admittedly a bit ugly.

tcharding added a commit to tcharding/hex-conservative that referenced this pull request Mar 7, 2025
This attribute was mistakenly left in during dev/review cycle in rust-bitcoin#159,
it serves no purpose.
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