Skip to content

build(core): add #![warn(clippy::cast_lossless)] - #6849

Merged
romanz merged 3 commits into
mainfrom
romanz/2604/clippy-cast
Jul 15, 2026
Merged

build(core): add #![warn(clippy::cast_lossless)]#6849
romanz merged 3 commits into
mainfrom
romanz/2604/clippy-cast

Conversation

@romanz

@romanz romanz commented Apr 29, 2026

Copy link
Copy Markdown
Contributor
warning: `trezor_lib` (lib) generated 253 warnings (run `cargo clippy --fix --lib -p trezor_lib -- ` to apply 233 suggestions)

https://github.com/trezor/trezor-firmware/actions/runs/25099514846/job/73545397242?pr=6849#step:6:3675

@trezor-bot trezor-bot Bot added this to Firmware Apr 29, 2026
@github-project-automation github-project-automation Bot moved this to 🔎 Needs review in Firmware Apr 29, 2026
@coderabbitai

coderabbitai Bot commented Apr 29, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The Rust crate now enforces clippy::cast_lossless and replaces lossless as casts with explicit conversions across core utilities, protocol handling, UI layouts, display code, and rendering math. The FFI bindings explicitly allow the lint. Integer interpolation implementations for i32 and u32 were removed, with tests updated to use i16 and u16.

Estimated code review effort: 3 (Moderate) | ~30 minutes

Suggested labels: core, code, rust

Suggested reviewers: matejcik, obrusvit, jjanku

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is mostly raw warning output and the template is not filled in with status, project/sprint setup, or QA notes. Replace the log snippet with a filled PR template, including the change summary, PR status/setup fields, and Notes for QA if testable.
Docstring Coverage ⚠️ Warning Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the main change of enforcing clippy::cast_lossless in core, though it understates the broader cast-fix cleanup.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch romanz/2604/clippy-cast

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Apr 29, 2026

Copy link
Copy Markdown

en main(all)

model device_test click_test persistence_test
T2T1 test(all) main(all) test(all) main(all) test(all) main(all)
T3B1 test(all) main(all) test(all) main(all) test(all) main(all)
T3T1 test(all) main(all) test(all) main(all) test(all) main(all)
T3W1 test(all) main(all) test(all) main(all) test(all) main(all)

Latest CI run: 29397302285

@romanz romanz added the no-QA On PR-merge, automatically transition status in the "Firmware" project to "Done (no QA)" state. label Apr 29, 2026
@mmilata

mmilata commented May 5, 2026

Copy link
Copy Markdown
Member

Pushed the result of cargo clippy --fix. Warnings remain for trezorhal.rs (generated) and lerp.rs, we can either add exceptions or just treat it as one time fix.

@romanz
romanz force-pushed the romanz/2604/clippy-cast branch 2 times, most recently from 72efc4e to 099e4ed Compare July 12, 2026 13:23
@romanz

romanz commented Jul 12, 2026

Copy link
Copy Markdown
Contributor Author

Rebased over main, added 8a903c7, 9aeabd3 & c7f563f (resolving clippy warnings) and 099e4ed (denying clippy::cast_lossless).

