-
Notifications
You must be signed in to change notification settings - Fork 32
Add and apply most of rust-bitcoin's lints
#140
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
Merged
Davidson-Souza
merged 7 commits into
mit-dci:main
from
luisschwab:chore/add-rust-bitcoin-lints
Sep 11, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1afe149
chore: bump `edition` to 2021 and update `Cargo.toml`
luisschwab 8a23a20
feat!: implement `new_hash_map` and `new_hash_set` for the `std` prelude
luisschwab 9f89d54
fix: make `cargo-rbmt` run `#![no_std]` tests
luisschwab cf1ce52
chore!: add and apply most of `rust-bitcoin`'s lints
luisschwab 6045cb4
chore(ci): move `cargo rbmt tools` to vendored action
luisschwab d2470b7
chore(rust): bump toolchains
luisschwab 56d2320
fix(doc): update `Proof::deserialize`'s max allocated size
luisschwab File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,7 @@ authors = ["Calvin Kim <calvin@kcalvinalvin.info>", "Davidson Souza <contact@dls | |
| repository = "https://github.com/mit-dci/rustreexo" | ||
| license = "MIT OR Apache-2.0" | ||
| readme = "README.md" | ||
| edition = "2018" | ||
| edition = "2021" | ||
| rust-version = "1.74.0" # MSRV | ||
| autobenches = false | ||
|
|
||
|
|
@@ -17,6 +17,18 @@ default = ["std"] | |
| std = ["bitcoin_hashes/std", "hex-conservative/std", "hashbrown/default-hasher"] | ||
| with-serde = ["serde"] | ||
|
|
||
| [[bench]] | ||
| name = "accumulator" | ||
| harness = false | ||
|
|
||
| [[bench]] | ||
| name = "proof" | ||
| harness = false | ||
|
|
||
| [[bench]] | ||
| name = "stump" | ||
| harness = false | ||
|
|
||
| [dependencies] | ||
| bitcoin_hashes = { version = "1.0.0", default-features = false } | ||
| hex-conservative = { version = "1.1.0", default-features = false } | ||
|
|
@@ -45,41 +57,17 @@ bumpalo = { version = "3.11.1" } # blame: criterion v0.5.1 (RUSTSEC-2022-0078) | |
| rayon = { version = "1.5.3" } # blame: criterion v0.5.1 (RUSTSEC-2022-0021, RUSTSEC-2023-0045) | ||
| errno-dragonfly = { version = "0.1.2" } # blame: criterion v0.5.1 (RUSTSEC-2025-0121) | ||
|
|
||
| [[bench]] | ||
| name = "accumulator" | ||
| harness = false | ||
|
|
||
| [[bench]] | ||
| name = "proof" | ||
| harness = false | ||
|
|
||
| [[bench]] | ||
| name = "stump" | ||
| harness = false | ||
|
|
||
| [lints.clippy] | ||
| use_self = "warn" | ||
|
|
||
| [lints.rust] | ||
| unexpected_cfgs = { level = "warn", check-cfg = ['cfg(bench)'] } | ||
| [package.metadata.docs.rs] | ||
| all-features = true | ||
| rustdoc-args = ["--cfg", "docsrs"] | ||
|
|
||
| [package.metadata.rbmt.toolchains] | ||
| stable = "1.96.0" | ||
| nightly = "nightly-2026-06-23" | ||
| [package.metadata.rbmt] | ||
| toolchains = { stable = "1.97.1", nightly = "nightly-2026-08-04" } | ||
| tools = { cargo-audit = "=0.22.2", zizmor = "=1.30.1" } | ||
| lint = { allowed_duplicates = ["bitcoin-consensus-encoding", "bitcoin-internals"] } | ||
|
|
||
| [package.metadata.rbmt.test] | ||
| # Test all possible auto-discovered feature combinations. | ||
| sample_strategy = "all" | ||
|
|
||
| # Features to exclude from auto-discovery. | ||
| # Use for internal or alias features that should not be tested in isolation. | ||
| exclude_features = ["default"] | ||
|
|
||
| # Examples to run with different feature configurations. | ||
| # | ||
| # Supported formats: | ||
| # * "name" - runs with no-default-features. | ||
| # * "name:feature1 feature2" - runs with specific features. | ||
| examples = [ | ||
| "stump_modify", | ||
| "stump_modify:std", | ||
|
|
@@ -95,9 +83,142 @@ examples = [ | |
| "custom_hash:with-serde std", | ||
| ] | ||
|
|
||
| # Allow packages of different versions in the dependency tree. | ||
| [package.metadata.rbmt.lint] | ||
| allowed_duplicates = [ | ||
| "bitcoin-consensus-encoding", | ||
| "bitcoin-internals" | ||
| ] | ||
| [lints.rust] | ||
| # TODO(@luisschwab): redocument the whole crate | ||
| #missing_docs = "warn" | ||
| unreachable_pub = "warn" | ||
| unused_qualifications = "warn" | ||
|
|
||
| # Copied over from rust-bitcoin | ||
| [lints.clippy] | ||
| # Exclude lints we don't think are valuable. | ||
| needless_question_mark = "allow" # https://github.com/rust-bitcoin/rust-bitcoin/pull/2134 | ||
| manual_range_contains = "allow" # More readable than clippy's format. | ||
| # Exhaustive list of pedantic clippy lints | ||
| assigning_clones = "warn" | ||
| bool_to_int_with_if = "warn" | ||
| borrow_as_ptr = "warn" | ||
| case_sensitive_file_extension_comparisons = "warn" | ||
| cast_lossless = "warn" | ||
| cast_possible_truncation = "allow" # All casts should include a code comment (except test code). | ||
| cast_possible_wrap = "allow" # Same as above re code comment. | ||
| cast_precision_loss = "warn" | ||
| cast_ptr_alignment = "warn" | ||
| cast_sign_loss = "allow" # All casts should include a code comment (except in test code). | ||
| checked_conversions = "warn" | ||
| cloned_instead_of_copied = "warn" | ||
| copy_iterator = "warn" | ||
| default_trait_access = "warn" | ||
| doc_link_with_quotes = "warn" | ||
| doc_markdown = "warn" | ||
| empty_enums = "warn" | ||
| enum_glob_use = "warn" | ||
| expl_impl_clone_on_copy = "warn" | ||
| explicit_deref_methods = "warn" | ||
| explicit_into_iter_loop = "warn" | ||
| explicit_iter_loop = "warn" | ||
| filter_map_next = "warn" | ||
| flat_map_option = "warn" | ||
| float_cmp = "allow" # Bitcoin floats are typically limited to 8 decimal places and we want them exact. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't do float pointing here
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just copy-pasted it from rust-bitcoin |
||
| fn_params_excessive_bools = "warn" | ||
| if_not_else = "warn" | ||
| ignored_unit_patterns = "warn" | ||
| implicit_clone = "warn" | ||
| implicit_hasher = "warn" | ||
| inconsistent_struct_constructor = "warn" | ||
| index_refutable_slice = "warn" | ||
| inefficient_to_string = "warn" | ||
| inline_always = "warn" | ||
| into_iter_without_iter = "warn" | ||
| invalid_upcast_comparisons = "warn" | ||
| items_after_statements = "warn" | ||
| iter_filter_is_ok = "warn" | ||
| iter_filter_is_some = "warn" | ||
| iter_not_returning_iterator = "warn" | ||
| iter_without_into_iter = "warn" | ||
| large_digit_groups = "warn" | ||
| large_futures = "warn" | ||
| large_stack_arrays = "warn" | ||
| large_types_passed_by_value = "warn" | ||
| linkedlist = "warn" | ||
| macro_use_imports = "warn" | ||
| manual_assert = "warn" | ||
| manual_instant_elapsed = "warn" | ||
| manual_is_power_of_two = "warn" | ||
| manual_is_variant_and = "warn" | ||
| manual_let_else = "warn" | ||
| manual_ok_or = "warn" | ||
| manual_string_new = "warn" | ||
| many_single_char_names = "warn" | ||
| map_unwrap_or = "warn" | ||
| match_bool = "allow" # Adds extra indentation and LOC. | ||
| match_same_arms = "allow" # Collapses things that are conceptually unrelated to each other. | ||
| match_wild_err_arm = "warn" | ||
| match_wildcard_for_single_variants = "warn" | ||
| maybe_infinite_iter = "warn" | ||
| mismatching_type_param_order = "warn" | ||
| # TODO(@luisschwab): redocument the whole crate | ||
| #missing_errors_doc = "warn" | ||
| missing_fields_in_debug = "warn" | ||
| # TODO(@luisschwab): redocument the whole crate | ||
| #missing_panics_doc = "warn" | ||
| missing_safety_doc = "warn" | ||
| # TODO(@luisschwab): redocument the whole crate | ||
| #missing_docs_in_private_items = "warn" | ||
| must_use_candidate = "allow" # Useful for audit but many false positives. | ||
| mut_mut = "warn" | ||
| naive_bytecount = "warn" | ||
| needless_bitwise_bool = "warn" | ||
| needless_continue = "warn" | ||
| needless_for_each = "warn" | ||
| needless_pass_by_value = "warn" | ||
| needless_raw_string_hashes = "warn" | ||
| no_effect_underscore_binding = "warn" | ||
| no_mangle_with_rust_abi = "warn" | ||
| option_as_ref_cloned = "warn" | ||
| option_option = "warn" | ||
| ptr_as_ptr = "warn" | ||
| ptr_cast_constness = "warn" | ||
| pub_underscore_fields = "warn" | ||
| range_minus_one = "warn" | ||
| range_plus_one = "warn" | ||
| redundant_clone = "warn" | ||
| redundant_closure_for_method_calls = "warn" | ||
| redundant_else = "warn" | ||
| ref_as_ptr = "warn" | ||
| ref_binding_to_reference = "warn" | ||
| ref_option = "warn" | ||
| ref_option_ref = "warn" | ||
| return_self_not_must_use = "warn" | ||
| same_functions_in_if_condition = "warn" | ||
| semicolon_if_nothing_returned = "warn" | ||
| should_panic_without_expect = "warn" | ||
| similar_names = "allow" # Too many (subjectively) false positives. | ||
| single_char_pattern = "warn" | ||
| single_match_else = "warn" | ||
| stable_sort_primitive = "warn" | ||
| str_split_at_newline = "warn" | ||
| string_add_assign = "warn" | ||
| struct_excessive_bools = "warn" | ||
| struct_field_names = "allow" # dumb | ||
| too_many_lines = "warn" | ||
| transmute_ptr_to_ptr = "warn" | ||
| trivially_copy_pass_by_ref = "warn" | ||
| unchecked_time_subtraction = "warn" | ||
| unicode_not_nfc = "warn" | ||
| uninlined_format_args = "warn" | ||
| unnecessary_box_returns = "warn" | ||
| unnecessary_join = "warn" | ||
| unnecessary_literal_bound = "warn" | ||
| unnecessary_wraps = "warn" | ||
| unnested_or_patterns = "warn" | ||
| unreadable_literal = "warn" | ||
| unsafe_derive_deserialize = "warn" | ||
| unused_async = "warn" | ||
| unused_self = "warn" | ||
| use_self = "warn" | ||
| used_underscore_binding = "warn" | ||
| used_underscore_items = "warn" | ||
| verbose_bit_mask = "warn" | ||
| wildcard_imports = "warn" | ||
| zero_sized_map_values = "warn" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, on 2e541cb I see you removing the old way, but where did the
rbmtversion is implemented?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
#![no_std]on lib.rs will trigger the check.