Skip to content

Commit e3629b7

Browse files
committed
Merge #104: Fix build on 1.48.0
efdc72f fix build on 1.48.0 (Andrew Poelstra) e0b8c82 ci: actually run tests on alternate compilers (Andrew Poelstra) Pull request description: #103 introduced a `panic` into a constfn; prior to that there were some loops using the new `IntoIter` implementations on arrays. Neither built with 1.48. This PR fixes these. This was not noticed because * In Github Actions we introduced the `DO_FEATURE_MATRIX` variabe but did not set it for the beta and 1.48 compiler runs, so we were not actually testing anything with those compilers * In my local CI script I was caching environments and did not feed the compiler into the key of a hashmap, resulting in tests running only on a single compiler (which happened to be nightly, which is the only compiler that I had put a lot of work into specifically ensuring was being used) ACKs for top commit: tcharding: ACK efdc72f Tree-SHA512: 215ca8265d953071374296800bb024c6cfd305fa08334ff44438e534a85f534587609d811fcbeb7ba6438faa0f790b8bcdf3f8000ef03b7e942c78c9cdbe0008
2 parents 7b4fd0f + efdc72f commit e3629b7

File tree

4 files changed

+16
-17
lines changed

4 files changed

+16
-17
lines changed

.github/workflows/rust.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ jobs:
3232
- name: Checkout Toolchain
3333
uses: dtolnay/rust-toolchain@beta
3434
- name: Running test script
35+
env:
36+
DO_FEATURE_MATRIX: true
3537
run: ./contrib/test.sh
3638

3739
Nightly:
@@ -62,6 +64,8 @@ jobs:
6264
- name: Checkout Toolchain
6365
uses: dtolnay/[email protected]
6466
- name: Running test script
67+
env:
68+
DO_FEATURE_MATRIX: true
6569
run: ./contrib/test.sh
6670

6771
EmbeddedWithAlloc:

contrib/test.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
set -eu
66
set -x
77

8-
# "arrayvec" feature breaks the MSRV, its added manually in DO_FEATURE_MATRIX loop below.
9-
FEATURES="std alloc"
10-
118
# Some tests require certain toolchain types.
129
NIGHTLY=false
1310
MSRV=false
@@ -52,8 +49,7 @@ if [ "${DO_FEATURE_MATRIX-false}" = true ]; then
5249
build_and_test "alloc"
5350
build_and_test "std alloc"
5451
# arrayvec breaks the MSRV
55-
if [ $MSRV = false
56-
]; then
52+
if [ $MSRV = false ]; then
5753
build_and_test "arrayvec"
5854
build_and_test "std arrayvec"
5955
build_and_test "alloc arrayvec"

src/primitives/gf32.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,8 @@ mod tests {
411411

412412
#[test]
413413
fn from_char() {
414-
for c in CHARS_LOWER {
415-
assert!(Fe32::from_char(c).is_ok())
414+
for c in &CHARS_LOWER[..] {
415+
assert!(Fe32::from_char(*c).is_ok())
416416
}
417417
}
418418

@@ -426,8 +426,8 @@ mod tests {
426426

427427
#[test]
428428
fn mul_zero() {
429-
for c in CHARS_LOWER {
430-
let fe = Fe32::from_char(c).unwrap();
429+
for c in &CHARS_LOWER[..] {
430+
let fe = Fe32::from_char(*c).unwrap();
431431
assert_eq!(fe._mul(Fe32::Q), Fe32::Q) // Fe32::Q == Fe32(0)
432432
}
433433
}
@@ -446,8 +446,8 @@ mod tests {
446446

447447
#[test]
448448
fn mul_one() {
449-
for c in CHARS_LOWER {
450-
let fe = Fe32::from_char(c).unwrap();
449+
for c in &CHARS_LOWER[..] {
450+
let fe = Fe32::from_char(*c).unwrap();
451451
assert_eq!(fe * Fe32::P, fe) // Fe32::P == Fe32(1)
452452
}
453453
}

src/primitives/hrp.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,22 @@ impl Hrp {
4646

4747
/// Parses the human-readable part (see [`Hrp::parse`] for full docs).
4848
///
49-
/// # Panics
50-
///
51-
/// If the string is invalid as defined by BIP-173.
49+
/// Does not check that `hrp` is valid according to BIP-173 but does check for valid ASCII
50+
/// values, replacing any invalid characters with `X`.
5251
pub const fn parse_unchecked(hrp: &str) -> Self {
5352
let mut new = Hrp { buf: [0_u8; MAX_HRP_LEN], size: 0 };
5453
let hrp_bytes = hrp.as_bytes();
5554

5655
let mut i = 0;
5756
// Funky code so we can be const.
5857
while i < hrp.len() {
59-
let b = hrp_bytes[i];
58+
let mut b = hrp_bytes[i];
6059
// Valid subset of ASCII
6160
if b < 33 || b > 126 {
62-
panic!("invalid hrp");
61+
b = b'X';
6362
}
6463

65-
new.buf[i] = hrp_bytes[i];
64+
new.buf[i] = b;
6665
new.size += 1;
6766
i += 1;
6867
}

0 commit comments

Comments
 (0)