Skip to content

Fix all the lint warnings on 0.32.x branch#5282

Merged
apoelstra merged 12 commits intorust-bitcoin:0.32.xfrom
jamillambert:1112-lint-bitcoin-0.32
Nov 24, 2025
Merged

Fix all the lint warnings on 0.32.x branch#5282
apoelstra merged 12 commits intorust-bitcoin:0.32.xfrom
jamillambert:1112-lint-bitcoin-0.32

Conversation

@jamillambert
Copy link
Copy Markdown
Contributor

@jamillambert jamillambert commented Nov 12, 2025

See #5281 for reason.

Use the current version of nightly on master (2025-09-26) to lint and format the v0.32.x branch.

Fix all of the lint errors.

Run the formatter.

Fix some rustdoc issues.

Closes #5281

There are lint errors "hiding a lifetime that's elided elsewhere is
confusing". Fix them.
@github-actions github-actions bot added C-bitcoin PRs modifying the bitcoin crate C-hashes PRs modifying the hashes crate C-units PRs modifying the units crate C-internals PRs modifying the internals crate C-io PRs modifying the io crate test C-base58 PRs modifying the base58 crate labels Nov 12, 2025
@coveralls
Copy link
Copy Markdown

coveralls commented Nov 12, 2025

Pull Request Test Coverage Report for Build 19517889972

Details

  • 63 of 75 (84.0%) changed or added relevant lines in 20 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.07%) to 83.228%

Changes Missing Coverage Covered Lines Changed/Added Lines %
bitcoin/src/blockdata/witness.rs 16 17 94.12%
bitcoin/src/p2p/message.rs 0 1 0.0%
bitcoin/src/p2p/mod.rs 0 1 0.0%
bitcoin/src/serde_utils.rs 0 1 0.0%
bitcoin/src/taproot/serialized_signature.rs 0 1 0.0%
hashes/src/serde_macros.rs 0 1 0.0%
bitcoin/src/blockdata/locktime/absolute.rs 0 3 0.0%
bitcoin/src/blockdata/transaction.rs 1 4 25.0%
Files with Coverage Reduction New Missed Lines %
bitcoin/src/blockdata/witness.rs 1 88.3%
Totals Coverage Status
Change from base Build 17702260423: 0.07%
Covered Lines: 17070
Relevant Lines: 20510

💛 - Coveralls

@jamillambert
Copy link
Copy Markdown
Contributor Author

jamillambert commented Nov 12, 2025

I grouped all of the similar lints together. This was a lot easier with jj than it would have been with just git. Clippy gives you a couple of random lint errors, you fix them and then get another random set - rinse and repeat. Then at the end CI says there are doc issues.

There are a lint errors "the following explicit lifetimes could be
elided: 'a". Fix them.
There is a lint error that "current MSRV (Minimum Supported Rust
Version) is `1.56.1` but this item is stable in a `const` context since
`1.64.0`". Allow it.
Some cases of incorrect doc levels e.g. module level docs used a `///`
and the macro had `//`.

Fix them so they are `//!` for modules `///` for items and `//` for
comments. Also use the full word `implements` instead of an abbreviation
to match other macros.
Lint error "non-canonical implementation of `partial_cmp` on an `Ord`
type". Fix it.
There are multiple fn that return large error types and cause a Clippy
error "the `Err`-variant returned from this function is very large".

Allow it for the whole psbt module.
Run cargo fmt on nightly-2025-09-26 to match the current version used
on master.
@jamillambert jamillambert force-pushed the 1112-lint-bitcoin-0.32 branch from a8d7053 to daad815 Compare November 12, 2025 17:29
@tcharding
Copy link
Copy Markdown
Member

I grouped all of the similar lints together. This was a lot easier with jj than it would have been with just git. Clippy gives you a couple of random lint errors, you fix them and then get another random set - rinse and repeat. Then at the end CI says there are doc issues.

chuckle, yep sometimes the tools get in the way of the task. If I was better I'd put effort into cargo and clippy dev but I don't so I'm glad we have what we have.

Copy link
Copy Markdown
Member

@tcharding tcharding left a comment

