diff --git a/.github/workflows/rustfmt.yml b/.github/workflows/rustfmt.yml new file mode 100644 index 0000000000..4fb721e07e --- /dev/null +++ b/.github/workflows/rustfmt.yml @@ -0,0 +1,26 @@ +name: Nightly rustfmt +on: + schedule: + - cron: "0 0 * * 0" # runs weekly on Sunday at 00:00 + workflow_dispatch: # allows manual triggering +jobs: + format: + name: Nightly rustfmt + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@nightly + with: + components: rustfmt + - name: Run Nightly rustfmt + run: cargo +nightly fmt + - name: Get the current date + run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_ENV + - name: Create Pull Request + uses: peter-evans/create-pull-request@v5 + with: + title: Automated nightly rustfmt (${{ env.date }}) + body: | + Automated nightly `rustfmt` changes by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action + commit-message: ${{ env.date }} automated rustfmt nightly + labels: rustfmt diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d61ae85f28..2439c664c6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -184,12 +184,6 @@ any of the following conditions: Library reflects Groestlcoin Core approach whenever possible. -### Formatting - -The repository currently uses `rustfmt` (WIP, some directories are excluded). We use nightly -features so to run the formatter use `cargo +nightly fmt`. (Remember that your editor may be -configured to fmt with a stable toolchain, this will result in many unwanted changes.) - ### Naming conventions Naming of data structures/enums and their fields/variants must follow names used diff --git a/groestlcoin/src/blockdata/locktime/absolute.rs b/groestlcoin/src/blockdata/locktime/absolute.rs index aefbbb28c3..da582349b5 100644 --- a/groestlcoin/src/blockdata/locktime/absolute.rs +++ b/groestlcoin/src/blockdata/locktime/absolute.rs @@ -66,7 +66,6 @@ pub const LOCK_TIME_THRESHOLD: u32 = 500_000_000; /// _ => panic!("handle invalid comparison error"), /// }; /// ``` -#[allow(clippy::derive_ord_xor_partial_ord)] #[derive(Clone, Copy, PartialEq, Eq, Hash)] pub enum LockTime { /// A block height lock time value. diff --git a/groestlcoin/src/blockdata/locktime/relative.rs b/groestlcoin/src/blockdata/locktime/relative.rs index c6edb3fa03..a058dd6c11 100644 --- a/groestlcoin/src/blockdata/locktime/relative.rs +++ b/groestlcoin/src/blockdata/locktime/relative.rs @@ -26,7 +26,6 @@ use crate::relative; /// /// * [BIP 68 Relative lock-time using consensus-enforced sequence numbers](https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki) /// * [BIP 112 CHECKSEQUENCEVERIFY](https://github.com/bitcoin/bips/blob/master/bip-0112.mediawiki) -#[allow(clippy::derive_ord_xor_partial_ord)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", serde(crate = "actual_serde"))] diff --git a/groestlcoin/src/crypto/sighash.rs b/groestlcoin/src/crypto/sighash.rs index 49ac7a5219..deab2dd87e 100644 --- a/groestlcoin/src/crypto/sighash.rs +++ b/groestlcoin/src/crypto/sighash.rs @@ -1238,7 +1238,6 @@ impl EncodeSigningDataResult { /// // use a hash value of "1", instead of computing the actual hash due to SIGHASH_SINGLE bug /// } /// ``` - #[allow(clippy::wrong_self_convention)] // E is not Copy so we consume self. pub fn is_sighash_single_bug(self) -> Result { match self { EncodeSigningDataResult::SighashSingleBug => Ok(true), diff --git a/groestlcoin/src/lib.rs b/groestlcoin/src/lib.rs index 28ba77ca50..a8d79117d8 100644 --- a/groestlcoin/src/lib.rs +++ b/groestlcoin/src/lib.rs @@ -38,6 +38,8 @@ #![warn(missing_docs)] // Instead of littering the codebase for non-fuzzing code just globally allow. #![cfg_attr(fuzzing, allow(dead_code, unused_imports))] +// Exclude clippy lints we don't think are valuable +#![allow(clippy::needless_question_mark)] // https://github.com/rust-bitcoin/rust-bitcoin/pull/2134 #[cfg(not(any(feature = "std", feature = "no-std")))] compile_error!("at least one of the `std` or `no-std` features must be enabled"); diff --git a/hashes/src/lib.rs b/hashes/src/lib.rs index 10ec9e9cec..739c1d074b 100644 --- a/hashes/src/lib.rs +++ b/hashes/src/lib.rs @@ -78,6 +78,8 @@ #![cfg_attr(all(not(test), not(feature = "std")), no_std)] // Instead of littering the codebase for non-fuzzing code just globally allow. #![cfg_attr(hashes_fuzz, allow(dead_code, unused_imports))] +// Exclude clippy lints we don't think are valuable +#![allow(clippy::needless_question_mark)] // https://github.com/rust-bitcoin/rust-bitcoin/pull/2134 #[cfg(all(not(test), not(feature = "std"), feature = "core2"))] extern crate actual_core2 as core2; diff --git a/internals/src/lib.rs b/internals/src/lib.rs index c90324115f..820a276ef5 100644 --- a/internals/src/lib.rs +++ b/internals/src/lib.rs @@ -11,6 +11,8 @@ #![cfg_attr(docsrs, feature(doc_auto_cfg))] // Coding conventions #![warn(missing_docs)] +// Exclude clippy lints we don't think are valuable +#![allow(clippy::needless_question_mark)] // https://github.com/rust-bitcoin/rust-bitcoin/pull/2134 #[cfg(feature = "alloc")] extern crate alloc;