From f96b1b2ce82215ec6969f17477cfdd0bd10ee8e9 Mon Sep 17 00:00:00 2001 From: Alex Yusiuk <55661041+RRRadicalEdward@users.noreply.github.com> Date: Wed, 23 Jul 2025 11:55:40 +0300 Subject: [PATCH] refactor: add `allow_attributes` clippy to "Extra-pedantic clippy" section (#880) --- Cargo.toml | 1 + crates/ironrdp-acceptor/src/connection.rs | 2 +- crates/ironrdp-cliprdr-format/src/bitmap.rs | 16 ++++++++-------- crates/ironrdp-cliprdr-format/src/html.rs | 4 ++-- .../src/windows/clipboard_impl.rs | 4 ++-- .../src/windows/os_clipboard.rs | 6 +++--- crates/ironrdp-connector/src/connection.rs | 2 +- crates/ironrdp-displaycontrol/src/pdu/mod.rs | 8 ++++---- .../ironrdp-dvc-pipe-proxy/src/windows/event.rs | 2 +- .../src/windows/semaphore.rs | 2 +- crates/ironrdp-graphics/src/color_conversion.rs | 2 +- crates/ironrdp-graphics/src/diff.rs | 2 +- crates/ironrdp-input/src/lib.rs | 2 +- crates/ironrdp-pdu/src/ber.rs | 5 ++--- crates/ironrdp-pdu/src/macros.rs | 2 +- crates/ironrdp-rdpdr-native/src/nix/backend.rs | 14 +++++++++----- crates/ironrdp-rdpdr/src/pdu/efs.rs | 2 +- crates/ironrdp-rdpsnd-native/src/cpal.rs | 2 +- crates/ironrdp-server/src/builder.rs | 2 +- crates/ironrdp-server/src/encoder/fast_path.rs | 4 ++++ crates/ironrdp-server/src/handler.rs | 4 ++-- crates/ironrdp-session/src/image.rs | 8 +++----- crates/ironrdp-svc/src/lib.rs | 1 - .../tests/graphics/rlgr.rs | 10 ---------- crates/ironrdp-web/src/clipboard.rs | 2 +- crates/ironrdp-web/src/session.rs | 8 ++++---- crates/ironrdp/examples/server.rs | 2 +- xtask/src/cov.rs | 4 ++-- 28 files changed, 59 insertions(+), 64 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 095f6594..08a83063 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -124,6 +124,7 @@ string_lit_chars_any = "warn" unnecessary_box_returns = "warn" # == Extra-pedantic clippy == # +allow_attributes = "warn" collection_is_never_read = "warn" copy_iterator = "warn" expl_impl_clone_on_copy = "warn" diff --git a/crates/ironrdp-acceptor/src/connection.rs b/crates/ironrdp-acceptor/src/connection.rs index 0101e731..9a2ed37f 100644 --- a/crates/ironrdp-acceptor/src/connection.rs +++ b/crates/ironrdp-acceptor/src/connection.rs @@ -404,7 +404,7 @@ impl Sequence for Acceptor { }) .unwrap_or_default(); - #[allow(clippy::arithmetic_side_effects)] // IO channel ID is not big enough for overflowing. + #[expect(clippy::arithmetic_side_effects)] // IO channel ID is not big enough for overflowing. let channels = joined .into_iter() .enumerate() diff --git a/crates/ironrdp-cliprdr-format/src/bitmap.rs b/crates/ironrdp-cliprdr-format/src/bitmap.rs index f8d1666a..590ed98f 100644 --- a/crates/ironrdp-cliprdr-format/src/bitmap.rs +++ b/crates/ironrdp-cliprdr-format/src/bitmap.rs @@ -32,7 +32,7 @@ pub enum BitmapError { #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] struct BitmapCompression(u32); -#[allow(dead_code)] +#[expect(dead_code)] impl BitmapCompression { const RGB: Self = Self(0x0000); const RLE8: Self = Self(0x0001); @@ -48,7 +48,7 @@ impl BitmapCompression { #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] struct ColorSpace(u32); -#[allow(dead_code)] +#[expect(dead_code)] impl ColorSpace { const CALIBRATED_RGB: Self = Self(0x00000000); const SRGB: Self = Self(0x73524742); @@ -60,7 +60,7 @@ impl ColorSpace { #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] struct BitmapIntent(u32); -#[allow(dead_code)] +#[expect(dead_code)] impl BitmapIntent { const LCS_GM_ABS_COLORIMETRIC: Self = Self(0x00000008); const LCS_GM_BUSINESS: Self = Self(0x00000001); @@ -499,7 +499,7 @@ fn rgb_bmp_stride(width: u16, bit_count: u16) -> usize { debug_assert!(bit_count <= 32); // No side effects, because u16::MAX * 32 + 31 < u16::MAX * u16::MAX < u32::MAX - #[allow(clippy::arithmetic_side_effects)] + #[expect(clippy::arithmetic_side_effects)] { (((usize::from(width) * usize::from(bit_count)) + 31) & !31) >> 3 } @@ -527,7 +527,7 @@ fn bgra_to_top_down_rgba( }; // Per invariants: height * width * dst_n_samples <= 10_000 * 10_000 * 4 < u32::MAX - #[allow(clippy::arithmetic_side_effects)] + #[expect(clippy::arithmetic_side_effects)] let dst_bitmap_len = usize::from(height) * usize::from(width) * dst_n_samples; // Prevent allocation of huge buffers. @@ -569,7 +569,7 @@ fn bgra_to_top_down_rgba( }; // Per invariants: width * dst_n_samples <= 10_000 * 4 < u32::MAX - #[allow(clippy::arithmetic_side_effects)] + #[expect(clippy::arithmetic_side_effects)] let dst_stride = usize::from(width) * dst_n_samples; let mut dst_bitmap = vec![0u8; dst_bitmap_len]; @@ -647,13 +647,13 @@ fn top_down_rgba_to_bottom_up_bgra( let width = u16::try_from(info.width).map_err(|_| BitmapError::WidthTooBig)?; let height = u16::try_from(info.height).map_err(|_| BitmapError::HeightTooBig)?; - #[allow(clippy::arithmetic_side_effects)] // width * 4 <= 10_000 * 4 < u32::MAX + #[expect(clippy::arithmetic_side_effects)] // width * 4 <= 10_000 * 4 < u32::MAX let stride = usize::from(width) * 4; let src_rows = src_bitmap.chunks_exact(stride); // As per invariants: stride * height <= width * 4 * height <= 10_000 * 4 * 10_000 <= u32::MAX. - #[allow(clippy::arithmetic_side_effects)] + #[expect(clippy::arithmetic_side_effects)] let dst_len = stride * usize::from(height); let dst_len = u32::try_from(dst_len).map_err(|_| BitmapError::InvalidSize)?; diff --git a/crates/ironrdp-cliprdr-format/src/html.rs b/crates/ironrdp-cliprdr-format/src/html.rs index 585948b4..05c89e3b 100644 --- a/crates/ironrdp-cliprdr-format/src/html.rs +++ b/crates/ironrdp-cliprdr-format/src/html.rs @@ -97,7 +97,7 @@ pub fn plain_html_to_cf_html(fragment: &str) -> String { let mut write_header = |key: &str, value: &str| { // This relation holds: key.len() + value.len() + ":\r\n".len() < usize::MAX // Rationale: we know all possible values (see code below), and they are much smaller than `usize::MAX`. - #[allow(clippy::arithmetic_side_effects)] + #[expect(clippy::arithmetic_side_effects)] let size = key.len() + value.len() + ":\r\n".len(); buffer.reserve(size); @@ -136,7 +136,7 @@ pub fn plain_html_to_cf_html(fragment: &str) -> String { let mut replace_placeholder = |value_begin_idx: usize, header_value: &str| { // We know that: value_begin_idx + POS_PLACEHOLDER.len() < usize::MAX // Rationale: the headers are written at the beginning, and we’re not indexing outside of the string. - #[allow(clippy::arithmetic_side_effects)] + #[expect(clippy::arithmetic_side_effects)] let value_end_idx = value_begin_idx + POS_PLACEHOLDER.len(); buffer.replace_range(value_begin_idx..value_end_idx, header_value); diff --git a/crates/ironrdp-cliprdr-native/src/windows/clipboard_impl.rs b/crates/ironrdp-cliprdr-native/src/windows/clipboard_impl.rs index 2025783c..ba1dba7e 100644 --- a/crates/ironrdp-cliprdr-native/src/windows/clipboard_impl.rs +++ b/crates/ironrdp-cliprdr-native/src/windows/clipboard_impl.rs @@ -261,7 +261,7 @@ impl WinClipboardImpl { const MAX_PROCESSING_ATTEMPTS: u32 = 10; const PROCESSING_TIMEOUT_MS: u32 = 100; - #[allow(clippy::arithmetic_side_effects)] + #[expect(clippy::arithmetic_side_effects)] // self.attempt can’t be greater than MAX_PROCESSING_ATTEMPTS, so the arithmetic is safe here if self.attempt < MAX_PROCESSING_ATTEMPTS { self.attempt += 1; @@ -347,7 +347,7 @@ pub(crate) unsafe extern "system" fn clipboard_subproc( } // Sent by the OS when delay-rendered data is requested for rendering. WM_RENDERFORMAT => { - #[allow(clippy::cast_possible_truncation)] // should never truncate in practice + #[expect(clippy::cast_possible_truncation)] // should never truncate in practice ctx.handle_event(BackendEvent::RenderFormat(ClipboardFormatId::new(wparam.0 as u32))); } // Sent by the OS when all delay-rendered data is requested for rendering. diff --git a/crates/ironrdp-cliprdr-native/src/windows/os_clipboard.rs b/crates/ironrdp-cliprdr-native/src/windows/os_clipboard.rs index 54ccaa14..6ea407aa 100644 --- a/crates/ironrdp-cliprdr-native/src/windows/os_clipboard.rs +++ b/crates/ironrdp-cliprdr-native/src/windows/os_clipboard.rs @@ -19,7 +19,7 @@ impl OwnedOsClipboard { } /// Enumerates all available formats in the current clipboard. - #[allow(clippy::unused_self)] // ensure we own the clipboard using RAII, and exclusive &mut self reference + #[expect(clippy::unused_self)] // ensure we own the clipboard using RAII, and exclusive &mut self reference pub(crate) fn enum_available_formats(&mut self) -> Result, WinCliprdrError> { const DEFAULT_FORMATS_CAPACITY: usize = 16; // Sane default for format name. If format name is longer than this, @@ -74,7 +74,7 @@ impl OwnedOsClipboard { /// Empties the clipboard /// /// It is required to empty clipboard before setting any delay-rendered data. - #[allow(clippy::unused_self)] // ensure we own the clipboard using RAII, and exclusive &mut self reference + #[expect(clippy::unused_self)] // ensure we own the clipboard using RAII, and exclusive &mut self reference pub(crate) fn clear(&mut self) -> Result<(), WinCliprdrError> { // SAFETY: We own the clipboard at moment of method invocation, therefore it is safe to // call `EmptyClipboard`. @@ -83,7 +83,7 @@ impl OwnedOsClipboard { Ok(()) } - #[allow(clippy::unused_self)] // ensure we own the clipboard using RAII, and exclusive &mut self reference + #[expect(clippy::unused_self)] // ensure we own the clipboard using RAII, and exclusive &mut self reference pub(crate) fn delay_render(&mut self, format: ClipboardFormatId) -> Result<(), WinCliprdrError> { // SAFETY: We own the clipboard at moment of method invocation, therefore it is safe to // call `SetClipboardData`. diff --git a/crates/ironrdp-connector/src/connection.rs b/crates/ironrdp-connector/src/connection.rs index 85693d3c..f8ebba77 100644 --- a/crates/ironrdp-connector/src/connection.rs +++ b/crates/ironrdp-connector/src/connection.rs @@ -600,7 +600,7 @@ pub fn encode_send_data_request( Ok(written) } -#[allow(single_use_lifetimes)] // anonymous lifetimes in `impl Trait` are unstable +#[expect(single_use_lifetimes)] // anonymous lifetimes in `impl Trait` are unstable fn create_gcc_blocks<'a>( config: &Config, selected_protocol: nego::SecurityProtocol, diff --git a/crates/ironrdp-displaycontrol/src/pdu/mod.rs b/crates/ironrdp-displaycontrol/src/pdu/mod.rs index a3e4c4de..6d7fab01 100644 --- a/crates/ironrdp-displaycontrol/src/pdu/mod.rs +++ b/crates/ironrdp-displaycontrol/src/pdu/mod.rs @@ -44,7 +44,7 @@ impl Encode for DisplayControlPdu { }; // This will never overflow as per invariants. - #[allow(clippy::arithmetic_side_effects)] + #[expect(clippy::arithmetic_side_effects)] let pdu_size = payload_length + Self::FIXED_PART_SIZE; // Write `DISPLAYCONTROL_HEADER` fields. @@ -65,7 +65,7 @@ impl Encode for DisplayControlPdu { fn size(&self) -> usize { // As per invariants: This will never overflow. - #[allow(clippy::arithmetic_side_effects)] + #[expect(clippy::arithmetic_side_effects)] let size = Self::FIXED_PART_SIZE + match self { DisplayControlPdu::Caps(caps) => caps.size(), @@ -310,7 +310,7 @@ impl Encode for DisplayControlMonitorLayout { fn size(&self) -> usize { // As per invariants: This will never overflow: // 0 <= Self::FIXED_PART_SIZE + MAX_SUPPORTED_MONITORS * MonitorLayoutEntry::FIXED_PART_SIZE < u16::MAX - #[allow(clippy::arithmetic_side_effects)] + #[expect(clippy::arithmetic_side_effects)] let size = Self::FIXED_PART_SIZE + self.monitors.iter().map(|monitor| monitor.size()).sum::(); size @@ -751,6 +751,6 @@ fn calculate_monitor_area( // As per invariants: This multiplication would never overflow. // 0 <= MAX_MONITOR_AREA_FACTOR * MAX_MONITOR_AREA_FACTOR * MAX_SUPPORTED_MONITORS <= u64::MAX - #[allow(clippy::arithmetic_side_effects)] + #[expect(clippy::arithmetic_side_effects)] Ok(u64::from(max_monitor_area_factor_a) * u64::from(max_monitor_area_factor_b) * u64::from(max_num_monitors)) } diff --git a/crates/ironrdp-dvc-pipe-proxy/src/windows/event.rs b/crates/ironrdp-dvc-pipe-proxy/src/windows/event.rs index 6629db25..d0421df5 100644 --- a/crates/ironrdp-dvc-pipe-proxy/src/windows/event.rs +++ b/crates/ironrdp-dvc-pipe-proxy/src/windows/event.rs @@ -30,7 +30,7 @@ impl Event { // CreateEventW returns a valid handle on success. Ok(Self { // See `unsafe impl Send` comment. - #[allow(clippy::arc_with_non_send_sync)] + #[expect(clippy::arc_with_non_send_sync)] handle: Arc::new(handle), }) } diff --git a/crates/ironrdp-dvc-pipe-proxy/src/windows/semaphore.rs b/crates/ironrdp-dvc-pipe-proxy/src/windows/semaphore.rs index 3e3ad053..2b8d6fdd 100644 --- a/crates/ironrdp-dvc-pipe-proxy/src/windows/semaphore.rs +++ b/crates/ironrdp-dvc-pipe-proxy/src/windows/semaphore.rs @@ -55,7 +55,7 @@ impl Semaphore { Ok(Self { // See `unsafe impl Send` comment. // TODO(@CBenoit): Verify this comment. - #[allow(clippy::arc_with_non_send_sync)] + #[expect(clippy::arc_with_non_send_sync)] handle: Arc::new(handle), }) } diff --git a/crates/ironrdp-graphics/src/color_conversion.rs b/crates/ironrdp-graphics/src/color_conversion.rs index 5b6d1902..7ce4c829 100644 --- a/crates/ironrdp-graphics/src/color_conversion.rs +++ b/crates/ironrdp-graphics/src/color_conversion.rs @@ -40,7 +40,7 @@ pub fn ycbcr_to_rgba(input: YCbCrBuffer<'_>, output: &mut [u8]) -> io::Result<() rdp_yuv444_to_rgba(&planar, output, len).map_err(io::Error::other) } -#[allow(clippy::too_many_arguments)] +#[expect(clippy::too_many_arguments)] pub fn to_64x64_ycbcr_tile( input: &[u8], width: usize, diff --git a/crates/ironrdp-graphics/src/diff.rs b/crates/ironrdp-graphics/src/diff.rs index 5de90728..1a45c48b 100644 --- a/crates/ironrdp-graphics/src/diff.rs +++ b/crates/ironrdp-graphics/src/diff.rs @@ -184,7 +184,7 @@ fn find_different_rects( /// │ │ /// └───────────────────────────────────────────┘ /// ``` -#[allow(clippy::too_many_arguments)] +#[expect(clippy::too_many_arguments)] pub fn find_different_rects_sub( image1: &[u8], stride1: usize, diff --git a/crates/ironrdp-input/src/lib.rs b/crates/ironrdp-input/src/lib.rs index b476b78b..628aa98c 100644 --- a/crates/ironrdp-input/src/lib.rs +++ b/crates/ironrdp-input/src/lib.rs @@ -78,7 +78,7 @@ impl Scancode { pub const fn from_u16(scancode: u16) -> Self { let extended = scancode & 0xE000 == 0xE000; - #[allow(clippy::cast_possible_truncation)] // truncating on purpose + #[expect(clippy::cast_possible_truncation)] // truncating on purpose let code = scancode as u8; Self { code, extended } diff --git a/crates/ironrdp-pdu/src/ber.rs b/crates/ironrdp-pdu/src/ber.rs index 0012acb6..b01b49ab 100644 --- a/crates/ironrdp-pdu/src/ber.rs +++ b/crates/ironrdp-pdu/src/ber.rs @@ -3,14 +3,13 @@ use ironrdp_core::{cast_length, ensure_size, invalid_field_err, ReadCursor, Writ use crate::{DecodeResult, EncodeResult}; #[repr(u8)] -#[allow(unused)] pub(crate) enum Pc { Primitive = 0x00, Construct = 0x20, } #[repr(u8)] -#[allow(unused)] +#[expect(unused)] enum Class { Universal = 0x00, Application = 0x40, @@ -19,7 +18,7 @@ enum Class { } #[repr(u8)] -#[allow(unused)] +#[expect(unused)] enum Tag { Mask = 0x1F, Boolean = 0x01, diff --git a/crates/ironrdp-pdu/src/macros.rs b/crates/ironrdp-pdu/src/macros.rs index 36e45f8d..2bbfda73 100644 --- a/crates/ironrdp-pdu/src/macros.rs +++ b/crates/ironrdp-pdu/src/macros.rs @@ -139,7 +139,7 @@ macro_rules! try_write_optional { if let Some(ref val) = $val { // This is a workaround for clippy false positive because // of macro expansion. - #[allow(clippy::redundant_closure_call)] + #[expect(clippy::redundant_closure_call)] $f(val)? } else { return Ok(()); diff --git a/crates/ironrdp-rdpdr-native/src/nix/backend.rs b/crates/ironrdp-rdpdr-native/src/nix/backend.rs index b5a1d75b..6bce80a8 100644 --- a/crates/ironrdp-rdpdr-native/src/nix/backend.rs +++ b/crates/ironrdp-rdpdr-native/src/nix/backend.rs @@ -186,7 +186,7 @@ pub(crate) fn query_information( .unwrap_or_default(); let name_index = match path.rfind('/') { // in fact, index only needs to be different for existing requests - #[allow(clippy::arithmetic_side_effects)] + #[expect(clippy::arithmetic_side_effects)] Some(index) => index + 1, None => 0, }; @@ -312,6 +312,10 @@ pub(crate) fn query_volume_information( // blocks_available() may have different integer type on different platforms. // so we need to cast it to u32 uniformly. so if it is u32, it will emit 'useless conversion' // warning, i choose to mute it. + #[expect( + clippy::allow_attributes, + reason = "we have to use allow as the useless_conversion isn't triggered on some platforms" + )] #[allow(clippy::useless_conversion)] volume_serial_number: u32::try_from(statvfs.blocks_available()).unwrap(), supports_objects: Boolean::False, @@ -446,7 +450,7 @@ pub(crate) fn set_information( } // in fact, it is time in secs which is very small -#[allow(clippy::arithmetic_side_effects)] +#[expect(clippy::arithmetic_side_effects)] pub(crate) fn transform_to_filetime(time_in_secs: i64) -> i64 { let mut time = time_in_secs * 10000000; time += 116444736000000000; @@ -491,7 +495,7 @@ pub(crate) fn make_query_dir_resp( ))]), Some(file_full_path) => { // in fact, it represents file name, so it is not very large - #[allow(clippy::arithmetic_side_effects)] + #[expect(clippy::arithmetic_side_effects)] let file_last_slash = if let Some(index) = file_full_path.rfind('/') { index + 1 } else { @@ -555,7 +559,7 @@ pub(crate) fn query_directory( let query_path = req_inner.path.replace('\\', "/"); let len = query_path.len(); // path ends with *, so its len > 0 - #[allow(clippy::arithmetic_side_effects)] + #[expect(clippy::arithmetic_side_effects)] parent.push_str(&query_path[0..len - 1]); if let Ok(dirp) = Dir::open( parent.as_str(), @@ -643,7 +647,7 @@ fn make_create_drive_resp( Ok(vec![SvcMessage::from(res)]) } // in fact, index only needs to be different, so it is ok -#[allow(clippy::arithmetic_side_effects)] +#[expect(clippy::arithmetic_side_effects)] pub(crate) fn create_drive( backend: &mut NixRdpdrBackend, req_inner: DeviceCreateRequest, diff --git a/crates/ironrdp-rdpdr/src/pdu/efs.rs b/crates/ironrdp-rdpdr/src/pdu/efs.rs index 7260e508..4b94237a 100644 --- a/crates/ironrdp-rdpdr/src/pdu/efs.rs +++ b/crates/ironrdp-rdpdr/src/pdu/efs.rs @@ -593,7 +593,7 @@ struct GeneralCapabilitySet { } impl GeneralCapabilitySet { - #[allow(clippy::manual_bits)] + #[expect(clippy::manual_bits)] const SIZE: usize = size_of::() * 8 + size_of::() * 2; fn encode(&self, dst: &mut WriteCursor<'_>) -> EncodeResult<()> { diff --git a/crates/ironrdp-rdpsnd-native/src/cpal.rs b/crates/ironrdp-rdpsnd-native/src/cpal.rs index 3a3fc208..7c9a8ee8 100644 --- a/crates/ironrdp-rdpsnd-native/src/cpal.rs +++ b/crates/ironrdp-rdpsnd-native/src/cpal.rs @@ -243,7 +243,7 @@ impl RxBuffer { return; }; - #[allow(clippy::arithmetic_side_effects)] + #[expect(clippy::arithmetic_side_effects)] while self.idx < last.len() && filled < data.len() { data[filled] = last[self.idx]; assert!(filled < usize::MAX); diff --git a/crates/ironrdp-server/src/builder.rs b/crates/ironrdp-server/src/builder.rs index 876f95ab..d31aedba 100644 --- a/crates/ironrdp-server/src/builder.rs +++ b/crates/ironrdp-server/src/builder.rs @@ -49,7 +49,7 @@ impl Default for RdpServerBuilder { } impl RdpServerBuilder { - #[allow(clippy::unused_self)] // ensuring state transition from WantsAddr + #[expect(clippy::unused_self)] // ensuring state transition from WantsAddr pub fn with_addr(self, addr: impl Into) -> RdpServerBuilder { RdpServerBuilder { state: WantsSecurity { addr: addr.into() }, diff --git a/crates/ironrdp-server/src/encoder/fast_path.rs b/crates/ironrdp-server/src/encoder/fast_path.rs index c63a8ce0..d348b7e7 100644 --- a/crates/ironrdp-server/src/encoder/fast_path.rs +++ b/crates/ironrdp-server/src/encoder/fast_path.rs @@ -8,6 +8,10 @@ const MAX_FASTPATH_UPDATE_SIZE: usize = 16_374; const FASTPATH_HEADER_SIZE: usize = 6; +#[expect( + clippy::allow_attributes, + reason = "Unfortunately, expect attribute doesn't work when above or after visibility::make attribute" +)] #[allow(unreachable_pub)] #[cfg_attr(feature = "__bench", visibility::make(pub))] pub(crate) struct UpdateFragmenter { diff --git a/crates/ironrdp-server/src/handler.rs b/crates/ironrdp-server/src/handler.rs index 99a5dcc4..a1497167 100644 --- a/crates/ironrdp-server/src/handler.rs +++ b/crates/ironrdp-server/src/handler.rs @@ -97,7 +97,7 @@ impl From<(u16, fast_path::KeyboardFlags)> for KeyboardEvent { } impl From<(u16, scan_code::KeyboardFlags)> for KeyboardEvent { - #[allow(clippy::cast_possible_truncation)] // we are actually truncating the value + #[expect(clippy::cast_possible_truncation)] // we are actually truncating the value fn from((key, flags): (u16, scan_code::KeyboardFlags)) -> Self { let extended = flags.contains(scan_code::KeyboardFlags::EXTENDED); if flags.contains(scan_code::KeyboardFlags::RELEASE) { @@ -131,7 +131,7 @@ impl From for KeyboardEvent { } impl From for KeyboardEvent { - #[allow(clippy::cast_possible_truncation)] // we are actually truncating the value + #[expect(clippy::cast_possible_truncation)] // we are actually truncating the value fn from(value: SyncToggleFlags) -> Self { KeyboardEvent::Synchronize(SynchronizeFlags::from_bits_truncate(value.bits() as u8)) } diff --git a/crates/ironrdp-session/src/image.rs b/crates/ironrdp-session/src/image.rs index 9a5bed9c..138b3dfb 100644 --- a/crates/ironrdp-session/src/image.rs +++ b/crates/ironrdp-session/src/image.rs @@ -70,8 +70,8 @@ struct PointerRenderingState { update_rectangle: InclusiveRectangle, } -#[allow(clippy::too_many_arguments)] -#[allow(clippy::cast_lossless)] // FIXME +#[expect(clippy::too_many_arguments)] +#[expect(clippy::cast_lossless)] // FIXME fn copy_cursor_data( from: &[u8], from_pos: (usize, usize), @@ -311,9 +311,7 @@ impl DecodedImage { } } - #[allow(clippy::cast_lossless)] // FIXME - #[allow(clippy::cast_possible_wrap)] // FIXME - #[allow(clippy::cast_possible_truncation)] // FIXME + #[expect(clippy::cast_possible_wrap)] // FIXME fn recalculate_pointer_geometry(&mut self) { let x = self.pointer_x; let y = self.pointer_y; diff --git a/crates/ironrdp-svc/src/lib.rs b/crates/ironrdp-svc/src/lib.rs index 8f87ace4..7b5594b6 100644 --- a/crates/ironrdp-svc/src/lib.rs +++ b/crates/ironrdp-svc/src/lib.rs @@ -673,7 +673,6 @@ impl Encode for ChannelPduHeader { Self::NAME } - #[allow(clippy::arithmetic_side_effects)] fn size(&self) -> usize { Self::FIXED_PART_SIZE } diff --git a/crates/ironrdp-testsuite-core/tests/graphics/rlgr.rs b/crates/ironrdp-testsuite-core/tests/graphics/rlgr.rs index 44754d55..507808aa 100644 --- a/crates/ironrdp-testsuite-core/tests/graphics/rlgr.rs +++ b/crates/ironrdp-testsuite-core/tests/graphics/rlgr.rs @@ -47,7 +47,6 @@ fn decode_works_with_rlgr3() { #[test] fn decode_correctly_decodes_rl_without_leading_zeros_and_ones() { - #[allow(clippy::inconsistent_digit_grouping)] let input = [0b1100_0000]; let expected = [0, 1]; let mode = EntropyAlgorithm::Rlgr3; @@ -59,7 +58,6 @@ fn decode_correctly_decodes_rl_without_leading_zeros_and_ones() { #[test] fn decode_correctly_decodes_rl_with_not_null_sign_bit() { - #[allow(clippy::inconsistent_digit_grouping)] let input = [0b1110_0000]; let expected = [0, -1]; let mode = EntropyAlgorithm::Rlgr3; @@ -71,7 +69,6 @@ fn decode_correctly_decodes_rl_with_not_null_sign_bit() { #[test] fn decode_correctly_decodes_rl_with_leading_zeros() { - #[allow(clippy::inconsistent_digit_grouping, clippy::unreadable_literal)] let input = [0b00000000, 0b10011001, 0b1100_0000]; let expected = [[0; 66].as_ref(), [7].as_ref()].concat(); let mode = EntropyAlgorithm::Rlgr3; @@ -83,7 +80,6 @@ fn decode_correctly_decodes_rl_with_leading_zeros() { #[test] fn encode_correctly_encodes_rl_with_leading_zeros() { - #[allow(clippy::inconsistent_digit_grouping, clippy::unreadable_literal)] let expected = [0b00000000, 0b10011001, 0b1100_0000]; let input = [[0; 66].as_ref(), [7].as_ref()].concat(); let mode = EntropyAlgorithm::Rlgr3; @@ -95,7 +91,6 @@ fn encode_correctly_encodes_rl_with_leading_zeros() { #[test] fn decode_correctly_decodes_rl_with_leading_ones() { - #[allow(clippy::inconsistent_digit_grouping, clippy::unreadable_literal)] let input = [0b11011111, 0b11111101]; let expected = [0, 24]; let mode = EntropyAlgorithm::Rlgr3; @@ -107,7 +102,6 @@ fn decode_correctly_decodes_rl_with_leading_ones() { #[test] fn encode_correctly_encodes_rl_with_leading_ones() { - #[allow(clippy::inconsistent_digit_grouping, clippy::unreadable_literal)] let expected = [0b11011111, 0b11111101]; let input = [0, 24]; let mode = EntropyAlgorithm::Rlgr3; @@ -119,7 +113,6 @@ fn encode_correctly_encodes_rl_with_leading_ones() { #[test] fn decode_correctly_decodes_rlgr3() { - #[allow(clippy::inconsistent_digit_grouping, clippy::unreadable_literal)] let input = [0b11000000]; let expected = [0, 1, 0, 0]; let mode = EntropyAlgorithm::Rlgr3; @@ -131,7 +124,6 @@ fn decode_correctly_decodes_rlgr3() { #[test] fn encode_correctly_encodes_rlgr3() { - #[allow(clippy::inconsistent_digit_grouping, clippy::unreadable_literal)] let expected = [0b11000000]; let input = [0, 1, 0, 0]; let mode = EntropyAlgorithm::Rlgr3; @@ -143,7 +135,6 @@ fn encode_correctly_encodes_rlgr3() { #[test] fn decode_correctly_decodes_rlgr1() { - #[allow(clippy::inconsistent_digit_grouping, clippy::unreadable_literal)] let input = [0b11000111, 0b11111000]; let expected = [0, 1, 4, 0]; let mode = EntropyAlgorithm::Rlgr1; @@ -155,7 +146,6 @@ fn decode_correctly_decodes_rlgr1() { #[test] fn encode_correctly_encodes_rlgr1() { - #[allow(clippy::inconsistent_digit_grouping, clippy::unreadable_literal)] let expected = [0b11000111, 0b11111000]; let input = [0, 1, 4, 0]; let mode = EntropyAlgorithm::Rlgr1; diff --git a/crates/ironrdp-web/src/clipboard.rs b/crates/ironrdp-web/src/clipboard.rs index 35ea669b..d259f9bf 100644 --- a/crates/ironrdp-web/src/clipboard.rs +++ b/crates/ironrdp-web/src/clipboard.rs @@ -681,7 +681,7 @@ impl iron_remote_desktop::ClipboardItem for ClipboardItem { &self.mime_type } - #[allow(refining_impl_trait)] + #[expect(refining_impl_trait)] fn value(&self) -> JsValue { match &self.value { ClipboardItemValue::Text(text) => JsValue::from_str(text), diff --git a/crates/ironrdp-web/src/session.rs b/crates/ironrdp-web/src/session.rs index dc584258..4b66f3d6 100644 --- a/crates/ironrdp-web/src/session.rs +++ b/crates/ironrdp-web/src/session.rs @@ -616,7 +616,7 @@ impl iron_remote_desktop::Session for Session { let hotspot_y = f64_to_u16_saturating_cast(f64::from(pointer.hotspot_y) * scale); // Per invariants: scaled_width * scaled_height * 4 <= 32 * 32 * 4 < usize::MAX - #[allow(clippy::arithmetic_side_effects)] + #[expect(clippy::arithmetic_side_effects)] let resized_rgba_buffer_size = usize::from(scaled_width * scaled_height * 4); let mut rgba_resized = vec![0u8; resized_rgba_buffer_size]; @@ -856,7 +856,7 @@ fn build_config( lossy_compression: true, codecs: client_codecs_capabilities(&[]).unwrap(), }), - #[allow(clippy::arithmetic_side_effects)] // fine unless we end up with an insanely big version + #[expect(clippy::arithmetic_side_effects)] // fine unless we end up with an insanely big version client_build: semver::Version::parse(env!("CARGO_PKG_VERSION")) .map(|version| version.major * 100 + version.minor * 10 + version.patch) .unwrap_or(0) @@ -1095,8 +1095,8 @@ where } } -#[allow(clippy::cast_sign_loss)] -#[allow(clippy::cast_possible_truncation)] +#[expect(clippy::cast_sign_loss)] +#[expect(clippy::cast_possible_truncation)] fn f64_to_u16_saturating_cast(value: f64) -> u16 { value as u16 } diff --git a/crates/ironrdp/examples/server.rs b/crates/ironrdp/examples/server.rs index 111b7c4f..78c90ba0 100644 --- a/crates/ironrdp/examples/server.rs +++ b/crates/ironrdp/examples/server.rs @@ -371,7 +371,7 @@ fn generate_sine_wave(sample_rate: u32, frequency: f32, duration_ms: u64, phase: // Wrap phase to maintain precision and avoid overflow *phase %= 2.0 * PI; - #[allow(clippy::cast_possible_truncation)] + #[expect(clippy::cast_possible_truncation)] let sample_i16 = (sample * amplitude) as i16; // Write same sample to both channels (stereo) diff --git a/xtask/src/cov.rs b/xtask/src/cov.rs index 6d663e7e..85ab8067 100644 --- a/xtask/src/cov.rs +++ b/xtask/src/cov.rs @@ -325,7 +325,7 @@ fn get_json_float(value: &tinyjson::JsonValue, key: &str) -> anyhow::Result fn get_json_int(value: &tinyjson::JsonValue, key: &str) -> anyhow::Result { // tinyjson does not expose any integers at all, so we need the f64 to u64 as casting - #[allow(clippy::cast_sign_loss)] - #[allow(clippy::cast_possible_truncation)] + #[expect(clippy::cast_sign_loss)] + #[expect(clippy::cast_possible_truncation)] get_json_float(value, key).map(|value| value as u64) }