diff --git a/core/embed/rust/Cargo.lock b/core/embed/rust/Cargo.lock index cee528409..4e00b8424 100644 --- a/core/embed/rust/Cargo.lock +++ b/core/embed/rust/Cargo.lock @@ -73,9 +73,9 @@ dependencies = [ [[package]] name = "cstr_core" -version = "0.2.4" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "917ba9efe9e1e736671d5a03f006afc4e7e3f32503e2077e0bcaf519c0c8c1d3" +checksum = "dd98742e4fdca832d40cab219dc2e3048de17d873248f83f17df47c1bea70956" dependencies = [ "cty", "memchr", diff --git a/core/embed/rust/Cargo.toml b/core/embed/rust/Cargo.toml index dd3e0ea16..4e7ca7bdc 100644 --- a/core/embed/rust/Cargo.toml +++ b/core/embed/rust/Cargo.toml @@ -90,8 +90,9 @@ default_features = false version = "0.3.3" [dependencies.cstr_core] -version = "0.2.4" -default_features = false +version = "0.2.6" +default-features = false +features = ["nightly"] # Build dependencies diff --git a/core/embed/rust/src/error.rs b/core/embed/rust/src/error.rs index 044adf517..417b4dfb3 100644 --- a/core/embed/rust/src/error.rs +++ b/core/embed/rust/src/error.rs @@ -29,7 +29,7 @@ pub enum Error { #[macro_export] macro_rules! value_error { ($msg:expr) => { - Error::ValueError(cstr!($msg)) + Error::ValueError(cstr_core::cstr!($msg)) }; } diff --git a/core/embed/rust/src/protobuf/error.rs b/core/embed/rust/src/protobuf/error.rs index 78449fc33..90cf2ee38 100644 --- a/core/embed/rust/src/protobuf/error.rs +++ b/core/embed/rust/src/protobuf/error.rs @@ -2,13 +2,11 @@ use cstr_core::cstr; use crate::{error::Error, micropython::qstr::Qstr}; -// XXX const version of `from_bytes_with_nul_unchecked` is nightly-only. - -pub fn experimental_not_enabled() -> Error { +pub const fn experimental_not_enabled() -> Error { value_error!("Experimental features are disabled.") } -pub fn unknown_field_type() -> Error { +pub const fn unknown_field_type() -> Error { value_error!("Unknown field type.") } @@ -20,6 +18,6 @@ pub fn invalid_value(field: Qstr) -> Error { Error::ValueErrorParam(cstr!("Invalid value for field."), field.into()) } -pub fn end_of_buffer() -> Error { +pub const fn end_of_buffer() -> Error { value_error!("End of buffer.") } diff --git a/core/embed/rust/src/trezorhal/storage.rs b/core/embed/rust/src/trezorhal/storage.rs index d4cd14f4d..8266acce8 100644 --- a/core/embed/rust/src/trezorhal/storage.rs +++ b/core/embed/rust/src/trezorhal/storage.rs @@ -3,7 +3,7 @@ use super::ffi; use crate::error::Error; use core::ptr; -use cstr_core::{cstr, CStr}; +use cstr_core::CStr; /// Result of PIN delay callback. #[derive(Copy, Clone, Debug, PartialEq, Eq)] diff --git a/core/embed/rust/src/ui/layout/util.rs b/core/embed/rust/src/ui/layout/util.rs index 57b3a2f53..560a064b9 100644 --- a/core/embed/rust/src/ui/layout/util.rs +++ b/core/embed/rust/src/ui/layout/util.rs @@ -18,7 +18,6 @@ use crate::{ util::set_animation_disabled, }, }; -use cstr_core::cstr; use heapless::Vec; #[cfg(feature = "jpeg")] diff --git a/core/embed/rust/src/ui/model_tt/layout.rs b/core/embed/rust/src/ui/model_tt/layout.rs index 0ef4e3a0c..44f5abd51 100644 --- a/core/embed/rust/src/ui/model_tt/layout.rs +++ b/core/embed/rust/src/ui/model_tt/layout.rs @@ -1,5 +1,4 @@ use core::{cmp::Ordering, convert::TryInto}; -use cstr_core::cstr; use crate::{ error::Error,