1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-27 09:58:27 +00:00
trezor-firmware/core/embed/rust/src/lib.rs

42 lines
1.2 KiB
Rust
Raw Normal View History

#![cfg_attr(not(test), no_std)]
#![deny(clippy::all)]
#![allow(clippy::new_without_default)]
#![deny(unsafe_op_in_unsafe_fn)]
#![allow(dead_code)]
mod error;
#[cfg(feature = "micropython")]
#[macro_use]
mod micropython;
#[cfg(feature = "protobuf")]
2021-03-23 12:30:03 +00:00
mod protobuf;
mod time;
#[cfg(feature = "ui_debug")]
mod trace;
mod trezorhal;
#[cfg(feature = "ui")]
#[macro_use]
pub mod ui;
#[cfg(not(test))]
#[cfg(any(not(feature = "test"), feature = "clippy"))]
#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
use cstr_core::CStr;
// Although it would be ideal to use the original error message, ignoring it
// lets us avoid the `fmt` machinery and its code size and is also important for
// security reasons, as we do not always controls the message contents. We
// should also avoid printing "panic" or "rust" on the user screen to avoid any
// confusion.
// SAFETY: Safe because we are passing in \0-terminated literals.
let empty = unsafe { CStr::from_bytes_with_nul_unchecked(b"\0") };
let msg = unsafe { CStr::from_bytes_with_nul_unchecked(b"rs\0") };
// TODO: Ideally we would take the file and line info out of
// `PanicInfo::location()`.
trezorhal::common::fatal_error(empty, msg, empty, 0, empty);
}