build(core): use `#![deny(clippy::cast_lossless)]`
What changed, and why it matters
This commit only changes build-time lint settings for the Rust compiler. It adds a stricter style check (clippy::cast_lossless) across the project and explicitly allows that same check in auto-generated code where it would be noisy and unhelpful. There is no change to any executable logic, no bug fix, and no security-relevant behavior change.
No action required. This is a code-quality/build-hygiene change with no security or functional impact.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit adds #![deny(clippy::cast_lossless)] to core/embed/rust/src/lib.rs and #![allow(clippy::cast_lossless)] to core/embed/rust/src/trezorhal/ffi.rs. cast_lossless is a Clippy lint that warns when a numeric cast is performed that could be replaced by a safer, semantically equivalent conversion method (e.g., u8::from(x) instead of x as u8). Denying the lint makes the build fail if such patterns are introduced in hand-written code, while allowing it in trezorhal.rs (auto-generated by bindgen) avoids false positives in generated FFI bindings. No runtime code is modified.
Changed components
core/embed/rust/src/lib.rscore/embed/rust/src/trezorhal/ffi.rsInspect captured patch +2 / −0
diff --git a/core/embed/rust/src/lib.rs b/core/embed/rust/src/lib.rs
index ecfe935b..94a0f574 100644
--- a/core/embed/rust/src/lib.rs
+++ b/core/embed/rust/src/lib.rs
@@ -1,5 +1,6 @@
#![cfg_attr(not(test), no_std)]
#![deny(clippy::all)]
+#![deny(clippy::cast_lossless)]
#![allow(clippy::new_without_default)]
#![allow(clippy::ptr_offset_with_cast)] // workaround https://github.com/rust-lang/rust-bindgen/issues/3053
#![deny(unsafe_op_in_unsafe_fn)]
diff --git a/core/embed/rust/src/trezorhal/ffi.rs b/core/embed/rust/src/trezorhal/ffi.rs
index 819ee593..3998a53e 100644
--- a/core/embed/rust/src/trezorhal/ffi.rs
+++ b/core/embed/rust/src/trezorhal/ffi.rs
@@ -6,5 +6,6 @@
#![allow(unnecessary_transmutes)]
#![allow(clippy::transmute_int_to_bool)]
#![allow(clippy::too_many_arguments)]
+#![allow(clippy::cast_lossless)]
include!(concat!(env!("OUT_DIR"), "/trezorhal.rs"));
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.