From 58be59529d15342cac991c3350fd409f0de5ca7c Mon Sep 17 00:00:00 2001 From: Martin Milata Date: Mon, 17 Apr 2023 15:33:46 +0200 Subject: [PATCH] style(core): fix clippy lints [no changelog] --- core/embed/rust/src/micropython/ffi.rs | 1 + core/embed/rust/src/ui/component/marquee.rs | 2 +- core/embed/rust/src/ui/component/text/layout.rs | 4 ++-- core/embed/rust/src/ui/component/text/paragraphs.rs | 4 ++-- core/embed/rust/src/ui/display/loader/circular.rs | 2 +- core/embed/rust/src/ui/display/mod.rs | 9 ++++----- core/embed/rust/src/ui/display/tjpgd.rs | 10 +++++----- .../src/ui/model_tt/component/homescreen/render.rs | 6 +++--- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/core/embed/rust/src/micropython/ffi.rs b/core/embed/rust/src/micropython/ffi.rs index d268afd305..245a5fa898 100644 --- a/core/embed/rust/src/micropython/ffi.rs +++ b/core/embed/rust/src/micropython/ffi.rs @@ -1,5 +1,6 @@ #![allow(non_camel_case_types)] #![allow(non_upper_case_globals)] #![allow(dead_code)] +#![allow(clippy::unnecessary_cast)] include!(concat!(env!("OUT_DIR"), "/micropython.rs")); diff --git a/core/embed/rust/src/ui/component/marquee.rs b/core/embed/rust/src/ui/component/marquee.rs index d3559521d0..072fa3a597 100644 --- a/core/embed/rust/src/ui/component/marquee.rs +++ b/core/embed/rust/src/ui/component/marquee.rs @@ -218,7 +218,7 @@ where _ => { let progress = self.progress(now); if let Some(done) = progress { - self.paint_anim(done as i16); + self.paint_anim(done); } else { self.paint_anim(0); } diff --git a/core/embed/rust/src/ui/component/text/layout.rs b/core/embed/rust/src/ui/component/text/layout.rs index 071ede1548..dadcc13d7b 100644 --- a/core/embed/rust/src/ui/component/text/layout.rs +++ b/core/embed/rust/src/ui/component/text/layout.rs @@ -175,9 +175,9 @@ impl TextLayout { self.layout_text(text, &mut self.initial_cursor(), &mut TextRenderer); } - pub fn layout_ops<'o>( + pub fn layout_ops( mut self, - ops: &mut dyn Iterator>, + ops: &mut dyn Iterator>, cursor: &mut Point, sink: &mut dyn LayoutSink, ) -> LayoutFit { diff --git a/core/embed/rust/src/ui/component/text/paragraphs.rs b/core/embed/rust/src/ui/component/text/paragraphs.rs index a906cf4e84..117210739c 100644 --- a/core/embed/rust/src/ui/component/text/paragraphs.rs +++ b/core/embed/rust/src/ui/component/text/paragraphs.rs @@ -149,11 +149,11 @@ where /// Iterate over visible layouts (bounding box, style) together /// with corresponding string content. Should not get monomorphized. - fn foreach_visible<'a, 'b, S: ParagraphStrType>( + fn foreach_visible<'a, S: ParagraphStrType>( source: &'a dyn ParagraphSource, visible: &'a [TextLayout], offset: PageOffset, - func: &'b mut dyn FnMut(&TextLayout, &str), + func: &mut dyn FnMut(&TextLayout, &str), ) { let mut vis_iter = visible.iter(); let mut chr = offset.chr; diff --git a/core/embed/rust/src/ui/display/loader/circular.rs b/core/embed/rust/src/ui/display/loader/circular.rs index a9387df1aa..f547433dd4 100644 --- a/core/embed/rust/src/ui/display/loader/circular.rs +++ b/core/embed/rust/src/ui/display/loader/circular.rs @@ -321,7 +321,7 @@ pub fn loader_rust( icon: Option<(&[u8], Color, Offset)>, ) { let center = screen().center() + Offset::new(0, y_offset); - let r = Rect::from_center_and_size(center, Offset::uniform(LOADER_OUTER as i16 * 2)); + let r = Rect::from_center_and_size(center, Offset::uniform(LOADER_OUTER * 2)); let clamped = r.clamp(constant::screen()); display::set_window(clamped); diff --git a/core/embed/rust/src/ui/display/mod.rs b/core/embed/rust/src/ui/display/mod.rs index f8dcc2ac91..a61c38ff25 100644 --- a/core/embed/rust/src/ui/display/mod.rs +++ b/core/embed/rust/src/ui/display/mod.rs @@ -359,9 +359,8 @@ pub(crate) fn position_buffer( } else { 0 }; - dest_buffer[((start * buffer_bpp) / 8)..((start + width) * buffer_bpp) / 8].copy_from_slice( - &src_buffer[((x_sh * buffer_bpp) / 8) as usize..((x_sh as usize + width) * buffer_bpp) / 8], - ); + dest_buffer[((start * buffer_bpp) / 8)..((start + width) * buffer_bpp) / 8] + .copy_from_slice(&src_buffer[((x_sh * buffer_bpp) / 8)..((x_sh + width) * buffer_bpp) / 8]); } /// Performs decompression of one line of pixels, @@ -1031,11 +1030,11 @@ impl Font { } pub fn max_height(self) -> i16 { - display::text_max_height(self.into()) as i16 + display::text_max_height(self.into()) } pub fn baseline(self) -> i16 { - display::text_baseline(self.into()) as i16 + display::text_baseline(self.into()) } pub fn line_height(self) -> i16 { diff --git a/core/embed/rust/src/ui/display/tjpgd.rs b/core/embed/rust/src/ui/display/tjpgd.rs index 1edaf664f4..bfb84e3496 100644 --- a/core/embed/rust/src/ui/display/tjpgd.rs +++ b/core/embed/rust/src/ui/display/tjpgd.rs @@ -301,7 +301,7 @@ impl<'i, 'p> JDEC<'i, 'p> { if cls == 0 && d > 11 { return Err(Error::InvalidData); } - self.huffdata[num][cls][i as usize] = d; + self.huffdata[num][cls][i] = d; } if JD_FASTDECODE == 2 { // Create fast huffman decode table @@ -326,8 +326,8 @@ impl<'i, 'p> JDEC<'i, 'p> { j = self.huffbits[num][cls][b as usize] as u32; while j != 0 { // Index of input pattern for the code - ti = (self.huffcode[num][cls][i] << (((HUFF_BIT - 1) as u32) - b)) as u32 - & HUFF_MASK; + ti = + (self.huffcode[num][cls][i] << ((HUFF_BIT - 1) - b)) as u32 & HUFF_MASK; if cls != 0 { // b15..b8: code length, b7..b0: zero run and data length @@ -447,7 +447,7 @@ impl<'i, 'p> JDEC<'i, 'p> { hb_idx = HUFF_BIT; // Bit distribution table hc_idx = self.longofs[id][cls]; // Code word table hd_idx = self.longofs[id][cls]; // Data table - bl = (HUFF_BIT + 1) as u32; + bl = HUFF_BIT + 1; } else { // Incremental search for all codes bl = 1; @@ -805,7 +805,7 @@ impl<'i, 'p> JDEC<'i, 'p> { // If no AC element or scale ratio is 1/8, IDCT can be omitted and the block is // filled with DC value if z == 1 || JD_USE_SCALE != 0 && self.scale == 3 { - d = (self.workbuf[0] / 256 + 128) as i32; + d = self.workbuf[0] / 256 + 128; if JD_FASTDECODE >= 1 { for i in 0..64 { self.mcubuf[mcu_buf_idx + i] = d as i16; diff --git a/core/embed/rust/src/ui/model_tt/component/homescreen/render.rs b/core/embed/rust/src/ui/model_tt/component/homescreen/render.rs index d898c2c3ea..d0540ed68f 100644 --- a/core/embed/rust/src/ui/model_tt/component/homescreen/render.rs +++ b/core/embed/rust/src/ui/model_tt/component/homescreen/render.rs @@ -463,7 +463,7 @@ impl BlurringContext { let data = get_data(buffer, self.line_num, mcu_height); for i in -BLUR_RADIUS..=BLUR_RADIUS { - let ic = i.clamp(0, HOMESCREEN_IMAGE_WIDTH as i16 - 1) as usize; + let ic = i.clamp(0, HOMESCREEN_IMAGE_WIDTH - 1) as usize; update_accs_add(data, ic, &mut acc_r, &mut acc_g, &mut acc_b); } @@ -473,9 +473,9 @@ impl BlurringContext { self.lines[self.add_idx][BLUE_IDX][i as usize] = acc_b; // clamping handles left and right edges - let ic = (i - BLUR_RADIUS).clamp(0, HOMESCREEN_IMAGE_WIDTH as i16 - 1) as usize; + let ic = (i - BLUR_RADIUS).clamp(0, HOMESCREEN_IMAGE_WIDTH - 1) as usize; let ic2 = (i + BLUR_SIZE as i16 - BLUR_RADIUS) - .clamp(0, HOMESCREEN_IMAGE_WIDTH as i16 - 1) as usize; + .clamp(0, HOMESCREEN_IMAGE_WIDTH - 1) as usize; update_accs_add(data, ic2, &mut acc_r, &mut acc_g, &mut acc_b); update_accs_sub(data, ic, &mut acc_r, &mut acc_g, &mut acc_b); }