mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-16 01:22:02 +00:00
feat(core/rust): improve catch_exception, make use of Rust 1.55
This commit is contained in:
parent
9dd97c77e3
commit
806beb77d2
@ -71,7 +71,7 @@ mp_obj_t trezor_obj_call_protected(void (*func)(void *), void *arg) {
|
||||
if (nlr_push(&nlr) == 0) {
|
||||
(*func)(arg);
|
||||
nlr_pop();
|
||||
return mp_const_none;
|
||||
return NULL;
|
||||
} else {
|
||||
return MP_OBJ_FROM_PTR(nlr.ret_val);
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ use core::mem::MaybeUninit;
|
||||
|
||||
use crate::error::Error;
|
||||
|
||||
use super::{ffi, obj::Obj};
|
||||
use super::ffi;
|
||||
|
||||
/// Raise a micropython exception via NLR jump.
|
||||
/// Jumps directly out of the context without running any destructors,
|
||||
@ -34,7 +34,7 @@ where
|
||||
// boundary, so we assign it explicitly in `wrapper`.
|
||||
let mut result = MaybeUninit::zeroed();
|
||||
let mut wrapper = || {
|
||||
result = MaybeUninit::new(func());
|
||||
result.write(func());
|
||||
};
|
||||
// `wrapper` is a closure, and to pass it over the FFI, we split it into a
|
||||
// function pointer, and a user-data pointer.
|
||||
@ -42,7 +42,7 @@ where
|
||||
// `argument`.
|
||||
let (callback, argument) = split_func_into_callback_and_argument(&mut wrapper);
|
||||
let exception = ffi::trezor_obj_call_protected(Some(callback), argument);
|
||||
if exception == Obj::const_none() {
|
||||
if exception.is_null() {
|
||||
Ok(result.assume_init())
|
||||
} else {
|
||||
Err(Error::CaughtException(exception))
|
||||
|
@ -54,7 +54,7 @@ brew install scons sdl2 sdl2_image pkg-config llvm
|
||||
|
||||
## Rust
|
||||
|
||||
You will require Rust and Cargo. The currently supported version is 1.52 stable.
|
||||
You will require Rust and Cargo. The currently supported version is 1.55 stable.
|
||||
The recommended way to install both is with [`rustup`](https://rustup.rs/). If you
|
||||
are installing `rustup` for the first time, the stable toolchain will be installed
|
||||
for you automatically. Otherwise, make sure you are up to date:
|
||||
|
Loading…
Reference in New Issue
Block a user