diff --git a/.github/workflows/cron-weekly-update-nightly.yml b/.github/workflows/cron-weekly-update-nightly.yml new file mode 100644 index 00000000..fa97f766 --- /dev/null +++ b/.github/workflows/cron-weekly-update-nightly.yml @@ -0,0 +1,41 @@ +name: Update Nightly rustc +on: + schedule: + - cron: "5 0 * * 6" # Saturday at 00:05 + workflow_dispatch: # allows manual triggering +jobs: + format: + name: Update nightly rustc + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@nightly + - name: Update rust.yml to use latest nightly + run: | + set -x + # Not every night has a nightly, so extract the date from whatever + # version of the compiler dtolnay/rust-toolchain gives us. + NIGHTLY_DATE=$(rustc +nightly --verbose --version | sed -ne 's/^commit-date: //p') + # Update the nightly version in the reference file. + echo "nightly-${NIGHTLY_DATE}" > nightly-version + echo "nightly_date=${NIGHTLY_DATE}" >> $GITHUB_ENV + # Some days there is no new nightly. In this case don't make an empty PR. + if ! git diff --exit-code > /dev/null; then + echo "Updated nightly. Opening PR." + echo "changes_made=true" >> $GITHUB_ENV + else + echo "Attempted to update nightly but the latest-nightly date did not change. Not opening any PR." + echo "changes_made=false" >> $GITHUB_ENV + fi + - name: Create Pull Request + if: env.changes_made == 'true' + uses: peter-evans/create-pull-request@v7 + with: + token: ${{ secrets.APOELSTRA_RUST_BITCOIN_ORG_CREATE_PR }} + author: Update Nightly Rustc Bot + committer: Update Nightly Rustc Bot + title: Automated update to nightly-version (to nightly-${{ env.nightly_date }}) + body: | + Automated update to Github CI workflow `rust.yml` by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action + commit-message: Automated update to Github CI to rustc nightly-${{ env.nightly_date }} + branch: create-pull-request/weekly-nightly-update diff --git a/.github/workflows/fuzz.yml b/.github/workflows/fuzz.yml index 80681682..b3fa2b2a 100644 --- a/.github/workflows/fuzz.yml +++ b/.github/workflows/fuzz.yml @@ -6,7 +6,7 @@ jobs: fuzz: if: ${{ !github.event.act }} - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest strategy: fail-fast: false matrix: @@ -14,8 +14,8 @@ jobs: steps: - name: Install test dependencies run: sudo apt-get update -y && sudo apt-get install -y binutils-dev libunwind8-dev libcurl4-openssl-dev libelf-dev libdw-dev cmake gcc libiberty-dev - - uses: actions/checkout@v2 - - uses: actions/cache@v2 + - uses: actions/checkout@v4 + - uses: actions/cache@v4 id: cache-fuzz with: path: | @@ -38,7 +38,7 @@ jobs: needs: fuzz runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: actions/download-artifact@v4 - name: Display structure of downloaded files run: ls -R diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index e134297a..6cfda274 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -3,6 +3,17 @@ on: [push, pull_request] name: Continuous Integration jobs: + Prepare: + runs-on: ubuntu-latest + outputs: + nightly_version: ${{ steps.read_toolchain.outputs.nightly_version }} + steps: + - name: "Checkout repo" + uses: actions/checkout@v4 + - name: "Read nightly version" + id: read_toolchain + run: echo "nightly_version=$(cat nightly-version)" >> $GITHUB_OUTPUT + Stable: name: Test - stable toolchain runs-on: ubuntu-latest @@ -10,7 +21,7 @@ jobs: fail-fast: false steps: - name: Checkout Crate - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Checkout Toolchain # https://github.com/dtolnay/rust-toolchain uses: dtolnay/rust-toolchain@stable @@ -28,7 +39,7 @@ jobs: fail-fast: false steps: - name: Checkout Crate - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Checkout Toolchain uses: dtolnay/rust-toolchain@beta - name: Running test script @@ -38,14 +49,17 @@ jobs: Nightly: name: Test - nightly toolchain + needs: Prepare runs-on: ubuntu-latest strategy: fail-fast: false steps: - name: Checkout Crate - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Checkout Toolchain - uses: dtolnay/rust-toolchain@nightly + uses: dtolnay/rust-toolchain@v1 + with: + toolchain: ${{ needs.Prepare.outputs.nightly_version }} - name: Running test script env: DO_DOCSRS: true @@ -60,7 +74,7 @@ jobs: fail-fast: false steps: - name: Checkout Crate - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Checkout Toolchain uses: dtolnay/rust-toolchain@1.56.1 - name: Running test script @@ -70,18 +84,20 @@ jobs: EmbeddedWithAlloc: name: no_std with alloc + needs: Prepare runs-on: ubuntu-latest strategy: fail-fast: false steps: - name: Checkout Crate - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up QEMU run: sudo apt update && sudo apt install -y qemu-system-arm gcc-arm-none-eabi - name: Checkout Toolchain - uses: dtolnay/rust-toolchain@nightly + uses: dtolnay/rust-toolchain@v1 with: targets: thumbv7m-none-eabi + toolchain: ${{ needs.Prepare.outputs.nightly_version }} - name: Run env: RUSTFLAGS: "-C link-arg=-Tlink.x" @@ -90,18 +106,20 @@ jobs: EmbeddedNoAlloc: name: no_std no alloc + needs: Prepare runs-on: ubuntu-latest strategy: fail-fast: false steps: - name: Checkout Crate - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up QEMU run: sudo apt update && sudo apt install -y qemu-system-arm gcc-arm-none-eabi - name: Checkout Toolchain - uses: dtolnay/rust-toolchain@nightly + uses: dtolnay/rust-toolchain@v1 with: targets: thumbv7m-none-eabi + toolchain: ${{ needs.Prepare.outputs.nightly_version }} - name: Run env: RUSTFLAGS: "-C link-arg=-Tlink.x" @@ -113,7 +131,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Crate - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Checkout Toolchain uses: dtolnay/rust-toolchain@stable - name: Add architecture i386 @@ -131,7 +149,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Crate - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Checkout Toolchain uses: dtolnay/rust-toolchain@stable - name: Install target diff --git a/nightly-version b/nightly-version new file mode 100644 index 00000000..98cd340e --- /dev/null +++ b/nightly-version @@ -0,0 +1 @@ +nightly-2025-07-11 diff --git a/src/primitives/correction.rs b/src/primitives/correction.rs index a6ce93b9..29652388 100644 --- a/src/primitives/correction.rs +++ b/src/primitives/correction.rs @@ -175,7 +175,7 @@ impl Corrector { /// /// If the input string has sufficiently many errors, this unique closest correct /// string may not actually be the intended string. - pub fn bch_errors(&self) -> Option> { + pub fn bch_errors(&self) -> Option> { // 1. Compute all syndromes by evaluating the residue at each power of the generator. let syndromes: Polynomial<_> = Ck::ROOT_GENERATOR .powers_range(Ck::ROOT_EXPONENTS) diff --git a/src/primitives/decode.rs b/src/primitives/decode.rs index 7b0f321f..c35aabf6 100644 --- a/src/primitives/decode.rs +++ b/src/primitives/decode.rs @@ -444,7 +444,7 @@ impl<'s> CheckedHrpstring<'s> { /// /// Converts the ASCII bytes representing field elements to the respective field elements. #[inline] - pub fn fe32_iter(&self, _: u8) -> AsciiToFe32Iter { + pub fn fe32_iter(&self, _: u8) -> AsciiToFe32Iter<'_> { AsciiToFe32Iter { iter: self.ascii.iter().copied() } } @@ -453,7 +453,7 @@ impl<'s> CheckedHrpstring<'s> { /// Converts the ASCII bytes representing field elements to the respective field elements, then /// converts the stream of field elements to a stream of bytes. #[inline] - pub fn byte_iter(&self) -> ByteIter { + pub fn byte_iter(&self) -> ByteIter<'_> { ByteIter { iter: AsciiToFe32Iter { iter: self.ascii.iter().copied() }.fes_to_bytes() } } @@ -663,7 +663,7 @@ impl<'s> SegwitHrpstring<'s> { /// /// Use `self.witness_version()` to get the witness version. #[inline] - pub fn byte_iter(&self) -> ByteIter { + pub fn byte_iter(&self) -> ByteIter<'_> { ByteIter { iter: AsciiToFe32Iter { iter: self.ascii.iter().copied() }.fes_to_bytes() } } } diff --git a/src/primitives/fieldvec.rs b/src/primitives/fieldvec.rs index 73da10bf..ba16f222 100644 --- a/src/primitives/fieldvec.rs +++ b/src/primitives/fieldvec.rs @@ -129,7 +129,7 @@ impl FieldVec { /// # Panics /// /// Panics if [`Self::has_data`] is false. - pub fn iter(&self) -> slice::Iter { + pub fn iter(&self) -> slice::Iter<'_, F> { if self.len > NO_ALLOC_MAX_LENGTH { self.assert_has_data(); #[cfg(feature = "alloc")] @@ -143,7 +143,7 @@ impl FieldVec { /// # Panics /// /// Panics if [`Self::has_data`] is false. - pub fn iter_mut(&mut self) -> slice::IterMut { + pub fn iter_mut(&mut self) -> slice::IterMut<'_, F> { if self.len > NO_ALLOC_MAX_LENGTH { self.assert_has_data(); #[cfg(feature = "alloc")] diff --git a/src/primitives/hrp.rs b/src/primitives/hrp.rs index b14e3eda..0e40da74 100644 --- a/src/primitives/hrp.rs +++ b/src/primitives/hrp.rs @@ -237,24 +237,24 @@ impl Hrp { /// If an uppercase HRP was parsed during object construction then this iterator will yield /// uppercase ASCII `char`s. For lowercase bytes see [`Self::lowercase_byte_iter`] #[inline] - pub fn byte_iter(&self) -> ByteIter { ByteIter { iter: self.buf[..self.size].iter() } } + pub fn byte_iter(&self) -> ByteIter<'_> { ByteIter { iter: self.buf[..self.size].iter() } } /// Creates a character iterator over the ASCII characters of this HRP. /// /// If an uppercase HRP was parsed during object construction then this iterator will yield /// uppercase ASCII `char`s. For lowercase bytes see [`Self::lowercase_char_iter`]. #[inline] - pub fn char_iter(&self) -> CharIter { CharIter { iter: self.byte_iter() } } + pub fn char_iter(&self) -> CharIter<'_> { CharIter { iter: self.byte_iter() } } /// Creates a lowercase iterator over the byte values (ASCII characters) of this HRP. #[inline] - pub fn lowercase_byte_iter(&self) -> LowercaseByteIter { + pub fn lowercase_byte_iter(&self) -> LowercaseByteIter<'_> { LowercaseByteIter { iter: self.byte_iter() } } /// Creates a lowercase character iterator over the ASCII characters of this HRP. #[inline] - pub fn lowercase_char_iter(&self) -> LowercaseCharIter { + pub fn lowercase_char_iter(&self) -> LowercaseCharIter<'_> { LowercaseCharIter { iter: self.lowercase_byte_iter() } } diff --git a/src/primitives/iter.rs b/src/primitives/iter.rs index a5cf068f..b078f379 100644 --- a/src/primitives/iter.rs +++ b/src/primitives/iter.rs @@ -85,7 +85,9 @@ pub trait Fe32IterExt: Sized + Iterator { /// Adapts the Fe32 iterator to encode the field elements into a bech32 address. #[inline] - fn with_checksum(self, hrp: &Hrp) -> Encoder { Encoder::new(self, hrp) } + fn with_checksum(self, hrp: &Hrp) -> Encoder<'_, Self, Ck> { + Encoder::new(self, hrp) + } } impl Fe32IterExt for I where I: Iterator {} diff --git a/src/primitives/polynomial.rs b/src/primitives/polynomial.rs index c202838f..b2dedcbc 100644 --- a/src/primitives/polynomial.rs +++ b/src/primitives/polynomial.rs @@ -73,7 +73,7 @@ impl Polynomial { /// # Panics /// /// Panics if [`Self::has_data`] is false. - pub fn iter(&self) -> slice::Iter { + pub fn iter(&self) -> slice::Iter<'_, F> { self.assert_has_data(); self.coefficients().iter() }