Choose a reason for hiding this comment

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

ACK daad815

@tcharding
Copy link
Copy Markdown
Member

tcharding commented Nov 12, 2025

nit: I dunno if this is a backport. Its 'fix all the lint warnings on 0.32.x branch', right?

I guess many of the same changes are also on master, so it doesn't really matter.

@tcharding
Copy link
Copy Markdown
Member

Thanks for doing this BTW, while reviewing I thought to myself "glad I didn't do this it would have annoyed me because I've fixed many of the things before"

@jamillambert
Copy link
Copy Markdown
Contributor Author

jamillambert commented Nov 13, 2025

nit: I dunno if this is a backport. Its 'fix all the lint warnings on 0.32.x branch', right?

I guess many of the same changes are also on master, so it doesn't really matter.

Yeah I wasn't sure, I added it to make it clear the target branch was 0.32.x and not master. I have changed it to your suggestion.

@jamillambert jamillambert changed the title Backport: Lint bitcoin 0.32.x Fix all the lint warnings on 0.32.x branch Nov 13, 2025
@apoelstra
Copy link
Copy Markdown
Member

In daad815

So, this "broken links" thing is what doc_auto_cfg was for. There is a new flag, doc_cfg or something like that. I really really distrust docs.rs after they broke the entire fucking ecosystem with these flags and I don't want to use anything related to them anymore, but I believe it would be more "correct" to do so. Thoughts?

@jamillambert jamillambert force-pushed the 1112-lint-bitcoin-0.32 branch from daad815 to 9e875ab Compare November 19, 2025 15:23
@jamillambert
Copy link
Copy Markdown
Contributor Author

I removed #![allow(rustdoc::broken_intra_doc_links)] and instead wrote out the link in the rustdocs so that it still builds the docs when the ordered feature is not enabled.

/// For [`crate::Transaction`], which has a locktime field, we implement a total ordering to make
/// it easy to store transactions in sorted data structures, and use the locktime's 32-bit integer
/// consensus encoding to order it. We also implement [`ordered::ArbitraryOrd`] if the "ordered"
/// consensus encoding to order it. We also implement [`ordered::ArbitraryOrd`](https://docs.rs/ordered/latest/ordered/trait.ArbitraryOrd.html) if the "ordered"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This line is too long. Can we use the style where at the bottom of the block of docs put

///
/// [`ordered::ArbitraryOrd`]: <https://docs.rs/ordered/latest/ordered/trait.ArbitraryOrd.html>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

There are links in the rustdoc to `ArbitraryOrd` that is behind a
feature gate. This makes rustdoc complain that the link is broken.

Write out the link in the docs so that rustdoc can resolve it properly
when the feature is not enabled.
@jamillambert jamillambert force-pushed the 1112-lint-bitcoin-0.32 branch from 9e875ab to a2fe08c Compare November 19, 2025 22:04
@tcharding
Copy link
Copy Markdown
Member

In daad815

So, this "broken links" thing is what doc_auto_cfg was for. There is a new flag, doc_cfg or something like that. I really really distrust docs.rs after they broke the entire fucking ecosystem with these flags and I don't want to use anything related to them anymore, but I believe it would be more "correct" to do so. Thoughts?

I'm not sure if I just 'worked out' what you already said or not but #5307

@apoelstra
Copy link
Copy Markdown
Member

Sorry for the delays. I'll make it my top rust-bitcoin priority today to get my local CI to pass on the tip of this so we can merge it then get the other backports merged.

@apoelstra
Copy link
Copy Markdown
Member

Don't have to deal with it in this PR but note that generate-files.sh is out of date here as well :P

@apoelstra
Copy link
Copy Markdown
Member

utACK a2fe08c ran my local CI on the tip

@apoelstra apoelstra merged commit 6993c6f into rust-bitcoin:0.32.x Nov 24, 2025
19 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-base58 PRs modifying the base58 crate C-bitcoin PRs modifying the bitcoin crate C-hashes PRs modifying the hashes crate C-internals PRs modifying the internals crate C-io PRs modifying the io crate C-units PRs modifying the units crate test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants