Skip to content

blech32: use square brackets for vec! in decoding tests - #305

Open
KyrylR wants to merge 1 commit into
ElementsProject:masterfrom
KyrylR:feature/blech32-vec-brackets
Open

KyrylR wants to merge 1 commit into
ElementsProject:masterfrom
KyrylR:feature/blech32-vec-brackets

Conversation

@KyrylR

@KyrylR KyrylR commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Stable clippy flags vec!(...) with clippy::nonstandard_macro_braces, which fails cargo clippy --all-targets -- -D warnings in the project on the current master

@KyrylR

KyrylR commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Below is a clippy on current master

rust-elements (master) ✔ cargo clippy --all-targets -- -D warnings
    Checking serde_core v1.0.228
    Checking bitcoin_hashes v0.14.101
    Checking bitcoin-units v0.1.101
    Checking bitcoin_hashes v1.2.0
    Checking secp256k1 v0.29.1
    Checking base58ck v0.1.101
    Checking bitcoin v0.32.102
    Checking secp256k1-zkp v0.11.0
    Checking serde v1.0.228
    Checking serde_json v1.0.149
    Checking serde_test v1.0.177
    Checking serde_cbor v0.8.2
    Checking bincode v1.3.3
    Checking elements v0.27.0 (/Users/inter/Desktop/Simpl/rust-elements)
error: use of irregular braces for `vec!` macro
   --> src/blech32/decode.rs:733:61
    |
733 |           let invalid: Vec<(&str, UncheckedHrpstringError)> = vec!(
    |  _____________________________________________________________^
734 | |             ("\u{20}1nwldj5",
735 | |              // TODO: Rust >= 1.59.0 use Hrp(hrp::Error::InvalidAsciiByte('\u{20}'.try_into().unwrap()))),
736 | |              E::Hrp(hrp::Error::InvalidAsciiByte(32))),
...   |
756 | |              E::Hrp(hrp::Error::Empty)),
757 | |         );
    | |_________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.99.0/index.html#nonstandard_macro_braces
    = note: `-D clippy::nonstandard-macro-braces` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::nonstandard_macro_braces)]`
help: consider writing
    |
733 ~         let invalid: Vec<(&str, UncheckedHrpstringError)> = vec![
734 +             ("\u{20}1nwldj5",
735 +              // TODO: Rust >= 1.59.0 use Hrp(hrp::Error::InvalidAsciiByte('\u{20}'.try_into().unwrap()))),
736 +              E::Hrp(hrp::Error::InvalidAsciiByte(32))),
737 +             ("\u{7F}1axkwrx",
738 +              E::Hrp(hrp::Error::InvalidAsciiByte(127))),
739 +             ("\u{80}1eym55h",
740 +              E::Hrp(hrp::Error::NonAsciiChar('\u{80}'))),
741 +             ("an84characterslonghumanreadablepartthatcontainsthetheexcludedcharactersbioandnumber11d6pts4",
742 +              E::Hrp(hrp::Error::TooLong(84))),
743 +             ("pzry9x0s0muk",
744 +              E::Char(CharError::MissingSeparator)),
745 +             ("1pzry9x0s0muk",
746 +              E::Hrp(hrp::Error::Empty)),
747 +             ("x1b4n0q5v",
748 +              E::Char(CharError::InvalidChar('b'))),
749 +             // "li1dgmt3" in separate test because error is a checksum error.
750 +             ("de1lg7wt\u{ff}",
751 +              E::Char(CharError::InvalidChar('\u{ff}'))),
752 +             // "A1G7SGD8" in separate test because error is a checksum error.
753 +             ("10a06t8",
754 +              E::Hrp(hrp::Error::Empty)),
755 +             ("1qzzfhee",
756 +              E::Hrp(hrp::Error::Empty)),
757 ~         ];
    |

error: use of irregular braces for `vec!` macro
   --> src/blech32/decode.rs:788:61
    |
788 |           let invalid: Vec<(&str, UncheckedHrpstringError)> = vec!(
    |  _____________________________________________________________^
789 | |             ("\u{20}1xj0phk",
790 | |              // TODO: Rust >= 1.59.0 use Hrp(hrp::Error::InvalidAsciiByte('\u{20}'.try_into().unwrap()))),
791 | |              E::Hrp(hrp::Error::InvalidAsciiByte(32))),
...   |
817 | |         );
    | |_________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.99.0/index.html#nonstandard_macro_braces
help: consider writing
    |
788 ~         let invalid: Vec<(&str, UncheckedHrpstringError)> = vec![
789 +             ("\u{20}1xj0phk",
790 +              // TODO: Rust >= 1.59.0 use Hrp(hrp::Error::InvalidAsciiByte('\u{20}'.try_into().unwrap()))),
791 +              E::Hrp(hrp::Error::InvalidAsciiByte(32))),
792 +             ("\u{7F}1g6xzxy",
793 +              E::Hrp(hrp::Error::InvalidAsciiByte(127))),
794 +             ("\u{80}1g6xzxy",
795 +              E::Hrp(hrp::Error::NonAsciiChar('\u{80}'))),
796 +             ("an84characterslonghumanreadablepartthatcontainsthenumber1andtheexcludedcharactersbio1569pvx",
797 +              E::Hrp(hrp::Error::TooLong(84))),
798 +             ("qyrz8wqd2c9m",
799 +              E::Char(CharError::MissingSeparator)),
800 +             ("1qyrz8wqd2c9m",
801 +              E::Hrp(hrp::Error::Empty)),
802 +             ("y1b0jsk6g",
803 +              E::Char(CharError::InvalidChar('b'))),
804 +             ("lt1igcx5c0",
805 +              E::Char(CharError::InvalidChar('i'))),
806 +             // "in1muywd" in separate test because error is a checksum error.
807 +             ("mm1crxm3i",
808 +              E::Char(CharError::InvalidChar('i'))),
809 +             ("au1s5cgom",
810 +              E::Char(CharError::InvalidChar('o'))),
811 +             // "M1VUXWEZ" in separate test because error is a checksum error.
812 +             ("16plkw9",
813 +              E::Hrp(hrp::Error::Empty)),
814 +             ("1p2gdwpf",
815 +              E::Hrp(hrp::Error::Empty)),
816 + 
817 ~         ];
    |

error: could not compile `elements` (lib) due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
error: could not compile `elements` (lib test) due to 2 previous errors

@apoelstra apoelstra left a comment

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.

ACK e8e05bf; successfully ran local tests; thank you!!

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.

2 participants