@romanz
romanz marked this pull request as ready for review July 12, 2026 14:38

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@core/embed/rust/src/ui/layout_bolt/component/number_input_slider.rs`:
- Line 117: Update NumberInputSlider::new to reject configurations where min is
greater than or equal to max, preventing zero-range division in slider_eval and
render. Preserve normal initialization for valid ranges and use the
constructor’s existing error or validation mechanism if available.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a23e985e-be59-4122-963e-9dbf2f896561

📥 Commits

Reviewing files that changed from the base of the PR and between b235e01 and 099e4ed.

📒 Files selected for processing (82)
  • core/embed/rust/src/crypto/crc32.rs
  • core/embed/rust/src/io.rs
  • core/embed/rust/src/lib.rs
  • core/embed/rust/src/micropython/buffer.rs
  • core/embed/rust/src/micropython/obj.rs
  • core/embed/rust/src/protobuf/encode.rs
  • core/embed/rust/src/smp/base64.rs
  • core/embed/rust/src/smp/crc16.rs
  • core/embed/rust/src/smp/mod.rs
  • core/embed/rust/src/strutil.rs
  • core/embed/rust/src/trezorhal/ble/mod.rs
  • core/embed/rust/src/trezorhal/ffi.rs
  • core/embed/rust/src/trezorhal/uzlib.rs
  • core/embed/rust/src/ui/component/qr_code.rs
  • core/embed/rust/src/ui/component/swipe.rs
  • core/embed/rust/src/ui/component/swipe_detect.rs
  • core/embed/rust/src/ui/component/timeout.rs
  • core/embed/rust/src/ui/display/color.rs
  • core/embed/rust/src/ui/display/font.rs
  • core/embed/rust/src/ui/display/image.rs
  • core/embed/rust/src/ui/layout_bolt/bootloader/menu.rs
  • core/embed/rust/src/ui/layout_bolt/bootloader/mod.rs
  • core/embed/rust/src/ui/layout_bolt/component/address_details.rs
  • core/embed/rust/src/ui/layout_bolt/component/button.rs
  • core/embed/rust/src/ui/layout_bolt/component/coinjoin_progress.rs
  • core/embed/rust/src/ui/layout_bolt/component/confirm_pairing.rs
  • core/embed/rust/src/ui/layout_bolt/component/keyboard/passphrase.rs
  • core/embed/rust/src/ui/layout_bolt/component/keyboard/pin.rs
  • core/embed/rust/src/ui/layout_bolt/component/loader.rs
  • core/embed/rust/src/ui/layout_bolt/component/number_input.rs
  • core/embed/rust/src/ui/layout_bolt/component/number_input_slider.rs
  • core/embed/rust/src/ui/layout_bolt/component/page.rs
  • core/embed/rust/src/ui/layout_bolt/component/progress.rs
  • core/embed/rust/src/ui/layout_bolt/component/simple_page.rs
  • core/embed/rust/src/ui/layout_bolt/component/swipe.rs
  • core/embed/rust/src/ui/layout_bolt/prodtest/welcome.rs
  • core/embed/rust/src/ui/layout_caesar/component/button.rs
  • core/embed/rust/src/ui/layout_caesar/component/flow_pages.rs
  • core/embed/rust/src/ui/layout_caesar/component/loader.rs
  • core/embed/rust/src/ui/layout_caesar/component/page.rs
  • core/embed/rust/src/ui/layout_caesar/component/scrollbar.rs
  • core/embed/rust/src/ui/layout_caesar/cshape/dotted_line.rs
  • core/embed/rust/src/ui/layout_delizia/bootloader/mod.rs
  • core/embed/rust/src/ui/layout_delizia/component/address_details.rs
  • core/embed/rust/src/ui/layout_delizia/component/coinjoin_progress.rs
  • core/embed/rust/src/ui/layout_delizia/component/footer.rs
  • core/embed/rust/src/ui/layout_delizia/component/frame.rs
  • core/embed/rust/src/ui/layout_delizia/component/homescreen.rs
  • core/embed/rust/src/ui/layout_delizia/component/keyboard/passphrase.rs
  • core/embed/rust/src/ui/layout_delizia/component/keyboard/pin.rs
  • core/embed/rust/src/ui/layout_delizia/component/loader.rs
  • core/embed/rust/src/ui/layout_delizia/component/number_input.rs
  • core/embed/rust/src/ui/layout_delizia/component/number_input_slider.rs
  • core/embed/rust/src/ui/layout_delizia/component/progress.rs
  • core/embed/rust/src/ui/layout_delizia/component/share_words.rs
  • core/embed/rust/src/ui/layout_delizia/component/swipe_content.rs
  • core/embed/rust/src/ui/layout_delizia/component/vertical_menu.rs
  • core/embed/rust/src/ui/layout_delizia/flow/request_number.rs
  • core/embed/rust/src/ui/layout_eckhart/component/button.rs
  • core/embed/rust/src/ui/layout_eckhart/component/fuel_gauge.rs
  • core/embed/rust/src/ui/layout_eckhart/cshape/loader.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/brightness_screen.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/hold_to_confirm.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/keyboard/passphrase.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/keyboard/pin.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/keyboard/slip39.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/regulatory_screen.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/text_screen.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/tutorial_screen.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/value_input_screen.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/vertical_menu_screen.rs
  • core/embed/rust/src/ui/layout_eckhart/flow/request_number.rs
  • core/embed/rust/src/ui/layout_eckhart/prodtest/welcome.rs
  • core/embed/rust/src/ui/layout_eckhart/theme/gradient.rs
  • core/embed/rust/src/ui/lerp.rs
  • core/embed/rust/src/ui/shape/canvas/common.rs
  • core/embed/rust/src/ui/shape/canvas/mono8.rs
  • core/embed/rust/src/ui/shape/canvas/rgba8888.rs
  • core/embed/rust/src/ui/shape/qrcode.rs
  • core/embed/rust/src/ui/shape/utils/blur.rs
  • core/embed/rust/src/ui/shape/utils/circle.rs
  • core/embed/rust/src/ui/shape/utils/line.rs

Comment thread core/embed/rust/src/ui/layout_bolt/component/number_input_slider.rs
@romanz

romanz commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

Squashing fixups.

@romanz
romanz force-pushed the romanz/2604/clippy-cast branch from 099e4ed to fb56758 Compare July 13, 2026 13:42

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@core/embed/rust/src/ui/layout_eckhart/theme/gradient.rs`:
- Around line 190-191: Update all three half-width calculations in the gradient
layout code to convert area.width() to f32 before dividing by 2. Apply this to
the calculations near x_half_width and the corresponding half-width expressions
around the other referenced sections, preserving fractional values and avoiding
a zero denominator for width 1.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b9e6ec16-bf9a-46e1-b321-9bce61243d52

📥 Commits

Reviewing files that changed from the base of the PR and between 099e4ed and fb56758.

📒 Files selected for processing (82)
  • core/embed/rust/src/crypto/crc32.rs
  • core/embed/rust/src/io.rs
  • core/embed/rust/src/lib.rs
  • core/embed/rust/src/micropython/buffer.rs
  • core/embed/rust/src/micropython/obj.rs
  • core/embed/rust/src/protobuf/encode.rs
  • core/embed/rust/src/smp/base64.rs
  • core/embed/rust/src/smp/crc16.rs
  • core/embed/rust/src/smp/mod.rs
  • core/embed/rust/src/strutil.rs
  • core/embed/rust/src/trezorhal/ble/mod.rs
  • core/embed/rust/src/trezorhal/ffi.rs
  • core/embed/rust/src/trezorhal/uzlib.rs
  • core/embed/rust/src/ui/component/qr_code.rs
  • core/embed/rust/src/ui/component/swipe.rs
  • core/embed/rust/src/ui/component/swipe_detect.rs
  • core/embed/rust/src/ui/component/timeout.rs
  • core/embed/rust/src/ui/display/color.rs
  • core/embed/rust/src/ui/display/font.rs
  • core/embed/rust/src/ui/display/image.rs
  • core/embed/rust/src/ui/layout_bolt/bootloader/menu.rs
  • core/embed/rust/src/ui/layout_bolt/bootloader/mod.rs
  • core/embed/rust/src/ui/layout_bolt/component/address_details.rs
  • core/embed/rust/src/ui/layout_bolt/component/button.rs
  • core/embed/rust/src/ui/layout_bolt/component/coinjoin_progress.rs
  • core/embed/rust/src/ui/layout_bolt/component/confirm_pairing.rs
  • core/embed/rust/src/ui/layout_bolt/component/keyboard/passphrase.rs
  • core/embed/rust/src/ui/layout_bolt/component/keyboard/pin.rs
  • core/embed/rust/src/ui/layout_bolt/component/loader.rs
  • core/embed/rust/src/ui/layout_bolt/component/number_input.rs
  • core/embed/rust/src/ui/layout_bolt/component/number_input_slider.rs
  • core/embed/rust/src/ui/layout_bolt/component/page.rs
  • core/embed/rust/src/ui/layout_bolt/component/progress.rs
  • core/embed/rust/src/ui/layout_bolt/component/simple_page.rs
  • core/embed/rust/src/ui/layout_bolt/component/swipe.rs
  • core/embed/rust/src/ui/layout_bolt/prodtest/welcome.rs
  • core/embed/rust/src/ui/layout_caesar/component/button.rs
  • core/embed/rust/src/ui/layout_caesar/component/flow_pages.rs
  • core/embed/rust/src/ui/layout_caesar/component/loader.rs
  • core/embed/rust/src/ui/layout_caesar/component/page.rs
  • core/embed/rust/src/ui/layout_caesar/component/scrollbar.rs
  • core/embed/rust/src/ui/layout_caesar/cshape/dotted_line.rs
  • core/embed/rust/src/ui/layout_delizia/bootloader/mod.rs
  • core/embed/rust/src/ui/layout_delizia/component/address_details.rs
  • core/embed/rust/src/ui/layout_delizia/component/coinjoin_progress.rs
  • core/embed/rust/src/ui/layout_delizia/component/footer.rs
  • core/embed/rust/src/ui/layout_delizia/component/frame.rs
  • core/embed/rust/src/ui/layout_delizia/component/homescreen.rs
  • core/embed/rust/src/ui/layout_delizia/component/keyboard/passphrase.rs
  • core/embed/rust/src/ui/layout_delizia/component/keyboard/pin.rs
  • core/embed/rust/src/ui/layout_delizia/component/loader.rs
  • core/embed/rust/src/ui/layout_delizia/component/number_input.rs
  • core/embed/rust/src/ui/layout_delizia/component/number_input_slider.rs
  • core/embed/rust/src/ui/layout_delizia/component/progress.rs
  • core/embed/rust/src/ui/layout_delizia/component/share_words.rs
  • core/embed/rust/src/ui/layout_delizia/component/swipe_content.rs
  • core/embed/rust/src/ui/layout_delizia/component/vertical_menu.rs
  • core/embed/rust/src/ui/layout_delizia/flow/request_number.rs
  • core/embed/rust/src/ui/layout_eckhart/component/button.rs
  • core/embed/rust/src/ui/layout_eckhart/component/fuel_gauge.rs
  • core/embed/rust/src/ui/layout_eckhart/cshape/loader.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/brightness_screen.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/hold_to_confirm.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/keyboard/passphrase.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/keyboard/pin.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/keyboard/slip39.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/regulatory_screen.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/text_screen.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/tutorial_screen.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/value_input_screen.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/vertical_menu_screen.rs
  • core/embed/rust/src/ui/layout_eckhart/flow/request_number.rs
  • core/embed/rust/src/ui/layout_eckhart/prodtest/welcome.rs
  • core/embed/rust/src/ui/layout_eckhart/theme/gradient.rs
  • core/embed/rust/src/ui/lerp.rs
  • core/embed/rust/src/ui/shape/canvas/common.rs
  • core/embed/rust/src/ui/shape/canvas/mono8.rs
  • core/embed/rust/src/ui/shape/canvas/rgba8888.rs
  • core/embed/rust/src/ui/shape/qrcode.rs
  • core/embed/rust/src/ui/shape/utils/blur.rs
  • core/embed/rust/src/ui/shape/utils/circle.rs
  • core/embed/rust/src/ui/shape/utils/line.rs
🚧 Files skipped from review as they are similar to previous changes (73)
  • core/embed/rust/src/ui/layout_eckhart/prodtest/welcome.rs
  • core/embed/rust/src/smp/crc16.rs
  • core/embed/rust/src/ui/layout_bolt/component/confirm_pairing.rs
  • core/embed/rust/src/ui/shape/qrcode.rs
  • core/embed/rust/src/ui/layout_delizia/component/vertical_menu.rs
  • core/embed/rust/src/ui/layout_eckhart/component/fuel_gauge.rs
  • core/embed/rust/src/ui/layout_delizia/component/address_details.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/regulatory_screen.rs
  • core/embed/rust/src/ui/layout_bolt/component/number_input.rs
  • core/embed/rust/src/trezorhal/ffi.rs
  • core/embed/rust/src/ui/display/image.rs
  • core/embed/rust/src/ui/layout_delizia/component/frame.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/tutorial_screen.rs
  • core/embed/rust/src/ui/display/font.rs
  • core/embed/rust/src/ui/shape/utils/line.rs
  • core/embed/rust/src/ui/layout_delizia/component/number_input_slider.rs
  • core/embed/rust/src/ui/layout_caesar/component/flow_pages.rs
  • core/embed/rust/src/ui/component/timeout.rs
  • core/embed/rust/src/ui/layout_delizia/component/footer.rs
  • core/embed/rust/src/ui/layout_delizia/component/loader.rs
  • core/embed/rust/src/strutil.rs
  • core/embed/rust/src/ui/layout_eckhart/flow/request_number.rs
  • core/embed/rust/src/ui/layout_bolt/bootloader/menu.rs
  • core/embed/rust/src/trezorhal/uzlib.rs
  • core/embed/rust/src/ui/layout_bolt/bootloader/mod.rs
  • core/embed/rust/src/ui/layout_bolt/component/keyboard/pin.rs
  • core/embed/rust/src/ui/layout_bolt/component/simple_page.rs
  • core/embed/rust/src/ui/layout_delizia/component/progress.rs
  • core/embed/rust/src/ui/layout_eckhart/component/button.rs
  • core/embed/rust/src/ui/layout_caesar/cshape/dotted_line.rs
  • core/embed/rust/src/protobuf/encode.rs
  • core/embed/rust/src/ui/layout_bolt/component/page.rs
  • core/embed/rust/src/ui/layout_delizia/component/keyboard/passphrase.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/keyboard/slip39.rs
  • core/embed/rust/src/ui/layout_eckhart/cshape/loader.rs
  • core/embed/rust/src/ui/layout_bolt/component/keyboard/passphrase.rs
  • core/embed/rust/src/lib.rs
  • core/embed/rust/src/ui/layout_bolt/component/number_input_slider.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/hold_to_confirm.rs
  • core/embed/rust/src/ui/layout_caesar/component/page.rs
  • core/embed/rust/src/ui/layout_delizia/component/share_words.rs
  • core/embed/rust/src/ui/layout_bolt/prodtest/welcome.rs
  • core/embed/rust/src/trezorhal/ble/mod.rs
  • core/embed/rust/src/ui/component/swipe.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/keyboard/pin.rs
  • core/embed/rust/src/smp/mod.rs
  • core/embed/rust/src/ui/display/color.rs
  • core/embed/rust/src/micropython/buffer.rs
  • core/embed/rust/src/io.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/value_input_screen.rs
  • core/embed/rust/src/ui/layout_delizia/flow/request_number.rs
  • core/embed/rust/src/ui/shape/canvas/rgba8888.rs
  • core/embed/rust/src/ui/shape/canvas/mono8.rs
  • core/embed/rust/src/ui/layout_bolt/component/coinjoin_progress.rs
  • core/embed/rust/src/micropython/obj.rs
  • core/embed/rust/src/smp/base64.rs
  • core/embed/rust/src/ui/layout_delizia/bootloader/mod.rs
  • core/embed/rust/src/ui/layout_bolt/component/progress.rs
  • core/embed/rust/src/ui/layout_delizia/component/keyboard/pin.rs
  • core/embed/rust/src/ui/layout_caesar/component/loader.rs
  • core/embed/rust/src/ui/layout_delizia/component/swipe_content.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/text_screen.rs
  • core/embed/rust/src/ui/layout_bolt/component/address_details.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/vertical_menu_screen.rs
  • core/embed/rust/src/ui/layout_caesar/component/scrollbar.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/brightness_screen.rs
  • core/embed/rust/src/ui/component/qr_code.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/keyboard/passphrase.rs
  • core/embed/rust/src/ui/shape/utils/circle.rs
  • core/embed/rust/src/ui/layout_delizia/component/number_input.rs
  • core/embed/rust/src/ui/shape/utils/blur.rs
  • core/embed/rust/src/ui/lerp.rs
  • core/embed/rust/src/ui/layout_bolt/component/swipe.rs

Comment thread core/embed/rust/src/ui/layout_eckhart/theme/gradient.rs
romanz and others added 3 commits July 15, 2026 09:25
Since `f32::from()` doesn't support u32/i32.

[no changelog]
Add an exception for `trezorhal.rs` auto-generated code.

[no changelog]
@romanz
romanz force-pushed the romanz/2604/clippy-cast branch from fb56758 to c3cc22a Compare July 15, 2026 07:25

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@core/embed/rust/src/ui/shape/canvas/rgba8888.rs`:
- Around line 118-123: Update the blend arithmetic in the RGBA compositing code
so channel values and alpha multipliers are converted to u32 before
multiplication and addition. Apply this to the r, g, and b calculations while
preserving the existing division by 255 and output behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 16ca625d-a46e-495c-9f38-ae0c36892559

📥 Commits

Reviewing files that changed from the base of the PR and between fb56758 and c3cc22a.

📒 Files selected for processing (82)
  • core/embed/rust/src/crypto/crc32.rs
  • core/embed/rust/src/io.rs
  • core/embed/rust/src/lib.rs
  • core/embed/rust/src/micropython/buffer.rs
  • core/embed/rust/src/micropython/obj.rs
  • core/embed/rust/src/protobuf/encode.rs
  • core/embed/rust/src/smp/base64.rs
  • core/embed/rust/src/smp/crc16.rs
  • core/embed/rust/src/smp/mod.rs
  • core/embed/rust/src/strutil.rs
  • core/embed/rust/src/trezorhal/ble/mod.rs
  • core/embed/rust/src/trezorhal/ffi.rs
  • core/embed/rust/src/trezorhal/uzlib.rs
  • core/embed/rust/src/ui/component/qr_code.rs
  • core/embed/rust/src/ui/component/swipe.rs
  • core/embed/rust/src/ui/component/swipe_detect.rs
  • core/embed/rust/src/ui/component/timeout.rs
  • core/embed/rust/src/ui/display/color.rs
  • core/embed/rust/src/ui/display/font.rs
  • core/embed/rust/src/ui/display/image.rs
  • core/embed/rust/src/ui/layout_bolt/bootloader/menu.rs
  • core/embed/rust/src/ui/layout_bolt/bootloader/mod.rs
  • core/embed/rust/src/ui/layout_bolt/component/address_details.rs
  • core/embed/rust/src/ui/layout_bolt/component/button.rs
  • core/embed/rust/src/ui/layout_bolt/component/coinjoin_progress.rs
  • core/embed/rust/src/ui/layout_bolt/component/confirm_pairing.rs
  • core/embed/rust/src/ui/layout_bolt/component/keyboard/passphrase.rs
  • core/embed/rust/src/ui/layout_bolt/component/keyboard/pin.rs
  • core/embed/rust/src/ui/layout_bolt/component/loader.rs
  • core/embed/rust/src/ui/layout_bolt/component/number_input.rs
  • core/embed/rust/src/ui/layout_bolt/component/number_input_slider.rs
  • core/embed/rust/src/ui/layout_bolt/component/page.rs
  • core/embed/rust/src/ui/layout_bolt/component/progress.rs
  • core/embed/rust/src/ui/layout_bolt/component/simple_page.rs
  • core/embed/rust/src/ui/layout_bolt/component/swipe.rs
  • core/embed/rust/src/ui/layout_bolt/prodtest/welcome.rs
  • core/embed/rust/src/ui/layout_caesar/component/button.rs
  • core/embed/rust/src/ui/layout_caesar/component/flow_pages.rs
  • core/embed/rust/src/ui/layout_caesar/component/loader.rs
  • core/embed/rust/src/ui/layout_caesar/component/page.rs
  • core/embed/rust/src/ui/layout_caesar/component/scrollbar.rs
  • core/embed/rust/src/ui/layout_caesar/cshape/dotted_line.rs
  • core/embed/rust/src/ui/layout_delizia/bootloader/mod.rs
  • core/embed/rust/src/ui/layout_delizia/component/address_details.rs
  • core/embed/rust/src/ui/layout_delizia/component/coinjoin_progress.rs
  • core/embed/rust/src/ui/layout_delizia/component/footer.rs
  • core/embed/rust/src/ui/layout_delizia/component/frame.rs
  • core/embed/rust/src/ui/layout_delizia/component/homescreen.rs
  • core/embed/rust/src/ui/layout_delizia/component/keyboard/passphrase.rs
  • core/embed/rust/src/ui/layout_delizia/component/keyboard/pin.rs
  • core/embed/rust/src/ui/layout_delizia/component/loader.rs
  • core/embed/rust/src/ui/layout_delizia/component/number_input.rs
  • core/embed/rust/src/ui/layout_delizia/component/number_input_slider.rs
  • core/embed/rust/src/ui/layout_delizia/component/progress.rs
  • core/embed/rust/src/ui/layout_delizia/component/share_words.rs
  • core/embed/rust/src/ui/layout_delizia/component/swipe_content.rs
  • core/embed/rust/src/ui/layout_delizia/component/vertical_menu.rs
  • core/embed/rust/src/ui/layout_delizia/flow/request_number.rs
  • core/embed/rust/src/ui/layout_eckhart/component/button.rs
  • core/embed/rust/src/ui/layout_eckhart/component/fuel_gauge.rs
  • core/embed/rust/src/ui/layout_eckhart/cshape/loader.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/brightness_screen.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/hold_to_confirm.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/keyboard/passphrase.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/keyboard/pin.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/keyboard/slip39.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/regulatory_screen.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/text_screen.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/tutorial_screen.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/value_input_screen.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/vertical_menu_screen.rs
  • core/embed/rust/src/ui/layout_eckhart/flow/request_number.rs
  • core/embed/rust/src/ui/layout_eckhart/prodtest/welcome.rs
  • core/embed/rust/src/ui/layout_eckhart/theme/gradient.rs
  • core/embed/rust/src/ui/lerp.rs
  • core/embed/rust/src/ui/shape/canvas/common.rs
  • core/embed/rust/src/ui/shape/canvas/mono8.rs
  • core/embed/rust/src/ui/shape/canvas/rgba8888.rs
  • core/embed/rust/src/ui/shape/qrcode.rs
  • core/embed/rust/src/ui/shape/utils/blur.rs
  • core/embed/rust/src/ui/shape/utils/circle.rs
  • core/embed/rust/src/ui/shape/utils/line.rs
🚧 Files skipped from review as they are similar to previous changes (67)
  • core/embed/rust/src/ui/layout_eckhart/firmware/keyboard/slip39.rs
  • core/embed/rust/src/ui/layout_delizia/component/loader.rs
  • core/embed/rust/src/trezorhal/ffi.rs
  • core/embed/rust/src/ui/layout_delizia/component/number_input.rs
  • core/embed/rust/src/lib.rs
  • core/embed/rust/src/ui/shape/qrcode.rs
  • core/embed/rust/src/ui/layout_delizia/component/address_details.rs
  • core/embed/rust/src/ui/layout_bolt/component/simple_page.rs
  • core/embed/rust/src/ui/layout_bolt/component/keyboard/passphrase.rs
  • core/embed/rust/src/ui/layout_delizia/component/number_input_slider.rs
  • core/embed/rust/src/ui/layout_eckhart/component/fuel_gauge.rs
  • core/embed/rust/src/ui/component/qr_code.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/regulatory_screen.rs
  • core/embed/rust/src/micropython/buffer.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/keyboard/pin.rs
  • core/embed/rust/src/strutil.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/value_input_screen.rs
  • core/embed/rust/src/ui/shape/utils/line.rs
  • core/embed/rust/src/ui/layout_bolt/bootloader/menu.rs
  • core/embed/rust/src/ui/display/image.rs
  • core/embed/rust/src/protobuf/encode.rs
  • core/embed/rust/src/ui/layout_delizia/component/keyboard/passphrase.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/vertical_menu_screen.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/tutorial_screen.rs
  • core/embed/rust/src/trezorhal/uzlib.rs
  • core/embed/rust/src/ui/layout_eckhart/prodtest/welcome.rs
  • core/embed/rust/src/ui/layout_delizia/component/keyboard/pin.rs
  • core/embed/rust/src/ui/layout_eckhart/component/button.rs
  • core/embed/rust/src/ui/layout_bolt/component/number_input.rs
  • core/embed/rust/src/ui/layout_caesar/component/page.rs
  • core/embed/rust/src/ui/layout_bolt/component/keyboard/pin.rs
  • core/embed/rust/src/ui/shape/canvas/mono8.rs
  • core/embed/rust/src/ui/layout_delizia/component/vertical_menu.rs
  • core/embed/rust/src/ui/component/timeout.rs
  • core/embed/rust/src/io.rs
  • core/embed/rust/src/micropython/obj.rs
  • core/embed/rust/src/smp/crc16.rs
  • core/embed/rust/src/ui/display/color.rs
  • core/embed/rust/src/ui/layout_caesar/component/flow_pages.rs
  • core/embed/rust/src/ui/layout_delizia/component/homescreen.rs
  • core/embed/rust/src/ui/layout_delizia/component/share_words.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/keyboard/passphrase.rs
  • core/embed/rust/src/ui/layout_bolt/component/button.rs
  • core/embed/rust/src/ui/layout_delizia/bootloader/mod.rs
  • core/embed/rust/src/ui/layout_eckhart/theme/gradient.rs
  • core/embed/rust/src/smp/base64.rs
  • core/embed/rust/src/trezorhal/ble/mod.rs
  • core/embed/rust/src/ui/layout_delizia/component/frame.rs
  • core/embed/rust/src/ui/shape/canvas/common.rs
  • core/embed/rust/src/ui/lerp.rs
  • core/embed/rust/src/ui/layout_bolt/component/confirm_pairing.rs
  • core/embed/rust/src/ui/layout_delizia/flow/request_number.rs
  • core/embed/rust/src/ui/layout_bolt/component/loader.rs
  • core/embed/rust/src/ui/display/font.rs
  • core/embed/rust/src/ui/layout_bolt/component/page.rs
  • core/embed/rust/src/crypto/crc32.rs
  • core/embed/rust/src/ui/component/swipe.rs
  • core/embed/rust/src/ui/layout_caesar/component/loader.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/brightness_screen.rs
  • core/embed/rust/src/ui/layout_delizia/component/swipe_content.rs
  • core/embed/rust/src/ui/layout_eckhart/firmware/text_screen.rs
  • core/embed/rust/src/ui/shape/utils/blur.rs
  • core/embed/rust/src/ui/layout_delizia/component/progress.rs
  • core/embed/rust/src/ui/component/swipe_detect.rs
  • core/embed/rust/src/ui/layout_eckhart/cshape/loader.rs
  • core/embed/rust/src/smp/mod.rs
  • core/embed/rust/src/ui/layout_bolt/component/number_input_slider.rs

Comment thread core/embed/rust/src/ui/shape/canvas/rgba8888.rs
@romanz

romanz commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

It seems that we weren't using lerp for 32-bit integers >1 year ago (tested on core/v2.8.9).

@romanz
romanz merged commit 825bd82 into main Jul 15, 2026
110 checks passed
@romanz
romanz deleted the romanz/2604/clippy-cast branch July 15, 2026 08:25
@trezor-bot trezor-bot Bot moved this from 🔎 Needs review to ✅ Done (no QA) in Firmware Jul 15, 2026
@mmilata

mmilata commented Jul 15, 2026

Copy link
Copy Markdown
Member

Side note: I was wondering if there are named lossy conversions for u32->f32 and i32->f32 and the answer seems to be no:

In the future, if we need Lerp for u32/i32 for some reason, separate impls using as would be a solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-QA On PR-merge, automatically transition status in the "Firmware" project to "Done (no QA)" state.

Projects

Status: ✅ Done (no QA)

Development

Successfully merging this pull request may close these issues.

2 participants