1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-05-07 17:39:03 +00:00

chore(core/rust): bump cstr_core, enable nightly features

So that cstr! can be used in const contexts. This is not critical but it's nice-to-have as long as we are on nightly anyway.
This commit is contained in:
matejcik 2023-11-27 12:49:22 +01:00 committed by matejcik
parent c8fa687c1e
commit d674634c86
7 changed files with 10 additions and 13 deletions

View File

@ -73,9 +73,9 @@ dependencies = [
[[package]] [[package]]
name = "cstr_core" name = "cstr_core"
version = "0.2.4" version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "917ba9efe9e1e736671d5a03f006afc4e7e3f32503e2077e0bcaf519c0c8c1d3" checksum = "dd98742e4fdca832d40cab219dc2e3048de17d873248f83f17df47c1bea70956"
dependencies = [ dependencies = [
"cty", "cty",
"memchr", "memchr",

View File

@ -90,8 +90,9 @@ default_features = false
version = "0.3.3" version = "0.3.3"
[dependencies.cstr_core] [dependencies.cstr_core]
version = "0.2.4" version = "0.2.6"
default_features = false default-features = false
features = ["nightly"]
# Build dependencies # Build dependencies

View File

@ -29,7 +29,7 @@ pub enum Error {
#[macro_export] #[macro_export]
macro_rules! value_error { macro_rules! value_error {
($msg:expr) => { ($msg:expr) => {
Error::ValueError(cstr!($msg)) Error::ValueError(cstr_core::cstr!($msg))
}; };
} }

View File

@ -2,13 +2,11 @@ use cstr_core::cstr;
use crate::{error::Error, micropython::qstr::Qstr}; use crate::{error::Error, micropython::qstr::Qstr};
// XXX const version of `from_bytes_with_nul_unchecked` is nightly-only. pub const fn experimental_not_enabled() -> Error {
pub fn experimental_not_enabled() -> Error {
value_error!("Experimental features are disabled.") value_error!("Experimental features are disabled.")
} }
pub fn unknown_field_type() -> Error { pub const fn unknown_field_type() -> Error {
value_error!("Unknown field type.") 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()) 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.") value_error!("End of buffer.")
} }

View File

@ -3,7 +3,7 @@
use super::ffi; use super::ffi;
use crate::error::Error; use crate::error::Error;
use core::ptr; use core::ptr;
use cstr_core::{cstr, CStr}; use cstr_core::CStr;
/// Result of PIN delay callback. /// Result of PIN delay callback.
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]

View File

@ -18,7 +18,6 @@ use crate::{
util::set_animation_disabled, util::set_animation_disabled,
}, },
}; };
use cstr_core::cstr;
use heapless::Vec; use heapless::Vec;
#[cfg(feature = "jpeg")] #[cfg(feature = "jpeg")]

View File

@ -1,5 +1,4 @@
use core::{cmp::Ordering, convert::TryInto}; use core::{cmp::Ordering, convert::TryInto};
use cstr_core::cstr;
use crate::{ use crate::{
error::Error, error::Error,