Skip to content

Commit f96b1b2

Browse files
refactor: add allow_attributes clippy to "Extra-pedantic clippy" section (#880)
1 parent 4fc295d commit f96b1b2

28 files changed

Lines changed: 59 additions & 64 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ string_lit_chars_any = "warn"
124124
unnecessary_box_returns = "warn"
125125

126126
# == Extra-pedantic clippy == #
127+
allow_attributes = "warn"
127128
collection_is_never_read = "warn"
128129
copy_iterator = "warn"
129130
expl_impl_clone_on_copy = "warn"

crates/ironrdp-acceptor/src/connection.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ impl Sequence for Acceptor {
404404
})
405405
.unwrap_or_default();
406406

407-
#[allow(clippy::arithmetic_side_effects)] // IO channel ID is not big enough for overflowing.
407+
#[expect(clippy::arithmetic_side_effects)] // IO channel ID is not big enough for overflowing.
408408
let channels = joined
409409
.into_iter()
410410
.enumerate()

crates/ironrdp-cliprdr-format/src/bitmap.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub enum BitmapError {
3232
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
3333
struct BitmapCompression(u32);
3434

35-
#[allow(dead_code)]
35+
#[expect(dead_code)]
3636
impl BitmapCompression {
3737
const RGB: Self = Self(0x0000);
3838
const RLE8: Self = Self(0x0001);
@@ -48,7 +48,7 @@ impl BitmapCompression {
4848
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
4949
struct ColorSpace(u32);
5050

51-
#[allow(dead_code)]
51+
#[expect(dead_code)]
5252
impl ColorSpace {
5353
const CALIBRATED_RGB: Self = Self(0x00000000);
5454
const SRGB: Self = Self(0x73524742);
@@ -60,7 +60,7 @@ impl ColorSpace {
6060
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
6161
struct BitmapIntent(u32);
6262

63-
#[allow(dead_code)]
63+
#[expect(dead_code)]
6464
impl BitmapIntent {
6565
const LCS_GM_ABS_COLORIMETRIC: Self = Self(0x00000008);
6666
const LCS_GM_BUSINESS: Self = Self(0x00000001);
@@ -499,7 +499,7 @@ fn rgb_bmp_stride(width: u16, bit_count: u16) -> usize {
499499
debug_assert!(bit_count <= 32);
500500

501501
// No side effects, because u16::MAX * 32 + 31 < u16::MAX * u16::MAX < u32::MAX
502-
#[allow(clippy::arithmetic_side_effects)]
502+
#[expect(clippy::arithmetic_side_effects)]
503503
{
504504
(((usize::from(width) * usize::from(bit_count)) + 31) & !31) >> 3
505505
}
@@ -527,7 +527,7 @@ fn bgra_to_top_down_rgba(
527527
};
528528

529529
// Per invariants: height * width * dst_n_samples <= 10_000 * 10_000 * 4 < u32::MAX
530-
#[allow(clippy::arithmetic_side_effects)]
530+
#[expect(clippy::arithmetic_side_effects)]
531531
let dst_bitmap_len = usize::from(height) * usize::from(width) * dst_n_samples;
532532

533533
// Prevent allocation of huge buffers.
@@ -569,7 +569,7 @@ fn bgra_to_top_down_rgba(
569569
};
570570

571571
// Per invariants: width * dst_n_samples <= 10_000 * 4 < u32::MAX
572-
#[allow(clippy::arithmetic_side_effects)]
572+
#[expect(clippy::arithmetic_side_effects)]
573573
let dst_stride = usize::from(width) * dst_n_samples;
574574

575575
let mut dst_bitmap = vec![0u8; dst_bitmap_len];
@@ -647,13 +647,13 @@ fn top_down_rgba_to_bottom_up_bgra(
647647
let width = u16::try_from(info.width).map_err(|_| BitmapError::WidthTooBig)?;
648648
let height = u16::try_from(info.height).map_err(|_| BitmapError::HeightTooBig)?;
649649

650-
#[allow(clippy::arithmetic_side_effects)] // width * 4 <= 10_000 * 4 < u32::MAX
650+
#[expect(clippy::arithmetic_side_effects)] // width * 4 <= 10_000 * 4 < u32::MAX
651651
let stride = usize::from(width) * 4;
652652

653653
let src_rows = src_bitmap.chunks_exact(stride);
654654

655655
// As per invariants: stride * height <= width * 4 * height <= 10_000 * 4 * 10_000 <= u32::MAX.
656-
#[allow(clippy::arithmetic_side_effects)]
656+
#[expect(clippy::arithmetic_side_effects)]
657657
let dst_len = stride * usize::from(height);
658658
let dst_len = u32::try_from(dst_len).map_err(|_| BitmapError::InvalidSize)?;
659659

crates/ironrdp-cliprdr-format/src/html.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ pub fn plain_html_to_cf_html(fragment: &str) -> String {
9797
let mut write_header = |key: &str, value: &str| {
9898
// This relation holds: key.len() + value.len() + ":\r\n".len() < usize::MAX
9999
// Rationale: we know all possible values (see code below), and they are much smaller than `usize::MAX`.
100-
#[allow(clippy::arithmetic_side_effects)]
100+
#[expect(clippy::arithmetic_side_effects)]
101101
let size = key.len() + value.len() + ":\r\n".len();
102102
buffer.reserve(size);
103103

@@ -136,7 +136,7 @@ pub fn plain_html_to_cf_html(fragment: &str) -> String {
136136
let mut replace_placeholder = |value_begin_idx: usize, header_value: &str| {
137137
// We know that: value_begin_idx + POS_PLACEHOLDER.len() < usize::MAX
138138
// Rationale: the headers are written at the beginning, and we’re not indexing outside of the string.
139-
#[allow(clippy::arithmetic_side_effects)]
139+
#[expect(clippy::arithmetic_side_effects)]
140140
let value_end_idx = value_begin_idx + POS_PLACEHOLDER.len();
141141

142142
buffer.replace_range(value_begin_idx..value_end_idx, header_value);

crates/ironrdp-cliprdr-native/src/windows/clipboard_impl.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ impl WinClipboardImpl {
261261
const MAX_PROCESSING_ATTEMPTS: u32 = 10;
262262
const PROCESSING_TIMEOUT_MS: u32 = 100;
263263

264-
#[allow(clippy::arithmetic_side_effects)]
264+
#[expect(clippy::arithmetic_side_effects)]
265265
// self.attempt can’t be greater than MAX_PROCESSING_ATTEMPTS, so the arithmetic is safe here
266266
if self.attempt < MAX_PROCESSING_ATTEMPTS {
267267
self.attempt += 1;
@@ -347,7 +347,7 @@ pub(crate) unsafe extern "system" fn clipboard_subproc(
347347
}
348348
// Sent by the OS when delay-rendered data is requested for rendering.
349349
WM_RENDERFORMAT => {
350-
#[allow(clippy::cast_possible_truncation)] // should never truncate in practice
350+
#[expect(clippy::cast_possible_truncation)] // should never truncate in practice
351351
ctx.handle_event(BackendEvent::RenderFormat(ClipboardFormatId::new(wparam.0 as u32)));
352352
}
353353
// Sent by the OS when all delay-rendered data is requested for rendering.

crates/ironrdp-cliprdr-native/src/windows/os_clipboard.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ impl OwnedOsClipboard {
1919
}
2020

2121
/// Enumerates all available formats in the current clipboard.
22-
#[allow(clippy::unused_self)] // ensure we own the clipboard using RAII, and exclusive &mut self reference
22+
#[expect(clippy::unused_self)] // ensure we own the clipboard using RAII, and exclusive &mut self reference
2323
pub(crate) fn enum_available_formats(&mut self) -> Result<Vec<ClipboardFormat>, WinCliprdrError> {
2424
const DEFAULT_FORMATS_CAPACITY: usize = 16;
2525
// Sane default for format name. If format name is longer than this,
@@ -74,7 +74,7 @@ impl OwnedOsClipboard {
7474
/// Empties the clipboard
7575
///
7676
/// It is required to empty clipboard before setting any delay-rendered data.
77-
#[allow(clippy::unused_self)] // ensure we own the clipboard using RAII, and exclusive &mut self reference
77+
#[expect(clippy::unused_self)] // ensure we own the clipboard using RAII, and exclusive &mut self reference
7878
pub(crate) fn clear(&mut self) -> Result<(), WinCliprdrError> {
7979
// SAFETY: We own the clipboard at moment of method invocation, therefore it is safe to
8080
// call `EmptyClipboard`.
@@ -83,7 +83,7 @@ impl OwnedOsClipboard {
8383
Ok(())
8484
}
8585

86-
#[allow(clippy::unused_self)] // ensure we own the clipboard using RAII, and exclusive &mut self reference
86+
#[expect(clippy::unused_self)] // ensure we own the clipboard using RAII, and exclusive &mut self reference
8787
pub(crate) fn delay_render(&mut self, format: ClipboardFormatId) -> Result<(), WinCliprdrError> {
8888
// SAFETY: We own the clipboard at moment of method invocation, therefore it is safe to
8989
// call `SetClipboardData`.

crates/ironrdp-connector/src/connection.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ pub fn encode_send_data_request<T: Encode>(
600600
Ok(written)
601601
}
602602

603-
#[allow(single_use_lifetimes)] // anonymous lifetimes in `impl Trait` are unstable
603+
#[expect(single_use_lifetimes)] // anonymous lifetimes in `impl Trait` are unstable
604604
fn create_gcc_blocks<'a>(
605605
config: &Config,
606606
selected_protocol: nego::SecurityProtocol,

crates/ironrdp-displaycontrol/src/pdu/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl Encode for DisplayControlPdu {
4444
};
4545

4646
// This will never overflow as per invariants.
47-
#[allow(clippy::arithmetic_side_effects)]
47+
#[expect(clippy::arithmetic_side_effects)]
4848
let pdu_size = payload_length + Self::FIXED_PART_SIZE;
4949

5050
// Write `DISPLAYCONTROL_HEADER` fields.
@@ -65,7 +65,7 @@ impl Encode for DisplayControlPdu {
6565

6666
fn size(&self) -> usize {
6767
// As per invariants: This will never overflow.
68-
#[allow(clippy::arithmetic_side_effects)]
68+
#[expect(clippy::arithmetic_side_effects)]
6969
let size = Self::FIXED_PART_SIZE
7070
+ match self {
7171
DisplayControlPdu::Caps(caps) => caps.size(),
@@ -310,7 +310,7 @@ impl Encode for DisplayControlMonitorLayout {
310310
fn size(&self) -> usize {
311311
// As per invariants: This will never overflow:
312312
// 0 <= Self::FIXED_PART_SIZE + MAX_SUPPORTED_MONITORS * MonitorLayoutEntry::FIXED_PART_SIZE < u16::MAX
313-
#[allow(clippy::arithmetic_side_effects)]
313+
#[expect(clippy::arithmetic_side_effects)]
314314
let size = Self::FIXED_PART_SIZE + self.monitors.iter().map(|monitor| monitor.size()).sum::<usize>();
315315

316316
size
@@ -751,6 +751,6 @@ fn calculate_monitor_area(
751751

752752
// As per invariants: This multiplication would never overflow.
753753
// 0 <= MAX_MONITOR_AREA_FACTOR * MAX_MONITOR_AREA_FACTOR * MAX_SUPPORTED_MONITORS <= u64::MAX
754-
#[allow(clippy::arithmetic_side_effects)]
754+
#[expect(clippy::arithmetic_side_effects)]
755755
Ok(u64::from(max_monitor_area_factor_a) * u64::from(max_monitor_area_factor_b) * u64::from(max_num_monitors))
756756
}

crates/ironrdp-dvc-pipe-proxy/src/windows/event.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl Event {
3030
// CreateEventW returns a valid handle on success.
3131
Ok(Self {
3232
// See `unsafe impl Send` comment.
33-
#[allow(clippy::arc_with_non_send_sync)]
33+
#[expect(clippy::arc_with_non_send_sync)]
3434
handle: Arc::new(handle),
3535
})
3636
}

crates/ironrdp-dvc-pipe-proxy/src/windows/semaphore.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl Semaphore {
5555
Ok(Self {
5656
// See `unsafe impl Send` comment.
5757
// TODO(@CBenoit): Verify this comment.
58-
#[allow(clippy::arc_with_non_send_sync)]
58+
#[expect(clippy::arc_with_non_send_sync)]
5959
handle: Arc::new(handle),
6060
})
6161
}

0 commit comments

Comments
 (0)