refactor(ironrdp-web): fix indexing_slicing clippy lint warnings#993
refactor(ironrdp-web): fix indexing_slicing clippy lint warnings#993RRRadicalEdward wants to merge 5 commits intomasterfrom
indexing_slicing clippy lint warnings#993Conversation
Coverage Report 🤖 ⚙️Past: New: Diff: +0.00% [this comment will be updated automatically] |
|
@CBenoit Does it look good? Should we proceed with adding this lint? |
|
I want to double check a little bit more before merging this. |
|
I’m putting back this PR on my TODO review list. |
Hi @CBenoit. Did you have a chance to double-check this PR? |
|
Sorry I actually forgot about it despite the TODO I wrote 😨 |
I just remembered about this PR yesterday. We have a mental connect 😄 |
There was a problem hiding this comment.
Pull request overview
This PR refactors the ironrdp-web crate to eliminate indexing_slicing clippy lint warnings by replacing direct slice indexing operations with safer alternatives that return Result or Option. The changes make the code more panic-resistant by ensuring all slice accesses are bounds-checked at runtime with proper error handling.
Changes:
- Converted slice indexing operations to use
.get()and.get_mut()methods with appropriate error handling - Updated function signatures to return
Resulttypes where slice access could fail - Replaced array indexing in pixel processing with
first_chunk()method
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| crates/ironrdp-web/src/image.rs | Modified extract_partial_image, extract_smallest_rectangle, and extract_whole_rows to return Result and use .get() for slice access with contextual error messages |
| crates/ironrdp-web/src/session.rs | Updated to propagate errors from extract_partial_image using the ? operator |
| crates/ironrdp-web/src/canvas.rs | Replaced direct indexing with first_chunk::<3>() for extracting RGB values from 4-byte pixel chunks |
| Cargo.toml | Added TODO comment noting intention to enable indexing_slicing lint project-wide |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
5b51f36 to
be67bdc
Compare
This lint
This one is quite pedantic and changes the way we write the code, but on the other hand, it makes the code more panic-resistant. Fixed the lint warnings only for ironrdp-web to see early feedback on it.

If we agree on adding it, I will add this lint for each crate separately, because there are too many warnings to do in 1 PR: