What changed, and why it matters
This commit is a routine code cleanup to satisfy the Rust Clippy linter. It removes unnecessary reference symbols (&), rewrites a small match block to assign a value directly, and removes an unused import. There is no functional change and no security relevance visible in the diff.
No security action required; treat as normal refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit applies Clippy-suggested style fixes in core/embed/rust: passing builtin exception types by value instead of reference to Exception::new/Exception::new_with_arg, removing an explicit return in a fallible conversion, changing two to_string methods to take self by value and return &’static str, simplifying a match expression in paragraph layout logic, and removing an unused Tuple import. No behavior changes are introduced.
Changed components
core/embed/rust/src/definitions/error.rscore/embed/rust/src/micropython/error.rscore/embed/rust/src/micropython/exception.rscore/embed/rust/src/micropython/tuple.rscore/embed/rust/src/thp/error.rscore/embed/rust/src/translations/error.rscore/embed/rust/src/ui/component/text/paragraphs.rscore/embed/rust/src/ui/layout_eckhart/component_msg_obj.rsInspect captured patch +21 / −23
### core/embed/rust/src/definitions/error.rs
@@ -24,7 +24,7 @@ impl From<crate::io::Error> for Error {
}
impl Error {
- pub fn to_string(&self) -> &str {
+ pub fn to_string(self) -> &'static str {
match self {
Error::InvalidDefinition => INVALID_DEFINITION_STR,
Error::InvalidSignature => INVALID_SIGNATURE_STR,
### core/embed/rust/src/micropython/error.rs
@@ -27,24 +27,24 @@ impl Error {
/// Create an exception instance matching the error code.
pub fn into_exception(self) -> Exception {
match self {
- Error::TypeError => Exception::new(&builtin::TypeError, &[]),
- Error::OutOfRange => Exception::new(&builtin::OverflowError, &[]),
- Error::MissingKwargs => Exception::new(&builtin::TypeError, &[]),
- Error::AllocationFailed => Exception::new(&builtin::MemoryError, &[]),
- Error::IndexError => Exception::new(&builtin::IndexError, &[]),
- Error::KeyError(key) => Exception::new_with_arg(&builtin::KeyError, key),
- Error::ValueError(msg) => Exception::new_with_arg(&builtin::ValueError, msg),
+ Error::TypeError => Exception::new(builtin::TypeError, &[]),
+ Error::OutOfRange => Exception::new(builtin::OverflowError, &[]),
+ Error::MissingKwargs => Exception::new(builtin::TypeError, &[]),
+ Error::AllocationFailed => Exception::new(builtin::MemoryError, &[]),
+ Error::IndexError => Exception::new(builtin::IndexError, &[]),
+ Error::KeyError(key) => Exception::new_with_arg(builtin::KeyError, key),
+ Error::ValueError(msg) => Exception::new_with_arg(builtin::ValueError, msg),
Error::ValueErrorParam(msg, param) => {
let args: &[Obj] = match msg.try_into() {
Ok(msg) => &[msg, param],
Err(_) => &[],
};
- Exception::new(&builtin::ValueError, args)
+ Exception::new(builtin::ValueError, args)
}
- Error::AttributeError(attr) => Exception::new_with_arg(&builtin::AttributeError, attr),
- Error::EOFError => Exception::new(&builtin::EOFError, &[]),
- Error::RuntimeError(msg) => Exception::new_with_arg(&builtin::RuntimeError, msg),
- Error::NotImplementedError => Exception::new(&builtin::NotImplementedError, &[]),
+ Error::AttributeError(attr) => Exception::new_with_arg(builtin::AttributeError, attr),
+ Error::EOFError => Exception::new(builtin::EOFError, &[]),
+ Error::RuntimeError(msg) => Exception::new_with_arg(builtin::RuntimeError, msg),
+ Error::NotImplementedError => Exception::new(builtin::NotImplementedError, &[]),
Error::Exception(exception) => exception,
}
}
### core/embed/rust/src/micropython/exception.rs
@@ -216,7 +216,7 @@ impl Exception {
}
fn conversion_failed_exception() -> Exception {
- Exception::new_with_arg(&builtin::TypeError, "Caught a non-exception object")
+ Exception::new_with_arg(builtin::TypeError, "Caught a non-exception object")
}
impl TryFrom<Obj> for Exception {
### core/embed/rust/src/micropython/tuple.rs
@@ -65,7 +65,7 @@ impl TryFrom<Obj> for Gc<Tuple> {
let this = unsafe { Gc::from_raw(obj.as_ptr().cast()) };
Ok(this)
} else {
- return Err(Error::TypeError);
+ Err(Error::TypeError)
}
}
}
### core/embed/rust/src/thp/error.rs
@@ -15,7 +15,7 @@ pub(super) enum Error {
}
pub(super) static THP_EXCEPTION_TYPE: ExceptionType =
- ExceptionType::new(&builtin::Exception, Qstr::MP_QSTR_ThpError);
+ ExceptionType::new(builtin::Exception, Qstr::MP_QSTR_ThpError);
fn thp_exception_str(error: ThpError) -> &'static str {
match error {
### core/embed/rust/src/translations/error.rs
@@ -30,7 +30,7 @@ impl From<core::str::Utf8Error> for Error {
}
impl Error {
- pub fn to_string(&self) -> &str {
+ pub fn to_string(self) -> &'static str {
match self {
Error::InvalidString => INVALID_TRANSLATIONS_BLOB,
Error::TranslationsInUse => "Translations in use",
### core/embed/rust/src/ui/component/text/paragraphs.rs
@@ -479,24 +479,23 @@ impl PageOffset {
let layout = TextLayoutProxy::new(self, used);
- let page_full: bool;
- match fit {
+ let page_full = match fit {
LayoutFit::Fitting { .. } => {
// Continue with start of next paragraph.
self.par += 1;
self.chr = 0;
// Handle hard break if requested for this paragraph.
- page_full = paragraph.break_after;
+ paragraph.break_after
}
LayoutFit::OutOfBounds {
processed_chars, ..
} => {
// Reached end of the page and not all content fits.
self.chr += processed_chars;
// Do not render more paragraphs.
- page_full = true;
+ true
}
- }
+ };
PageOffsetAdvance {
offset: self,
### core/embed/rust/src/ui/layout_eckhart/component_msg_obj.rs
@@ -7,7 +7,6 @@ use super::firmware::{
SelectWordScreen, SetBrightnessScreen, StringInput, StringKeyboard, StringKeyboardMsg,
TextScreen, TextScreenMsg, ValueInput, ValueInputScreen, ValueInputScreenMsg,
};
-use crate::micropython::tuple::Tuple;
use crate::micropython::{Error, Obj};
#[cfg(not(feature = "clippy"))]
use crate::ui::component::{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.