feat(core): allow fallible conversion of `i16` into `Obj`
What changed, and why it matters
This is a small, safe Rust language addition that lets the firmware convert a signed 16-bit integer (i16) into an internal MicroPython object type, mirroring existing conversions already done for unsigned 8-bit and 16-bit integers. There is no user-facing change, no bug fix, and no security relevance visible in the commit.
No action required. Treat as routine feature/infrastructure code.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit adds a single TryFrom<Obj> for i16 implementation in core/embed/rust/src/micropython/obj.rs. It reuses the existing fallible i32 conversion and then narrows to i16 with Self::try_from(val), so it cannot introduce truncation or overflow. The pattern is identical to the pre-existing u8 and u16 implementations.
Changed components
core/embed/rust/src/micropython/obj.rsInspect captured patch +10 / −0
diff --git a/core/embed/rust/src/micropython/obj.rs b/core/embed/rust/src/micropython/obj.rs
index 701e485e..b6e9280c 100644
--- a/core/embed/rust/src/micropython/obj.rs
+++ b/core/embed/rust/src/micropython/obj.rs
@@ -382,6 +382,16 @@ impl TryFrom<Obj> for u16 {
}
}
+impl TryFrom<Obj> for i16 {
+ type Error = Error;
+
+ fn try_from(obj: Obj) -> Result<Self, Self::Error> {
+ let val = i32::try_from(obj)?;
+ let this = Self::try_from(val)?;
+ Ok(this)
+ }
+}
+
impl TryFrom<Obj> for u32 {
type Error = Error;
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.