Skip to content

Commit 2fd10c8

Browse files
committed
Merge branch 'rust-1.51.0'
2 parents 56e5a6f + b78fe45 commit 2fd10c8

File tree

11 files changed

+21
-13
lines changed

11 files changed

+21
-13
lines changed

.ci/run-container-ci

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
set -e
2626
set -x
2727

28-
CONTAINER=shiftcrypto/firmware_v2:19
28+
CONTAINER=shiftcrypto/firmware_v2:20
2929

3030
if [ "$1" == "pull" ] ; then
3131
docker pull "$CONTAINER"

src/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,9 @@ if(NOT CMAKE_CROSSCOMPILING)
474474
-A clippy::type_complexity
475475
-A clippy::collapsible-if
476476
-A clippy::len_without_is_empty
477+
-A clippy::result_unit_err
478+
-A clippy::upper_case_acronyms
479+
-A clippy::manual_range_contains
477480
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/rust/
478481
)
479482
add_dependencies(rust-clippy rust-bindgen)

src/rust/bitbox02-rust-c/src/util.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@ pub extern "C" fn rust_util_validate_name(cstr: CStr, max_len: size_t) -> bool {
3939
pub extern "C" fn rust_util_uint8_to_hex(buf: Bytes, mut out: CStrMut) {
4040
let min_len = buf.len * 2;
4141
out.write(min_len, |out| {
42-
hex::encode_to_slice(&buf, out).unwrap();
42+
// Avoid .unwrap() here until the following compiler regression is fixed:
43+
// https://github.com/rust-lang/rust/issues/83925
44+
match hex::encode_to_slice(&buf, out) {
45+
Ok(()) => {}
46+
Err(err) => panic!("{:?}", err),
47+
}
4348
});
4449
}
4550

src/rust/bitbox02-rust/src/bb02_async.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ impl<O> core::future::Future for AsyncOption<'_, O> {
4848

4949
/// Waits for an option to contain a value and returns that value, leaving `None` in its place.
5050
/// E.g. `assert_eq!(option(&Some(42)).await, 42)`.
51-
pub fn option<'a, O>(option: &'a RefCell<Option<O>>) -> AsyncOption<'a, O> {
52-
AsyncOption(&option)
51+
pub fn option<O>(option: &RefCell<Option<O>>) -> AsyncOption<O> {
52+
AsyncOption(option)
5353
}
5454

5555
/// Polls a future until the result is available.

src/rust/bitbox02-rust/src/hww/api/ethereum/amount.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ mod tests {
5656
decimals: usize,
5757
unit: &'a str,
5858
expected_result: &'a str,
59-
};
59+
}
6060

6161
let tests = vec![
6262
Test {

src/rust/bitbox02-rust/src/workflow/mnemonic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ pub async fn get() -> Result<zeroize::Zeroizing<String>, ()> {
207207
enum GetWordError {
208208
Cancel,
209209
EditPrevious,
210-
};
210+
}
211211

212212
let cancel_choice = if word_idx == 0 {
213213
// In the first word, there is no previous word, so we go straight to the cancel

src/rust/bitbox02/src/app_eth.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub fn params_get(coin: bitbox02_sys::ETHCoin) -> Option<Params> {
3030
let len = crate::util::strlen_ptr(params.unit);
3131
core::slice::from_raw_parts(params.unit, len as _)
3232
};
33-
core::str::from_utf8(&s[..]).unwrap()
33+
core::str::from_utf8(s).unwrap()
3434
},
3535
})
3636
}
@@ -55,14 +55,14 @@ pub fn erc20_params_get(
5555
let len = crate::util::strlen_ptr(params.unit);
5656
core::slice::from_raw_parts(params.unit, len as _)
5757
};
58-
core::str::from_utf8(&s[..]).unwrap()
58+
core::str::from_utf8(s).unwrap()
5959
},
6060
name: {
6161
let s = unsafe {
6262
let len = crate::util::strlen_ptr(params.name);
6363
core::slice::from_raw_parts(params.name, len as _)
6464
};
65-
core::str::from_utf8(&s[..]).unwrap()
65+
core::str::from_utf8(s).unwrap()
6666
},
6767
contract_address: params.contract_address,
6868
decimals: params.decimals,

src/rust/bitbox02/src/keystore.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ pub fn get_bip39_word(idx: u16) -> Result<zeroize::Zeroizing<String>, ()> {
100100
let word = unsafe {
101101
let len = crate::util::strlen_ptr(word_ptr);
102102
let slice = core::slice::from_raw_parts(word_ptr, len as _);
103-
zeroize::Zeroizing::new(core::str::from_utf8(&slice[..]).unwrap().into())
103+
zeroize::Zeroizing::new(core::str::from_utf8(slice).unwrap().into())
104104
};
105105
unsafe {
106106
bitbox02_sys::wally_free_string(word_ptr as _);

src/rust/bitbox02/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ pub enum Color {
180180
}
181181

182182
pub fn leds_turn_big_led(led: i32, color: Option<Color>) {
183-
if led < 0 || led > 2 {
183+
if !(0..=2).contains(&led) {
184184
panic!("Invalid led");
185185
}
186186
let c = match color {

src/rust/bitbox02/src/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ macro_rules! str_to_cstr_force {
7676
($input:expr, $len:expr) => {
7777
match $crate::str_to_cstr!($input, $len) {
7878
Ok(buf) => buf,
79-
Err(msg) => panic!(msg),
79+
Err(msg) => panic!("{}", msg),
8080
}
8181
};
8282
}

0 commit comments

Comments
 (0)