From f7cc585335a2a0bdf6285daf607020e877158fe7 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 20 Oct 2026 21:40:11 -0700 Subject: [PATCH 01/21] quest: claim quest/m0/audit-lints.md Co-Authored-By: Claude Opus 5.5 From e40db753cf60f79b8aa18f6a5884f697e170f1e4 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 20 Oct 2026 22:20:02 -0700 Subject: [PATCH 02/21] refactor(net): express lite version predicates with matches! The 24 feature predicates suppressed match_like_matches_macro to keep a two-arm match. `matches!` over the old versions still lists them explicitly and falls forward for a new one, so the suppressions go. Co-Authored-By: Claude Opus 5.5 --- rs/moq-net/src/lite/version.rs | 222 ++++++++++++--------------------- 1 file changed, 80 insertions(+), 142 deletions(-) diff --git a/rs/moq-net/src/lite/version.rs b/rs/moq-net/src/lite/version.rs index 543028c8419..d94110c51b1 100644 --- a/rs/moq-net/src/lite/version.rs +++ b/rs/moq-net/src/lite/version.rs @@ -27,17 +27,17 @@ pub enum Version { Lite07, } +// Feature predicates list the old versions explicitly, so a future version falls +// forward to the newest behavior. impl Version { /// Whether SUBSCRIBE_OK carries the publisher's largest (group, frame), which a /// subscriber takes as where the live feed is. Added in lite-07; an earlier answer /// says nothing about the live edge. - #[allow(clippy::match_like_matches_macro)] pub(crate) fn has_largest(self) -> bool { - // Match form so future versions default forward (AGENTS.md convention). - match self { - Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04 | Self::Lite05 | Self::Lite06 => false, - _ => true, - } + !matches!( + self, + Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04 | Self::Lite05 | Self::Lite06 + ) } /// Whether the version has lite-05's dedicated TRACK stream and related stream @@ -45,106 +45,70 @@ impl Version { /// /// This is the common feature boundary for TRACK_INFO, FETCH streams, /// SUBSCRIBE_START/END, and per-frame timestamp prefixes. - #[allow(clippy::match_like_matches_macro)] pub fn has_track_stream(self) -> bool { - // Match form so future versions default forward (AGENTS.md convention). - match self { - Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04 => false, - _ => true, - } + !matches!(self, Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04) } /// Whether the PROBE message carries the RTT field. Added in lite-04; lite-03 /// carries the bitrate alone, so a report with only an RTT to give says nothing /// there and must not be sent. - #[allow(clippy::match_like_matches_macro)] pub fn has_probe_rtt(self) -> bool { - // Match form so future versions default forward (AGENTS.md convention). - match self { - Self::Lite01 | Self::Lite02 | Self::Lite03 => false, - _ => true, - } + !matches!(self, Self::Lite01 | Self::Lite02 | Self::Lite03) } /// Whether the session opens a unidirectional Setup Stream carrying a single SETUP /// message (capabilities + optional Path). Added in lite-05; the older bidirectional /// setup exchange (Lite01/02) and the no-setup drafts (Lite03/04) don't use it. - #[allow(clippy::match_like_matches_macro)] pub fn has_setup_stream(self) -> bool { - // Match form so future versions default forward (AGENTS.md convention). - match self { - Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04 => false, - _ => true, - } + !matches!(self, Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04) } /// Whether the session may deliver groups over unreliable QUIC datagrams (lite-05 §6.4). /// A datagram carries one single-frame group's `subscribe | sequence | timestamp | payload` /// and is routed over the existing subscription. Added in lite-05; older versions never /// send or accept datagram bodies. - #[allow(clippy::match_like_matches_macro)] pub fn has_datagrams(self) -> bool { - // Match form so future versions default forward (AGENTS.md convention). - match self { - Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04 => false, - _ => true, - } + !matches!(self, Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04) } /// Whether announce streams begin with ANNOUNCE_OK and omit the sender's origin /// from each announcement's hop chain. Added in lite-05. - #[allow(clippy::match_like_matches_macro)] pub fn has_announce_ok(self) -> bool { - // Match form so future versions default forward (AGENTS.md convention). - match self { - Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04 => false, - _ => true, - } + !matches!(self, Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04) } /// Whether the session supports the GOAWAY control stream (0x5) for graceful /// shutdown and migration. Added in lite-04. - #[allow(clippy::match_like_matches_macro)] pub fn has_goaway(self) -> bool { - // Match form so future versions default forward (AGENTS.md convention). - match self { - Self::Lite01 | Self::Lite02 | Self::Lite03 => false, - _ => true, - } + !matches!(self, Self::Lite01 | Self::Lite02 | Self::Lite03) } /// Whether either endpoint may open an Auth Stream (0x7) to present a token and /// learn its grant. Added in lite-07. - #[allow(clippy::match_like_matches_macro)] pub fn has_auth(self) -> bool { - // Match form so future versions default forward (AGENTS.md convention). - match self { - Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04 | Self::Lite05 | Self::Lite06 => false, - _ => true, - } + !matches!( + self, + Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04 | Self::Lite05 | Self::Lite06 + ) } /// Whether a subscriber may open a Tracks Stream (0x8) to list a broadcast's /// tracks. Added in lite-07. - #[allow(clippy::match_like_matches_macro)] pub fn has_tracks(self) -> bool { - // Match form so future versions default forward (AGENTS.md convention). - match self { - Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04 | Self::Lite05 | Self::Lite06 => false, - _ => true, - } + !matches!( + self, + Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04 | Self::Lite05 | Self::Lite06 + ) } /// Whether announcements carry implicit announce ids: each `active` /// ANNOUNCE_BROADCAST assigns the next per-stream ordinal, and `ended`/`restart` /// reference that id instead of repeating the path. Added in lite-06. - #[allow(clippy::match_like_matches_macro)] pub fn has_announce_id(self) -> bool { - // Match form so future versions default forward (AGENTS.md convention). - match self { - Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04 | Self::Lite05 => false, - _ => true, - } + !matches!( + self, + Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04 | Self::Lite05 + ) } /// Whether ANNOUNCE_REQUEST carries the Exclude Hop field: the subscriber's own @@ -169,35 +133,29 @@ impl Version { /// /// Older versions only address whole groups, so a route change has to wait for the /// next group before it can resume. - #[allow(clippy::match_like_matches_macro)] pub fn has_frame_bounds(self) -> bool { - // Match form so future versions default forward (AGENTS.md convention). - match self { - Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04 | Self::Lite05 => false, - _ => true, - } + !matches!( + self, + Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04 | Self::Lite05 + ) } /// Whether SUBSCRIBE and SUBSCRIBE_UPDATE carry the subscriber's `Group Order`. /// Added in lite-07; an earlier subscription is served newest first. - #[allow(clippy::match_like_matches_macro)] pub(crate) fn has_order(self) -> bool { - // Match form so future versions default forward (AGENTS.md convention). - match self { - Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04 | Self::Lite05 | Self::Lite06 => false, - _ => true, - } + !matches!( + self, + Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04 | Self::Lite05 | Self::Lite06 + ) } /// Whether FETCH carries the subscriber's optional max delay. Added in lite-07; an /// earlier fetch is bounded by the publisher's retention alone. - #[allow(clippy::match_like_matches_macro)] pub(crate) fn has_fetch_max_delay(self) -> bool { - // Match form so future versions default forward (AGENTS.md convention). - match self { - Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04 | Self::Lite05 | Self::Lite06 => false, - _ => true, - } + !matches!( + self, + Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04 | Self::Lite05 | Self::Lite06 + ) } /// Whether this version's SUBSCRIBE, SUBSCRIBE_UPDATE, SUBSCRIBE_OK, and TRACK_INFO @@ -220,126 +178,106 @@ impl Version { /// Older versions encode `Group Start` as the sequence + 1, with 0 meaning the /// latest group, so an absent start there pins the cursor to the live edge instead /// of resolving it from the budget. - #[allow(clippy::match_like_matches_macro)] pub(crate) fn resolves_start(self) -> bool { - // Match form so future versions default forward (AGENTS.md convention). - match self { - Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04 | Self::Lite05 => false, - _ => true, - } + !matches!( + self, + Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04 | Self::Lite05 + ) } /// Whether subscription completion waits for the subscriber's FIN. - #[allow(clippy::match_like_matches_macro)] pub(crate) fn waits_for_subscriber_fin(self) -> bool { - match self { - Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04 | Self::Lite05 | Self::Lite06 => false, - _ => true, - } + !matches!( + self, + Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04 | Self::Lite05 | Self::Lite06 + ) } /// Whether ANNOUNCE_REQUEST carries the hidden opt-in. Added in lite-07; older /// requests decode as not opted in. - #[allow(clippy::match_like_matches_macro)] pub fn has_hidden(self) -> bool { - // Match form so future versions default forward (AGENTS.md convention). - match self { - Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04 | Self::Lite05 | Self::Lite06 => false, - _ => true, - } + !matches!( + self, + Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04 | Self::Lite05 | Self::Lite06 + ) } /// Whether ANNOUNCE_START and ANNOUNCE_UPDATE may copy a path head or hop-chain tail /// from a live announcement on the same stream. Added in lite-07. - #[allow(clippy::match_like_matches_macro)] pub fn has_announce_compression(self) -> bool { - // Match form so future versions default forward (AGENTS.md convention). - match self { - Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04 | Self::Lite05 | Self::Lite06 => false, - _ => true, - } + !matches!( + self, + Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04 | Self::Lite05 | Self::Lite06 + ) } /// Whether the stream error table has NOT_FETCHABLE, for a FETCH that reached a /// datagram. Added in lite-07; earlier versions say NOT_FOUND instead. - #[allow(clippy::match_like_matches_macro)] pub(crate) fn has_not_fetchable(self) -> bool { - // Match form so future versions default forward (AGENTS.md convention). - match self { - Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04 | Self::Lite05 | Self::Lite06 => false, - _ => true, - } + !matches!( + self, + Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04 | Self::Lite05 | Self::Lite06 + ) } /// Whether announcements and track requests carry the publisher epoch, the /// identity that says two routes serve the same bytes. Added in lite-07. /// Older versions carry nothing, so a received route has no epoch and is /// never resumed through another route. - #[allow(clippy::match_like_matches_macro)] pub fn has_epoch(self) -> bool { - // Match form so future versions default forward (AGENTS.md convention). - match self { - Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04 | Self::Lite05 | Self::Lite06 => false, - _ => true, - } + !matches!( + self, + Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04 | Self::Lite05 | Self::Lite06 + ) } /// Whether a session may negotiate the `ietf` extension (draft-lcurley-moq-ietf), which /// carries moq-transport object state between relays. Added on lite-07; published /// versions get no framing changes. - #[allow(clippy::match_like_matches_macro)] pub(crate) fn has_ietf(self) -> bool { - // Match form so future versions default forward (AGENTS.md convention). - match self { - Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04 | Self::Lite05 | Self::Lite06 => false, - _ => true, - } + !matches!( + self, + Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04 | Self::Lite05 | Self::Lite06 + ) } /// Whether the announce stream has ANNOUNCE_RESTART: another publisher instance /// replacing an advertisement in place. Added in lite-07. Older versions send an /// ANNOUNCE_END then an ANNOUNCE_START. - #[allow(clippy::match_like_matches_macro)] pub fn has_announce_restart(self) -> bool { - // Match form so future versions default forward (AGENTS.md convention). - match self { - Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04 | Self::Lite05 | Self::Lite06 => false, - _ => true, - } + !matches!( + self, + Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04 | Self::Lite05 | Self::Lite06 + ) } /// Whether TRACK_INFO carries the refresh ratio and SUBSCRIBE_UPDATE a wanted group, /// so a join at any hop reaches the publisher. Added in lite-07; older peers see a /// track that never refreshes. - #[allow(clippy::match_like_matches_macro)] pub(crate) fn has_refresh(self) -> bool { - // Match form so future versions default forward (AGENTS.md convention). - match self { - Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04 | Self::Lite05 | Self::Lite06 => false, - _ => true, - } + !matches!( + self, + Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04 | Self::Lite05 | Self::Lite06 + ) } /// Whether discovery streams end their initial set with SYNCED rather than a count. - #[allow(clippy::match_like_matches_macro)] pub fn has_synced(self) -> bool { - match self { - Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04 | Self::Lite05 | Self::Lite06 => false, - _ => true, - } + !matches!( + self, + Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04 | Self::Lite05 | Self::Lite06 + ) } /// Whether announcements carry the route cost: the marginal cost of pulling /// the broadcast via this route, accumulated per link. Added in lite-06. /// Older versions carry nothing, so a received route stays at zero and ranks /// on hop count alone, exactly as before. - #[allow(clippy::match_like_matches_macro)] pub fn has_route_cost(self) -> bool { - // Match form so future versions default forward (AGENTS.md convention). - match self { - Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04 | Self::Lite05 => false, - _ => true, - } + !matches!( + self, + Self::Lite01 | Self::Lite02 | Self::Lite03 | Self::Lite04 | Self::Lite05 + ) } /// The timescale the wire carries for a track with `timescale`, or `None` when its From 4c799c5eaffa8a9dec25e1e2c646c097f7a07acd Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 20 Oct 2026 22:20:06 -0700 Subject: [PATCH 03/21] refactor(net): use is_multiple_of in Timestamp's Debug The suppression said is_multiple_of was unstable on Rust 1.85; it is stable since 1.87 and the workspace floor is 1.91. Co-Authored-By: Claude Opus 5.5 --- rs/moq-net/src/model/time.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/rs/moq-net/src/model/time.rs b/rs/moq-net/src/model/time.rs index 8d433a1571b..ab585eaed84 100644 --- a/rs/moq-net/src/model/time.rs +++ b/rs/moq-net/src/model/time.rs @@ -330,16 +330,15 @@ impl From for std::time::Duration { } impl std::fmt::Debug for Timestamp { - #[allow(clippy::manual_is_multiple_of)] // is_multiple_of is unstable in Rust 1.85 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let nanos = self.as_nanos(); // Choose the largest unit where we don't need decimal places. - if nanos % 1_000_000_000 == 0 { + if nanos.is_multiple_of(1_000_000_000) { write!(f, "{}s", nanos / 1_000_000_000) - } else if nanos % 1_000_000 == 0 { + } else if nanos.is_multiple_of(1_000_000) { write!(f, "{}ms", nanos / 1_000_000) - } else if nanos % 1_000 == 0 { + } else if nanos.is_multiple_of(1_000) { write!(f, "{}µs", nanos / 1_000) } else { write!(f, "{}ns", nanos) From 7ad363384a0a3098c618cc78051c8bd287e441b7 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 20 Oct 2026 22:20:11 -0700 Subject: [PATCH 04/21] refactor(tokio): name the interruptible stream op type Three state variants spelled out OpBox<(S, Option>)> under type_complexity allows. A StreamOp alias names it once. Co-Authored-By: Claude Opus 5.5 --- rs/moq-tokio/src/transport.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/rs/moq-tokio/src/transport.rs b/rs/moq-tokio/src/transport.rs index 5f60ad295b9..b6598bc1f15 100644 --- a/rs/moq-tokio/src/transport.rs +++ b/rs/moq-tokio/src/transport.rs @@ -66,6 +66,9 @@ impl std::fmt::Display for Transport { /// plain boxed flavor suffices. type OpBox = futures::future::BoxFuture<'static, T>; +/// A stream op that hands the stream back with its result, or `None` if interrupted. +type StreamOp = OpBox<(S, Option>)>; + /// Adapts one of this crate's async backends (qmux, iroh, quic) to the poll interface /// moq-net requires. /// @@ -286,13 +289,12 @@ enum SendState { /// retrying caller supplied the same bytes. A `None` result means the write /// was interrupted by a reset (see [`SendStream::interrupt`]). Writing { - #[allow(clippy::type_complexity)] - fut: OpBox<(S, Option>)>, + fut: StreamOp, chunk: Bytes, }, /// The closed() acknowledgement watch; a `None` result means it was /// interrupted by a late reset or priority change (see [`SendStream::interrupt`]). - Closing(#[allow(clippy::type_complexity)] OpBox<(S, Option>)>), + Closing(StreamOp), } impl SendStream { @@ -668,7 +670,7 @@ enum RecvState { Idle(S), /// A read in flight; a `None` result means it was interrupted by a stop /// (see [`RecvStream::interrupt`]). - Reading(#[allow(clippy::type_complexity)] OpBox<(S, Option, S::Error>>)>), + Reading(StreamOp, S::Error>), } impl RecvStream { From 1f98fa325e1612fff71531ceb5d9f6d8e33ccea4 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 20 Oct 2026 22:20:16 -0700 Subject: [PATCH 05/21] fix(lint): clear clippy failures in moq-auth examples and the jitter bench `--all-targets` clippy failed on both: the moq-auth examples read SystemTime::now under the crate's clock ban (Claims takes SystemTime, so the examples expect the lint), and the jitter bench dropped a must_use Poll. Co-Authored-By: Claude Opus 5.5 --- rs/moq-auth/examples/asymmetric.rs | 5 +++++ rs/moq-auth/examples/basic.rs | 5 +++++ rs/moq-mux/benches/jitter.rs | 7 +++++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/rs/moq-auth/examples/asymmetric.rs b/rs/moq-auth/examples/asymmetric.rs index cd1a9ceb01d..b92f4213d1b 100644 --- a/rs/moq-auth/examples/asymmetric.rs +++ b/rs/moq-auth/examples/asymmetric.rs @@ -4,6 +4,11 @@ // and the public key verifies them. This is the recommended approach for // production: the relay only needs the public key. +#![expect( + clippy::disallowed_methods, + reason = "`Claims` takes `SystemTime`, so the example reads the host clock" +)] + use std::time::{Duration, SystemTime}; fn main() -> anyhow::Result<()> { diff --git a/rs/moq-auth/examples/basic.rs b/rs/moq-auth/examples/basic.rs index ebdc7174999..b2f4dd5a919 100644 --- a/rs/moq-auth/examples/basic.rs +++ b/rs/moq-auth/examples/basic.rs @@ -1,5 +1,10 @@ // cargo run --example basic +#![expect( + clippy::disallowed_methods, + reason = "`Claims` takes `SystemTime`, so the example reads the host clock" +)] + use std::time::{Duration, SystemTime}; fn main() -> anyhow::Result<()> { diff --git a/rs/moq-mux/benches/jitter.rs b/rs/moq-mux/benches/jitter.rs index 384071b502a..16f49a643f8 100644 --- a/rs/moq-mux/benches/jitter.rs +++ b/rs/moq-mux/benches/jitter.rs @@ -6,7 +6,10 @@ use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main}; use moq_net::Timestamp; #[path = "../src/jitter.rs"] -#[allow(dead_code)] +#[allow( + dead_code, + reason = "the bench compiles the private module from source and uses only part of it" +)] mod jitter; /// Every track sends a frame a second as it decodes, for as many two-second steering steps as @@ -97,7 +100,7 @@ fn acquisition(c: &mut Criterion) { .unwrap(); } } - std::hint::black_box(buffer.poll_next(&kio::Waiter::noop())); + let _ = std::hint::black_box(buffer.poll_next(&kio::Waiter::noop())); }) }); }); From 0f50eda3af7f02619326905250088cb25fcfde2c Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 20 Oct 2026 22:20:21 -0700 Subject: [PATCH 06/21] fix(publish): read file track metadata through mediabunny's async getters typescript-eslint's no-deprecated flagged six reads of mediabunny's deprecated synchronous track properties (rotation, display size, codec, sample rate, channel count). They are read once while probing, before the clock is pinned. Co-Authored-By: Claude Opus 5.5 --- js/publish/src/source/file.ts | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/js/publish/src/source/file.ts b/js/publish/src/source/file.ts index 1045ebdba21..47f7ae4ecc1 100644 --- a/js/publish/src/source/file.ts +++ b/js/publish/src/source/file.ts @@ -160,6 +160,11 @@ export class File { // The encoder sizes its bitrate off this, and a file's real cadence beats assuming 30fps. const frameRate = video && videoOk ? (await video.computePacketStats(FRAME_RATE_SAMPLES)).averagePacketRate : undefined; + const toFrame = video && videoOk ? await converter(video) : undefined; + const format = + audio && audioOk + ? { sampleRate: await audio.getSampleRate(), channelCount: await audio.getNumberOfChannels() } + : undefined; // Pin the clock last. Probing the file takes a moment, and anchoring before that would leave // the first samples already overdue, so playback would open with a catch-up burst. @@ -169,19 +174,14 @@ export class File { const source: Media = { video: - video && videoOk + video && toFrame ? { - frames: pace( - new VideoSampleSink(video), - timeline, - video.rotation === 0 ? (sample) => sample.toVideoFrame() : rotator(video), - signal, - ), + frames: pace(new VideoSampleSink(video), timeline, toFrame, signal), frameRate, } : undefined, audio: - audio && audioOk + audio && format ? { samples: pace( new AudioSampleSink(audio), @@ -189,8 +189,7 @@ export class File { (sample) => sample.toAudioData(), signal, ), - sampleRate: audio.sampleRate, - channelCount: audio.numberOfChannels, + ...format, // A file is whatever the user picked, so leave the Opus tuning to the encoder. kind: "auto", } @@ -293,8 +292,10 @@ function pace( // Phone footage is usually stored sideways with rotation metadata, which toVideoFrame() ignores // because a VideoFrame can't carry it. Drawing through a canvas is the only way to bake it in. -function rotator(track: InputVideoTrack): (sample: VideoSample) => VideoFrame { - const canvas = new OffscreenCanvas(track.displayWidth, track.displayHeight); +async function converter(track: InputVideoTrack): Promise<(sample: VideoSample) => VideoFrame> { + if ((await track.getRotation()) === 0) return (sample) => sample.toVideoFrame(); + + const canvas = new OffscreenCanvas(await track.getDisplayWidth(), await track.getDisplayHeight()); const ctx = canvas.getContext("2d"); if (!ctx) throw new Error("Failed to create 2D canvas context"); @@ -312,7 +313,7 @@ async function decodable(track: InputVideoTrack | InputAudioTrack | null, file: if (await track.canDecode()) return true; console.warn( - `Publishing "${file.name}" without its ${track.type} track: this browser can't decode ${track.codec}.`, + `Publishing "${file.name}" without its ${track.type} track: this browser can't decode ${await track.getCodec()}.`, ); return false; } From 15c152ac881e09a1b9c6df5a6e85db52edb36b25 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 20 Oct 2026 22:20:26 -0700 Subject: [PATCH 07/21] chore(publish): say which DOM types each ts-expect-error covers Co-Authored-By: Claude Opus 5.5 --- js/publish/src/source/screen.ts | 8 ++++---- js/publish/src/video/capture-worker.ts | 2 +- js/publish/src/video/encoder.ts | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/js/publish/src/source/screen.ts b/js/publish/src/source/screen.ts index 8e32f6e4c78..2ecdba991a0 100644 --- a/js/publish/src/source/screen.ts +++ b/js/publish/src/source/screen.ts @@ -73,11 +73,11 @@ export class Screen { const audio = effect.get(this.audio); // TODO Expose these to the application. - // @ts-expect-error Chrome only + // @ts-expect-error TypeScript's DOM lib lacks the Chrome-only `CaptureController`. let controller: CaptureController | undefined; - // @ts-expect-error Chrome only + // @ts-expect-error TypeScript's DOM lib lacks the Chrome-only `CaptureController`. if (typeof self.CaptureController !== "undefined") { - // @ts-expect-error Chrome only + // @ts-expect-error TypeScript's DOM lib lacks the Chrome-only `CaptureController`. controller = new CaptureController(); controller.setFocusBehavior("no-focus-change"); } @@ -88,7 +88,7 @@ export class Screen { .getDisplayMedia({ video, audio, - // @ts-expect-error Chrome only + // @ts-expect-error TypeScript's DOM lib lacks the Chrome-only `CaptureController`. controller, preferCurrentTab: false, selfBrowserSurface: "exclude", diff --git a/js/publish/src/video/capture-worker.ts b/js/publish/src/video/capture-worker.ts index afffad94ba6..fac139d9782 100644 --- a/js/publish/src/video/capture-worker.ts +++ b/js/publish/src/video/capture-worker.ts @@ -60,7 +60,7 @@ async function handle(msg: ToWorker): Promise { function start(track: MediaStreamTrack): void { source = track; - // @ts-expect-error No typescript types yet. + // @ts-expect-error TypeScript's DOM lib lacks the Chrome-only `MediaStreamTrackProcessor`. const processor = new MediaStreamTrackProcessor({ track }); reader = (processor.readable as ReadableStream).getReader(); } diff --git a/js/publish/src/video/encoder.ts b/js/publish/src/video/encoder.ts index 64a3d26893b..53d3e83d6ea 100644 --- a/js/publish/src/video/encoder.ts +++ b/js/publish/src/video/encoder.ts @@ -804,7 +804,7 @@ export class Encoder { latencyMode: "realtime", hardwareAcceleration, avc: codec.startsWith("avc1") ? { format: "annexb" } : undefined, - // @ts-expect-error Typescript needs to be updated. + // @ts-expect-error TypeScript's DOM lib lacks the HEVC codec registration's `hevc` config. hevc: codec.startsWith("hev1") ? { format: "annexb" } : undefined, }; From 576f55bd36d6470cbb7d3ef136b3030017cc2883 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 20 Oct 2026 22:20:31 -0700 Subject: [PATCH 08/21] chore(py): enable ruff's RUF100 and drop stale noqa directives RUF100 fails a noqa that no longer suppresses anything. Five were stale: BLE001 is not a selected rule, F401 never fires on a star import, and ruff accepts an import after sys.path.insert. Co-Authored-By: Claude Opus 5.5 --- demo/carla/sim/pyproject.toml | 3 ++- demo/carla/sim/tests/test_main.py | 2 +- py/moq-ffi/moq_ffi/__init__.py | 2 +- pyproject.toml | 3 ++- test/interop/clients/python/interop.py | 2 +- test/smoke/clients/python/smoke.py | 2 +- test/ts/compliance.test.py | 2 +- 7 files changed, 9 insertions(+), 7 deletions(-) diff --git a/demo/carla/sim/pyproject.toml b/demo/carla/sim/pyproject.toml index 505c49c58f3..6826f64944e 100644 --- a/demo/carla/sim/pyproject.toml +++ b/demo/carla/sim/pyproject.toml @@ -26,7 +26,8 @@ line-length = 120 target-version = "py312" [tool.ruff.lint] -select = ["E", "F", "W", "I"] +# RUF100 fails a `noqa` that no longer suppresses anything. +select = ["E", "F", "W", "I", "RUF100"] [tool.ruff.format] quote-style = "double" diff --git a/demo/carla/sim/tests/test_main.py b/demo/carla/sim/tests/test_main.py index 8ccad470e98..d999629431e 100644 --- a/demo/carla/sim/tests/test_main.py +++ b/demo/carla/sim/tests/test_main.py @@ -84,7 +84,7 @@ async def scenario() -> tuple[BaseException | None, asyncio.Task]: truck = asyncio.create_task(asyncio.Event().wait(), name="truck:truck1") try: await asyncio.wait_for(main_module.supervise(client, [truck], clock, watchdog), timeout=1.0) - except BaseException as err: # noqa: BLE001 - the test asserts on it + except BaseException as err: # the test asserts on it return err, truck return None, truck diff --git a/py/moq-ffi/moq_ffi/__init__.py b/py/moq-ffi/moq_ffi/__init__.py index c4e54479d5c..42a76c67900 100644 --- a/py/moq-ffi/moq_ffi/__init__.py +++ b/py/moq-ffi/moq_ffi/__init__.py @@ -10,7 +10,7 @@ import atexit -from ._uniffi import * # noqa: F401,F403 +from ._uniffi import * # noqa: F403 from ._uniffi.moq import _UniffiLib # Rust runtime workers wake awaiting coroutines through a ctypes diff --git a/pyproject.toml b/pyproject.toml index 13d34725e7b..ec725f628ff 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,7 +38,8 @@ target-version = "py310" extend-exclude = ["**/_uniffi"] [tool.ruff.lint] -select = ["E", "F", "W", "I"] +# RUF100 fails a `noqa` that no longer suppresses anything. +select = ["E", "F", "W", "I", "RUF100"] [tool.ruff.format] quote-style = "double" diff --git a/test/interop/clients/python/interop.py b/test/interop/clients/python/interop.py index 2433090615d..ceddae17bea 100644 --- a/test/interop/clients/python/interop.py +++ b/test/interop/clients/python/interop.py @@ -153,7 +153,7 @@ def main() -> None: except (TimeoutError, asyncio.TimeoutError): print("error: timed out waiting for data", file=sys.stderr) sys.exit(1) - except Exception as err: # noqa: BLE001 - interop client: any failure is a failure + except Exception as err: # interop client: any failure is a failure print(f"error: {err}", file=sys.stderr) sys.exit(1) diff --git a/test/smoke/clients/python/smoke.py b/test/smoke/clients/python/smoke.py index c57adca2b64..8af3b12b105 100644 --- a/test/smoke/clients/python/smoke.py +++ b/test/smoke/clients/python/smoke.py @@ -108,7 +108,7 @@ def main() -> None: except (TimeoutError, asyncio.TimeoutError): print("error: timed out waiting for data", file=sys.stderr) sys.exit(1) - except Exception as err: # noqa: BLE001 - smoke client: any failure is a failure + except Exception as err: # smoke client: any failure is a failure print(f"error: {err}", file=sys.stderr) sys.exit(1) diff --git a/test/ts/compliance.test.py b/test/ts/compliance.test.py index ee93a1f9a29..698842fe5e4 100644 --- a/test/ts/compliance.test.py +++ b/test/ts/compliance.test.py @@ -3,7 +3,7 @@ import unittest sys.path.insert(0, str(pathlib.Path(__file__).parent)) -import compliance # noqa: E402 +import compliance def eac3(stream: int) -> bytes: From 6b7ae69ed48821b38f26f6db74ee002ddbd1d3ee Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 20 Oct 2026 22:21:29 -0700 Subject: [PATCH 09/21] ci(rs): require a reason on every lint suppression, and expect where unconditional A [workspace.lints] table enables clippy::allow_attributes_without_reason, and every crate opts in. kio's and moq-net's loom check-cfg moves into it; moq-quic's quinn lints move to crate attributes, since a crate can't extend the workspace table. Each unconditional clippy suppression, and each always-firing rustc one (naming, missing_docs, deprecated), is now #[expect], so it fails once the lint stops firing. Suppressions that depend on features, targets, or pointer width use cfg_attr or stay an allow with their reason. Converting surfaced stale suppressions, which are removed: 27 repr(C) naming allows in moq-c (rustc skips repr(C) structs), off-by-default pedantic and restriction lints in moq-v4l and moq-nvenc, never-firing large_enum_variant, too_many_arguments, type_complexity, field_reassign_with_default, needless_lifetimes, and arc_with_non_send_sync (moq-net, moq-flate, moq-mux), an unused_mut in moq-relay, disallowed_types in test modules, the moq-uring clock module's ban opt-out, and a deprecated allow on a field that is no longer deprecated. moq-quic's crate-wide too_many_arguments and cognitive_complexity allows become four per-function expects. model-markers.py steps over attributes rustfmt wraps, so a marker above a long cfg_attr still counts. Co-Authored-By: Claude Opus 5.5 --- Cargo.toml | 8 + demo/carla/bridge/Cargo.toml | 3 + rs/hang/Cargo.toml | 3 + rs/hang/src/catalog/root.rs | 5 +- rs/kio/Cargo.toml | 4 +- rs/kio/src/waiter.rs | 2 +- rs/libmoq/Cargo.toml | 3 + rs/moq-archive/Cargo.toml | 3 + rs/moq-archive/benches/writer.rs | 7 +- rs/moq-archive/src/lib.rs | 2 +- rs/moq-archive/src/reader/mod.rs | 6 +- rs/moq-archive/src/writer.rs | 8 +- rs/moq-audio/Cargo.toml | 3 + rs/moq-audio/src/encode/capture.rs | 7 +- rs/moq-audio/src/playback/mixer.rs | 5 +- rs/moq-auth/Cargo.toml | 3 + rs/moq-auth/src/claims.rs | 2 +- rs/moq-auth/src/client.rs | 11 +- rs/moq-auth/src/key.rs | 7 +- rs/moq-auth/src/lease.rs | 2 +- rs/moq-auth/src/serve.rs | 2 +- rs/moq-auth/src/set.rs | 7 +- rs/moq-bench/Cargo.toml | 3 + rs/moq-bench/src/config.rs | 5 +- rs/moq-boy/Cargo.toml | 3 + rs/moq-c/Cargo.toml | 3 + rs/moq-c/src/api.rs | 43 +---- rs/moq-c/src/audio.rs | 6 +- rs/moq-c/src/error.rs | 5 +- rs/moq-c/src/ffi.rs | 2 +- rs/moq-c/src/test.rs | 5 +- rs/moq-c/src/video.rs | 11 +- rs/moq-cli/Cargo.toml | 3 + rs/moq-cli/benches/play_buffer.rs | 5 +- rs/moq-cli/src/args.rs | 2 +- rs/moq-cli/src/play/mod.rs | 10 +- rs/moq-cli/src/publish.rs | 106 ++++++++++-- rs/moq-clock/Cargo.toml | 3 + rs/moq-clock/macros/Cargo.toml | 3 + rs/moq-clock/src/installed.rs | 5 +- rs/moq-clock/src/runtime.rs | 5 +- rs/moq-e2ee/Cargo.toml | 3 + rs/moq-e2ee/tests/support/harness.rs | 2 +- rs/moq-ffi/Cargo.toml | 3 + rs/moq-ffi/src/android.rs | 2 +- rs/moq-ffi/src/ffi.rs | 8 +- rs/moq-ffi/src/lib.rs | 13 +- rs/moq-flate/Cargo.toml | 3 + rs/moq-flate/src/lib.rs | 4 - rs/moq-gst/Cargo.toml | 3 + rs/moq-hls/Cargo.toml | 3 + rs/moq-hls/src/export/mod.rs | 30 +++- rs/moq-hls/src/export/rendition.rs | 15 +- rs/moq-hls/src/export/renditions.rs | 10 +- rs/moq-hls/src/export/segments.rs | 30 +++- rs/moq-ice/Cargo.toml | 3 + rs/moq-ice/src/agent.rs | 6 +- rs/moq-json/Cargo.toml | 3 + rs/moq-json/benches/window.rs | 4 +- rs/moq-json/src/snapshot/decoder.rs | 4 +- rs/moq-json/src/snapshot/mod.rs | 4 +- rs/moq-loc/Cargo.toml | 3 + rs/moq-msf/Cargo.toml | 3 + rs/moq-msf/src/lib.rs | 5 +- rs/moq-mux/Cargo.toml | 3 + rs/moq-mux/benches/ts_schedule.rs | 5 +- rs/moq-mux/src/catalog/consumer.rs | 7 +- rs/moq-mux/src/catalog/producer.rs | 5 - rs/moq-mux/src/container/ts/import.rs | 1 - rs/moq-mux/src/lib.rs | 5 +- rs/moq-mux/src/timeline.rs | 4 - rs/moq-native/Cargo.toml | 3 + rs/moq-net/Cargo.toml | 6 +- rs/moq-net/benches/admission.rs | 6 +- rs/moq-net/benches/memory.rs | 6 +- rs/moq-net/benches/origin.rs | 6 +- rs/moq-net/benches/priority.rs | 5 +- rs/moq-net/benches/refresh.rs | 6 +- rs/moq-net/benches/schedule.rs | 7 +- rs/moq-net/benches/session.rs | 6 +- rs/moq-net/benches/track.rs | 6 +- rs/moq-net/fuzz/Cargo.toml | 3 + rs/moq-net/src/auth.rs | 154 +++++++++--------- rs/moq-net/src/coding/codes.rs | 2 +- rs/moq-net/src/coding/decode.rs | 34 ++-- rs/moq-net/src/coding/encode.rs | 30 ++-- rs/moq-net/src/coding/varint.rs | 8 +- rs/moq-net/src/coding/version.rs | 2 +- rs/moq-net/src/epoch.rs | 4 +- rs/moq-net/src/fuzz.rs | 2 +- rs/moq-net/src/goaway.rs | 28 ++-- rs/moq-net/src/ietf/mod.rs | 10 +- rs/moq-net/src/ietf/parameters.rs | 16 +- rs/moq-net/src/ietf/publisher.rs | 10 +- rs/moq-net/src/ietf/session.rs | 5 +- rs/moq-net/src/ietf/subscriber.rs | 15 +- rs/moq-net/src/ietf/token.rs | 2 +- rs/moq-net/src/lib.rs | 6 - rs/moq-net/src/lite/mod.rs | 10 +- rs/moq-net/src/lite/publisher.rs | 35 ++-- rs/moq-net/src/lite/subscriber.rs | 59 ++++--- rs/moq-net/src/model/bandwidth.rs | 6 +- rs/moq-net/src/model/broadcast.rs | 20 +-- rs/moq-net/src/model/frame.rs | 32 ++-- rs/moq-net/src/model/group.rs | 24 +-- rs/moq-net/src/model/ledger.rs | 2 +- rs/moq-net/src/model/listing.rs | 4 +- rs/moq-net/src/model/origin.rs | 55 ++++--- rs/moq-net/src/model/resume.rs | 16 +- rs/moq-net/src/model/track.rs | 110 ++++++------- rs/moq-net/src/path/mod.rs | 2 +- rs/moq-net/src/setup.rs | 30 ++-- rs/moq-net/src/stats.rs | 8 +- rs/moq-net/src/util.rs | 4 +- rs/moq-net/src/version.rs | 4 +- .../integration/routing_contracts/model.rs | 5 +- .../tests/integration/support/harness.rs | 2 +- rs/moq-net/tests/integration/support/mock.rs | 3 +- rs/moq-net/tests/integration/support/mod.rs | 4 +- rs/moq-nvenc/Cargo.toml | 3 + rs/moq-nvenc/src/cuvid.rs | 1 - rs/moq-nvenc/src/lib.rs | 10 +- rs/moq-nvenc/src/safe/api.rs | 6 +- rs/moq-nvenc/src/safe/buffer.rs | 1 - rs/moq-nvenc/src/sys/mod.rs | 4 +- rs/moq-nvenc/src/sys/version.rs | 4 +- rs/moq-pattern/Cargo.toml | 3 + rs/moq-quic/Cargo.toml | 13 +- rs/moq-quic/benches/common/mod.rs | 6 +- rs/moq-quic/benches/endpoint.rs | 5 +- rs/moq-quic/benches/receive.rs | 5 +- rs/moq-quic/benches/streams.rs | 5 +- rs/moq-quic/benches/wire.rs | 5 +- rs/moq-quic/fuzz/Cargo.toml | 3 + rs/moq-quic/src/config/mod.rs | 5 +- rs/moq-quic/src/congestion.rs | 43 ++++- rs/moq-quic/src/connection/packet_builder.rs | 4 + rs/moq-quic/src/connection/qlog.rs | 6 +- rs/moq-quic/src/connection/stats.rs | 5 +- rs/moq-quic/src/connection/streams/mod.rs | 2 - rs/moq-quic/src/endpoint.rs | 4 + rs/moq-quic/src/lib.rs | 21 ++- rs/moq-quic/src/packet.rs | 5 +- rs/moq-quic/src/range_set/btree_range_set.rs | 5 +- rs/moq-quic/src/token.rs | 5 +- rs/moq-quic/src/transport_error.rs | 2 +- rs/moq-quic/src/transport_parameters.rs | 5 +- rs/moq-relay/Cargo.toml | 3 + rs/moq-relay/src/cluster.rs | 2 +- rs/moq-relay/src/connection.rs | 5 +- rs/moq-relay/src/incoming.rs | 5 +- rs/moq-relay/src/relay.rs | 1 - rs/moq-relay/src/settings.rs | 5 +- rs/moq-relay/src/uring.rs | 3 - rs/moq-relay/src/web.rs | 10 +- rs/moq-relay/src/websocket.rs | 6 +- .../tests/integration/cluster_unknown.rs | 5 +- rs/moq-relay/tests/integration/refusals.rs | 5 +- .../tests/integration/session_revalidate.rs | 5 +- rs/moq-room/Cargo.toml | 3 + rs/moq-room/src/lib.rs | 2 - rs/moq-rtc/Cargo.toml | 3 + rs/moq-rtmp/Cargo.toml | 3 + rs/moq-rtmp/src/dial.rs | 2 +- rs/moq-rtmp/src/rml/mod.rs | 10 +- .../rml/test_utils/assert_vec_match_macro.rs | 2 +- rs/moq-rtmp/src/server.rs | 2 +- rs/moq-rtsp/Cargo.toml | 3 + rs/moq-shaper/Cargo.toml | 3 + rs/moq-sock/Cargo.toml | 3 + rs/moq-sock/src/udp/apple_fast.rs | 4 +- rs/moq-sock/src/udp/linux.rs | 5 +- rs/moq-sock/src/udp/mod.rs | 6 +- rs/moq-sock/src/udp/unix.rs | 25 +-- rs/moq-srt/Cargo.toml | 3 + rs/moq-stats/Cargo.toml | 3 + rs/moq-stats/benches/aggregate.rs | 6 +- rs/moq-stats/benches/decode.rs | 6 +- rs/moq-stats/benches/producer_tick.rs | 6 +- rs/moq-stats/src/aggregate.rs | 4 +- rs/moq-stats/src/lib.rs | 1 - rs/moq-stats/src/produce.rs | 2 +- rs/moq-tokio/Cargo.toml | 3 + rs/moq-tokio/src/client.rs | 4 +- rs/moq-tokio/src/crypto.rs | 2 +- rs/moq-tokio/src/error.rs | 16 +- rs/moq-tokio/src/quic.rs | 11 +- rs/moq-tokio/src/quic/driver/connection.rs | 1 - rs/moq-tokio/src/quic/web/client.rs | 5 +- rs/moq-tokio/src/quic/web/crypto.rs | 2 +- rs/moq-tokio/src/quic/web/session.rs | 11 +- rs/moq-tokio/src/quic/web/settings.rs | 8 +- rs/moq-tokio/src/server.rs | 16 +- rs/moq-tokio/src/settings.rs | 5 +- rs/moq-tokio/src/websocket.rs | 10 +- rs/moq-tokio/src/worker/group.rs | 1 - rs/moq-transcode/Cargo.toml | 3 + rs/moq-uring/Cargo.toml | 3 + rs/moq-uring/benches/echo_quic.rs | 6 +- rs/moq-uring/benches/session_lite.rs | 6 +- rs/moq-uring/benches/udp_tokio.rs | 6 +- rs/moq-uring/benches/udp_uring.rs | 6 +- rs/moq-uring/src/clock.rs | 6 +- rs/moq-uring/src/lib.rs | 9 +- rs/moq-uring/src/udp.rs | 10 +- rs/moq-uring/src/worker.rs | 12 +- rs/moq-uring/tests/integration/support.rs | 2 +- rs/moq-uring/tests/integration/web.rs | 8 +- rs/moq-v4l/Cargo.toml | 3 + rs/moq-v4l/src/buffer.rs | 2 - rs/moq-v4l/src/capability.rs | 1 - rs/moq-v4l/src/control.rs | 2 - rs/moq-v4l/src/format/description.rs | 1 - rs/moq-v4l/src/format/fourcc.rs | 1 - rs/moq-v4l/src/format/mod.rs | 1 - rs/moq-v4l/src/frameinterval.rs | 2 +- rs/moq-v4l/src/framesize.rs | 2 +- rs/moq-v4l/src/memory.rs | 1 - rs/moq-v4l/src/parameters.rs | 1 - rs/moq-v4l/src/sys/mod.rs | 8 +- rs/moq-v4l/src/v4l2/vidioc.rs | 4 +- rs/moq-video/Cargo.toml | 3 + rs/moq-video/src/capture/avfoundation.rs | 10 +- rs/moq-video/src/decode/conformance.rs | 5 +- rs/moq-video/src/decode/consumer.rs | 5 +- rs/moq-video/src/decode/decoder.rs | 5 +- .../src/encode/backend/mediafoundation.rs | 5 +- rs/moq-video/src/encode/backend/mod.rs | 20 ++- .../src/encode/backend/videotoolbox.rs | 5 +- rs/moq-video/src/encode/encoder.rs | 7 +- rs/moq-video/src/encode/mod.rs | 11 +- rs/moq-video/src/encode/producer.rs | 24 ++- rs/moq-video/src/frame.rs | 26 ++- rs/moq-video/src/frame/vulkan.rs | 15 +- rs/moq-wasm/Cargo.toml | 3 + rs/uniffi-bindgen/Cargo.toml | 3 + sh/rs/model-markers.py | 19 ++- sh/rs/model-markers.test.py | 4 + 238 files changed, 1317 insertions(+), 750 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 479044152d1..5ae3aa90a52 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -111,6 +111,14 @@ ignored = ["getrandom"] # That pin sits above every MSRV here; rust-toolchain.toml says why. rust-version = "1.91" +[workspace.lints.rust] +# kio and moq-net model-check their primitives under `--cfg loom`. +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(loom)'] } + +[workspace.lints.clippy] +# Every suppression says why, so the next lint audit can judge it. +allow_attributes_without_reason = "warn" + [workspace.dependencies] anyhow = "1" ash = "0.38" diff --git a/demo/carla/bridge/Cargo.toml b/demo/carla/bridge/Cargo.toml index 215417a62f0..8809275a994 100644 --- a/demo/carla/bridge/Cargo.toml +++ b/demo/carla/bridge/Cargo.toml @@ -35,3 +35,6 @@ tracing = { workspace = true } # The stand-in producer: a native Vulkan renderer that hands the bridge # exportable slots exactly the way the CARLA plugin does. ash = { workspace = true } + +[lints] +workspace = true diff --git a/rs/hang/Cargo.toml b/rs/hang/Cargo.toml index 5300c906ed2..a35fe3575e0 100644 --- a/rs/hang/Cargo.toml +++ b/rs/hang/Cargo.toml @@ -36,3 +36,6 @@ moq-tokio = { path = "../moq-tokio", default-features = false, features = ["quic tokio = { workspace = true, features = ["macros", "fs"] } tracing = { workspace = true } url = { workspace = true } + +[lints] +workspace = true diff --git a/rs/hang/src/catalog/root.rs b/rs/hang/src/catalog/root.rs index 4fc866506aa..be7dc6ad6a5 100644 --- a/rs/hang/src/catalog/root.rs +++ b/rs/hang/src/catalog/root.rs @@ -349,7 +349,10 @@ impl Catalog { /// /// Fails with [`Error::UnsupportedVersion`](crate::Error::UnsupportedVersion) if the catalog /// needs a newer moq-hang draft than this crate reads. - #[allow(clippy::should_implement_trait)] + #[expect( + clippy::should_implement_trait, + reason = "public inherent parser; switching to `FromStr` is a breaking change" + )] pub fn from_str(s: &str) -> Result { Self::from_slice(s.as_bytes()) } diff --git a/rs/kio/Cargo.toml b/rs/kio/Cargo.toml index 4acfc6e12fc..e77abfe02c4 100644 --- a/rs/kio/Cargo.toml +++ b/rs/kio/Cargo.toml @@ -47,5 +47,5 @@ harness = false name = "contended" harness = false -[lints.rust] -unexpected_cfgs = { level = "warn", check-cfg = ['cfg(loom)'] } +[lints] +workspace = true diff --git a/rs/kio/src/waiter.rs b/rs/kio/src/waiter.rs index 94776b90c50..28e0ddcc0e7 100644 --- a/rs/kio/src/waiter.rs +++ b/rs/kio/src/waiter.rs @@ -770,7 +770,7 @@ mod tests { #[test] fn wait_output_need_not_be_unpin() { - struct NotUnpin(#[allow(dead_code)] std::marker::PhantomPinned); + struct NotUnpin(#[allow(dead_code, reason = "only makes the type `!Unpin`")] std::marker::PhantomPinned); let mut fut = std::pin::pin!(crate::wait(|_| Poll::Ready(NotUnpin(std::marker::PhantomPinned)))); let mut cx = Context::from_waker(Waker::noop()); diff --git a/rs/libmoq/Cargo.toml b/rs/libmoq/Cargo.toml index e042c37f195..79dce540ac6 100644 --- a/rs/libmoq/Cargo.toml +++ b/rs/libmoq/Cargo.toml @@ -11,3 +11,6 @@ rust-version.workspace = true keywords = ["quic", "media", "live"] categories = ["multimedia", "network-programming"] + +[lints] +workspace = true diff --git a/rs/moq-archive/Cargo.toml b/rs/moq-archive/Cargo.toml index 3a9ad66bc6e..41213d6139e 100644 --- a/rs/moq-archive/Cargo.toml +++ b/rs/moq-archive/Cargo.toml @@ -43,3 +43,6 @@ tokio = { workspace = true, features = ["macros", "net", "rt", "test-util"] } [[bench]] name = "writer" harness = false + +[lints] +workspace = true diff --git a/rs/moq-archive/benches/writer.rs b/rs/moq-archive/benches/writer.rs index d342d9b7c1f..209aaa1c8db 100644 --- a/rs/moq-archive/benches/writer.rs +++ b/rs/moq-archive/benches/writer.rs @@ -1,5 +1,8 @@ -// Host time measures benchmark throughput. -#![allow(clippy::disallowed_methods, clippy::disallowed_types)] +#![expect( + clippy::disallowed_methods, + clippy::disallowed_types, + reason = "host time measures benchmark throughput" +)] //! `Writer::run` recording every enrolled track into memory, swept over the number of tracks and //! the groups each one publishes. Throughput is per frame, so a per-event cost that grows with the diff --git a/rs/moq-archive/src/lib.rs b/rs/moq-archive/src/lib.rs index 94ec612132b..374c7842068 100644 --- a/rs/moq-archive/src/lib.rs +++ b/rs/moq-archive/src/lib.rs @@ -24,7 +24,7 @@ pub mod info; mod mock; mod path; #[cfg(test)] -#[allow(clippy::disallowed_methods, clippy::disallowed_types)] +#[expect(clippy::disallowed_methods, reason = "tests read the host clock directly")] mod proof; pub mod reader; mod recover; diff --git a/rs/moq-archive/src/reader/mod.rs b/rs/moq-archive/src/reader/mod.rs index 8eed95d0f09..414106b4ea9 100644 --- a/rs/moq-archive/src/reader/mod.rs +++ b/rs/moq-archive/src/reader/mod.rs @@ -663,5 +663,9 @@ impl quick_cache::Weighter> for Weight { } #[cfg(test)] -#[allow(clippy::disallowed_methods, clippy::disallowed_types)] +#[expect( + clippy::disallowed_methods, + clippy::disallowed_types, + reason = "tests read the host clock directly" +)] mod tests; diff --git a/rs/moq-archive/src/writer.rs b/rs/moq-archive/src/writer.rs index 013d5cc8e62..f2a15c86c1c 100644 --- a/rs/moq-archive/src/writer.rs +++ b/rs/moq-archive/src/writer.rs @@ -641,8 +641,10 @@ impl Track { } } -// Each read is already boxed as a future, so the variant sizes cost nothing extra. -#[allow(clippy::large_enum_variant)] +#[expect( + clippy::large_enum_variant, + reason = "each read is already boxed as a future, so the variant sizes cost nothing extra" +)] enum Read { Group { name: String, @@ -1048,7 +1050,7 @@ fn recorded_end(resume: &Resume, timescale: Option) -> Result { /// Registered in the broadcast but not the catalog, because the rendition /// describes a PCM layout no probe has returned yet. @@ -735,7 +738,7 @@ pub async fn publish_capture( /// if the future ever regains a `!Send` component. macOS is exempt: the TCC /// prompt and ScreenCaptureKit both hold ObjC handles across an await. #[cfg(not(target_os = "macos"))] -#[allow(dead_code)] +#[allow(dead_code, reason = "a compile-time `Send` assertion, never called")] fn assert_publish_capture_send( broadcast: moq_net::broadcast::Producer, catalog: moq_mux::catalog::Producer, diff --git a/rs/moq-audio/src/playback/mixer.rs b/rs/moq-audio/src/playback/mixer.rs index 3341009d85f..fe5255b2361 100644 --- a/rs/moq-audio/src/playback/mixer.rs +++ b/rs/moq-audio/src/playback/mixer.rs @@ -133,7 +133,10 @@ pub(super) struct Entry { /// /// Nothing reads these payloads, which is the point: they exist so the driver /// thread is the one that drops them. -#[allow(dead_code)] +#[allow( + dead_code, + reason = "nothing reads the payloads; they exist so the driver thread drops them" +)] pub(super) enum Retired { /// A sink that was removed or rebuilt. Sink(Entry), diff --git a/rs/moq-auth/Cargo.toml b/rs/moq-auth/Cargo.toml index bcc3ec419f8..990e6809915 100644 --- a/rs/moq-auth/Cargo.toml +++ b/rs/moq-auth/Cargo.toml @@ -49,3 +49,6 @@ moq-token = "0.7" tempfile = { workspace = true } tokio = { workspace = true, features = ["macros", "rt-multi-thread", "test-util"] } wiremock = "0.6" + +[lints] +workspace = true diff --git a/rs/moq-auth/src/claims.rs b/rs/moq-auth/src/claims.rs index 2fff13a4b1d..ace22cf4a9a 100644 --- a/rs/moq-auth/src/claims.rs +++ b/rs/moq-auth/src/claims.rs @@ -243,7 +243,7 @@ impl Claims { } #[cfg(test)] -#[allow(clippy::disallowed_methods, clippy::disallowed_types)] +#[expect(clippy::disallowed_methods, reason = "tests read the host clock directly")] mod tests { use super::*; diff --git a/rs/moq-auth/src/client.rs b/rs/moq-auth/src/client.rs index ff2c5232cdc..7e046670e00 100644 --- a/rs/moq-auth/src/client.rs +++ b/rs/moq-auth/src/client.rs @@ -423,7 +423,11 @@ impl Driver { } #[cfg(test)] -#[allow(clippy::disallowed_methods, clippy::disallowed_types)] +#[expect( + clippy::disallowed_methods, + clippy::disallowed_types, + reason = "tests read the host clock directly" +)] mod tests { use super::*; use moq_pattern::Patterns; @@ -498,7 +502,10 @@ mod tests { struct Script { identity: Arc<()>, log: Log, - #[allow(clippy::type_complexity)] + #[expect( + clippy::type_complexity, + reason = "a one-off test responder; an alias would only move the type" + )] respond: std::sync::Arc Option> + Send + Sync>, } diff --git a/rs/moq-auth/src/key.rs b/rs/moq-auth/src/key.rs index a5a61c8d074..5f4ec8dab05 100644 --- a/rs/moq-auth/src/key.rs +++ b/rs/moq-auth/src/key.rs @@ -323,7 +323,10 @@ impl Key { } /// Parse a key from a string, auto-detecting JSON or base64url encoding. - #[allow(clippy::should_implement_trait)] + #[expect( + clippy::should_implement_trait, + reason = "public inherent parser; switching to `FromStr` is a breaking change" + )] pub fn from_str(s: &str) -> crate::Result { let s = s.trim(); if s.starts_with('{') { @@ -707,7 +710,7 @@ where } #[cfg(test)] -#[allow(clippy::disallowed_methods, clippy::disallowed_types)] +#[expect(clippy::disallowed_methods, reason = "tests read the host clock directly")] mod tests { use super::*; diff --git a/rs/moq-auth/src/lease.rs b/rs/moq-auth/src/lease.rs index 96127c501e3..a2b0d47bd37 100644 --- a/rs/moq-auth/src/lease.rs +++ b/rs/moq-auth/src/lease.rs @@ -434,7 +434,7 @@ fn ready_if(condition: bool) -> Poll<()> { } #[cfg(test)] -#[allow(clippy::disallowed_methods, clippy::disallowed_types)] +#[expect(clippy::disallowed_methods, reason = "tests read the host clock directly")] mod tests { use super::*; use std::future::Future; diff --git a/rs/moq-auth/src/serve.rs b/rs/moq-auth/src/serve.rs index b007f594d46..965b82f3071 100644 --- a/rs/moq-auth/src/serve.rs +++ b/rs/moq-auth/src/serve.rs @@ -517,7 +517,7 @@ async fn handle(State(server): State, Json(request): Json) -> R } #[cfg(test)] -#[allow(clippy::disallowed_methods, clippy::disallowed_types)] +#[expect(clippy::disallowed_methods, reason = "tests read the host clock directly")] mod tests { use super::*; use crate::{Algorithm, Bytes, Claims, Client, Error, Peer, Transport, lease::Reason}; diff --git a/rs/moq-auth/src/set.rs b/rs/moq-auth/src/set.rs index 39b3ed85bcb..9c16fa61576 100644 --- a/rs/moq-auth/src/set.rs +++ b/rs/moq-auth/src/set.rs @@ -45,7 +45,10 @@ impl<'de> Deserialize<'de> for KeySet { impl KeySet { /// Parse a set from a JSON string. - #[allow(clippy::should_implement_trait)] + #[expect( + clippy::should_implement_trait, + reason = "public inherent parser; switching to `FromStr` is a breaking change" + )] pub fn from_str(s: &str) -> crate::Result { Ok(serde_json::from_str(s)?) } @@ -133,7 +136,7 @@ impl KeySet { } #[cfg(test)] -#[allow(clippy::disallowed_methods, clippy::disallowed_types)] +#[expect(clippy::disallowed_methods, reason = "tests read the host clock directly")] mod tests { use super::*; diff --git a/rs/moq-bench/Cargo.toml b/rs/moq-bench/Cargo.toml index 7239d2ddcb2..c73be94389c 100644 --- a/rs/moq-bench/Cargo.toml +++ b/rs/moq-bench/Cargo.toml @@ -62,3 +62,6 @@ procfs = "0.18" [dev-dependencies] # test-util enables tokio::time::pause/advance for the deterministic produce tests. tokio = { workspace = true, features = ["test-util"] } + +[lints] +workspace = true diff --git a/rs/moq-bench/src/config.rs b/rs/moq-bench/src/config.rs index cae111ea1e7..a4f68c4101b 100644 --- a/rs/moq-bench/src/config.rs +++ b/rs/moq-bench/src/config.rs @@ -322,7 +322,10 @@ impl Config { } } -#[allow(dead_code)] +#[allow( + dead_code, + reason = "declares the settings for the usage registry; nothing reads the fields" +)] #[derive(usage_rs::Config)] struct Settings { #[usage(env = "MOQ_BENCH_NAME", cli("--name"))] diff --git a/rs/moq-boy/Cargo.toml b/rs/moq-boy/Cargo.toml index 3ae442fc20f..d465f7d5a68 100644 --- a/rs/moq-boy/Cargo.toml +++ b/rs/moq-boy/Cargo.toml @@ -43,3 +43,6 @@ usage-rs = { workspace = true, features = ["completions", "config"] } [dev-dependencies] tokio = { workspace = true, features = ["test-util"] } + +[lints] +workspace = true diff --git a/rs/moq-c/Cargo.toml b/rs/moq-c/Cargo.toml index e8396a7c3fb..e049c5e8a3f 100644 --- a/rs/moq-c/Cargo.toml +++ b/rs/moq-c/Cargo.toml @@ -54,3 +54,6 @@ moq-loc = { path = "../moq-loc" } # turn it on without the `openh264` feature. moq-video = { path = "../moq-video", features = ["openh264"] } tokio = { workspace = true, features = ["test-util"] } + +[lints] +workspace = true diff --git a/rs/moq-c/src/api.rs b/rs/moq-c/src/api.rs index 74c55fa2952..a592062c6fc 100644 --- a/rs/moq-c/src/api.rs +++ b/rs/moq-c/src/api.rs @@ -12,7 +12,7 @@ use tracing::Level; /// The ABI carries this as a `uint32_t`, so an unknown discriminant from C is an /// error rather than UB. #[repr(C)] -#[allow(non_camel_case_types)] +#[expect(non_camel_case_types, reason = "C ABI type names match moq.h")] #[derive(Clone, Copy, Debug)] pub enum moq_container_kind { /// A QUIC varint timestamp prefix followed by the raw codec payload. @@ -35,7 +35,6 @@ pub enum moq_container_kind { /// Zeroing this struct means `MOQ_CONTAINER_KIND_LEGACY` with no init segment, /// which is what a rendition written by [moq_publish_audio] or [moq_publish_video] carries. #[repr(C)] -#[allow(non_camel_case_types)] #[derive(Clone, Copy)] pub struct moq_container { /// `moq_container_kind` discriminant. @@ -104,7 +103,7 @@ pub(crate) fn borrow_container(container: &hang::catalog::Container) -> moq_cont /// A single audio codec [moq_publish_audio] can parse. #[repr(C)] -#[allow(non_camel_case_types)] +#[expect(non_camel_case_types, reason = "C ABI type names match moq.h")] #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum moq_audio_format { /// Advanced Audio Coding, configured by an AudioSpecificConfig. @@ -123,7 +122,7 @@ pub enum moq_audio_format { /// codec: AVC1/HVC1 are length-prefixed with an out-of-band config record, /// while AVC3/HEV1 are Annex-B with the parameter sets inline. #[repr(C)] -#[allow(non_camel_case_types)] +#[expect(non_camel_case_types, reason = "C ABI type names match moq.h")] #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum moq_video_format { /// H.264, length-prefixed NALUs with an out-of-band avcC. @@ -144,7 +143,7 @@ pub enum moq_video_format { /// A container [moq_publish_container] can demux, which may publish several tracks. #[repr(C)] -#[allow(non_camel_case_types)] +#[expect(non_camel_case_types, reason = "C ABI type names match moq.h")] #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum moq_container_format { /// Fragmented MP4 / CMAF. @@ -162,7 +161,6 @@ pub enum moq_container_format { /// Zero the struct, then set `format` and the required `init` bytes. New /// optional fields are appended so existing initializers keep their meaning. #[repr(C)] -#[allow(non_camel_case_types)] pub struct moq_audio_init { /// The audio codec, a [moq_audio_format] value. pub format: u32, @@ -184,7 +182,6 @@ pub struct moq_audio_init { /// Zero the struct, then set `format` and whatever else the codec needs. `init` /// may stay NULL for a format that resolves in band. #[repr(C)] -#[allow(non_camel_case_types)] pub struct moq_video_init { /// The video codec, a [moq_video_format] value. pub format: u32, @@ -210,7 +207,6 @@ pub struct moq_video_init { /// bitstream leaves (especially bitrate); a value the stream detects later wins /// for dimensions. #[repr(C)] -#[allow(non_camel_case_types)] #[derive(Clone, Copy, Default)] pub struct moq_video_hint { /// Encoded width in pixels when `has_coded` is true. @@ -262,7 +258,6 @@ impl moq_video_hint { /// There is no label here: a container publishes and describes its own tracks, /// so a rendition name would have no single track to land on. #[repr(C)] -#[allow(non_camel_case_types)] pub struct moq_container_init { /// The container format, a [moq_container_format] value. pub format: u32, @@ -317,7 +312,6 @@ fn container_format_from_u32(value: u32) -> Result for moq_net::track::Info { /// the terminal statuses every callback shares. [moq_publish_demand_wanted] reads which /// group the subscribers want. #[repr(C)] -#[allow(non_camel_case_types)] +#[expect(non_camel_case_types, reason = "C ABI type names match moq.h")] #[derive(Clone, Copy, Debug)] pub enum moq_demand { /// At least one subscriber is active. Repeats when the wanted group moves. @@ -577,7 +562,6 @@ pub enum moq_demand { /// A null [moq_consume_track] or [moq_consume_track_update] `subscription` /// pointer uses the moq-net defaults, and so does a zeroed struct. #[repr(C)] -#[allow(non_camel_case_types)] pub struct moq_subscription { /// Delivery priority. Higher values preempt lower ones under contention. pub priority: u8, @@ -604,7 +588,6 @@ pub struct moq_subscription { /// A relative or time start is the first frame of its group, and a relative or time end /// includes its whole group. An absolute end is exclusive. #[repr(C)] -#[allow(non_camel_case_types)] #[derive(Clone, Copy)] pub struct moq_range { /// Where delivery starts. @@ -617,7 +600,6 @@ pub struct moq_range { /// Where one end of a [moq_range] falls. Zeroing it means group 0, frame 0. #[repr(C)] -#[allow(non_camel_case_types)] #[derive(Clone, Copy)] pub struct moq_anchor { /// `moq_anchor_kind` discriminant. @@ -633,7 +615,7 @@ pub struct moq_anchor { /// How a [moq_anchor] names its position. #[repr(C)] -#[allow(non_camel_case_types)] +#[expect(non_camel_case_types, reason = "C ABI type names match moq.h")] #[derive(Clone, Copy, Debug)] pub enum moq_anchor_kind { /// A fixed group and frame. @@ -646,7 +628,7 @@ pub enum moq_anchor_kind { /// Which of a subscription's pending groups the publisher sends first. Zero is the default. #[repr(C)] -#[allow(non_camel_case_types)] +#[expect(non_camel_case_types, reason = "C ABI type names match moq.h")] #[derive(Clone, Copy, Debug)] pub enum moq_order { /// Newest first, so congestion sheds the backlog rather than the live edge. @@ -709,7 +691,6 @@ pub(crate) unsafe fn parse_subscription( /// [moq_client_config] list) the pointer borrows the caller's storage and is only read /// during the call. #[repr(C)] -#[allow(non_camel_case_types)] #[derive(Clone, Copy)] pub struct moq_string { /// Pointer to `len` bytes of UTF-8, NOT NULL terminated. @@ -724,7 +705,6 @@ pub struct moq_string { /// [moq_consume_catalog_free]. `json` is the section's value serialized as JSON /// (parse it yourself); a top-level catalog key beyond `video`/`audio`. #[repr(C)] -#[allow(non_camel_case_types)] pub struct moq_section { /// The section name, NOT NULL terminated. pub name: *const c_char, @@ -743,7 +723,6 @@ pub struct moq_section { /// /// `cost` is the static production and link price; lower wins. #[repr(C)] -#[allow(non_camel_case_types)] #[derive(Clone, Copy)] pub struct moq_route { /// Hop ids, oldest first. NULL when `hops_len` is 0. 0 is the anonymous @@ -799,7 +778,6 @@ unsafe fn parse_route(route: *const moq_route) -> Result u64 { /// New settings are appended to the end of this struct, and a zeroed one keeps /// the previous behavior, so adding one does not disturb existing callers. #[repr(C)] -#[allow(non_camel_case_types)] pub struct moq_client_config { /// Protocol versions to offer during the handshake, most preferred first. /// NULL/0 offers everything this build supports. Names are spelled the way @@ -1439,7 +1413,6 @@ pub extern "C" fn moq_session_failure(session: u32) -> i32 { /// one keeps the previous behavior. TLS is required: set `tls_cert` and `tls_key`, /// or `tls_generate`. #[repr(C)] -#[allow(non_camel_case_types)] pub struct moq_server_config { /// Address to bind, e.g. `[::]:443`, `127.0.0.1:0`, or `localhost:4443`; NULL /// for `[::]:443`. A port of 0 picks one; read it back with [moq_server_addr]. diff --git a/rs/moq-c/src/audio.rs b/rs/moq-c/src/audio.rs index 89b004f34e7..dfbee4c6042 100644 --- a/rs/moq-c/src/audio.rs +++ b/rs/moq-c/src/audio.rs @@ -33,7 +33,7 @@ use crate::{Error, Id, NonZeroSlab, Shared, State, ffi}; /// /// #[repr(C)] -#[allow(non_camel_case_types)] +#[expect(non_camel_case_types, reason = "C ABI type names match moq.h")] #[derive(Clone, Copy, Debug)] pub enum moq_audio_sample_format { MOQ_AUDIO_SAMPLE_FORMAT_U8 = 0, @@ -63,7 +63,6 @@ fn audio_format_from_u32(value: u32) -> Result { /// PCM layout the caller hands to [`moq_encode_audio_frame`]. #[repr(C)] -#[allow(non_camel_case_types)] pub struct moq_audio_encoder_input { /// `moq_audio_sample_format` discriminant. pub format: u32, @@ -78,7 +77,6 @@ pub struct moq_audio_encoder_input { /// "match the input (snapping the rate up to a libopus-supported /// value if necessary)". #[repr(C)] -#[allow(non_camel_case_types)] pub struct moq_audio_encoder_output { /// Codec id, UTF-8: "opus", "pcm", or "aac". AAC encodes through the /// platform's encoder, so a host without one refuses it. @@ -98,7 +96,6 @@ pub struct moq_audio_encoder_output { /// PCM layout the caller wants out of [`moq_decode_audio`]. #[repr(C)] -#[allow(non_camel_case_types)] pub struct moq_audio_decoder_output { pub format: u32, /// 0 = deliver at the codec's native sample rate. @@ -123,7 +120,6 @@ pub struct moq_audio_decoder_output { /// [`moq_decode_audio_frame_free`]) or borrowed by the publish call /// (the publisher copies before returning). #[repr(C)] -#[allow(non_camel_case_types)] pub struct moq_audio_frame { pub timestamp_us: u64, pub data: *const u8, diff --git a/rs/moq-c/src/error.rs b/rs/moq-c/src/error.rs index 4b6c8d4c4f0..96c74356e6d 100644 --- a/rs/moq-c/src/error.rs +++ b/rs/moq-c/src/error.rs @@ -46,7 +46,7 @@ pub const MOQ_ERROR_UNSUPPORTED_CATALOG: i32 = -43; /// Whether a protocol code is from the session or stream registry. #[repr(C)] -#[allow(non_camel_case_types)] +#[expect(non_camel_case_types, reason = "C ABI type names match moq.h")] #[derive(Clone, Copy, Debug)] pub enum moq_error_scope { /// A session close code. @@ -58,7 +58,7 @@ pub enum moq_error_scope { /// A recognized protocol kind. Pair with [`moq_error_scope`]: `CANCEL` is 0 on a session /// and 1 on a stream. `APP` and `UNKNOWN` keep the numeric code in [`moq_protocol_error`]. #[repr(C)] -#[allow(non_camel_case_types)] +#[expect(non_camel_case_types, reason = "C ABI type names match moq.h")] #[derive(Clone, Copy, Debug)] pub enum moq_protocol_kind { /// Cancel. @@ -117,7 +117,6 @@ pub enum moq_protocol_kind { /// Filled by [`crate::moq_error_protocol`] after a call returned a negative code. Do not parse /// [`crate::moq_error`] for this; that string is diagnostics only. #[repr(C)] -#[allow(non_camel_case_types)] #[derive(Clone, Copy, Debug)] pub struct moq_protocol_error { /// [`moq_error_scope`] discriminant. diff --git a/rs/moq-c/src/ffi.rs b/rs/moq-c/src/ffi.rs index bc90777c4b7..bd0f63ab4cb 100644 --- a/rs/moq-c/src/ffi.rs +++ b/rs/moq-c/src/ffi.rs @@ -9,7 +9,7 @@ use url::Url; use crate::{Error, Id, moq_protocol_error}; /// A callback receiving a positive handle/value, zero on clean completion, or a negative error. -#[allow(non_camel_case_types)] +#[expect(non_camel_case_types, reason = "C ABI type names match moq.h")] pub type moq_status_callback = Option; pub static RUNTIME: LazyLock = LazyLock::new(|| { diff --git a/rs/moq-c/src/test.rs b/rs/moq-c/src/test.rs index b270deb4f76..21c7e433947 100644 --- a/rs/moq-c/src/test.rs +++ b/rs/moq-c/src/test.rs @@ -5911,7 +5911,10 @@ async fn a_background_panic_reaches_the_terminal_callback_and_keeps_another_orig let task = crate::ffi::RUNTIME.spawn(async move { let result = crate::ffi::run(async { panic!("injected background panic"); - #[allow(unreachable_code)] + #[expect( + unreachable_code, + reason = "the panic is the point; the `Ok` names the future's output type" + )] Ok::<(), Error>(()) }) .await; diff --git a/rs/moq-c/src/video.rs b/rs/moq-c/src/video.rs index 7d09c680796..6cd8ae28ad3 100644 --- a/rs/moq-c/src/video.rs +++ b/rs/moq-c/src/video.rs @@ -31,7 +31,7 @@ use crate::{Error, Id, NonZeroSlab, Shared, State, ffi}; /// carry it are typed `u32`. A C caller passing an unknown discriminant gets /// `Error::InvalidCode` instead of UB. #[repr(C)] -#[allow(non_camel_case_types)] +#[expect(non_camel_case_types, reason = "C ABI type names match moq.h")] #[derive(Clone, Copy, Debug)] pub enum moq_video_pixel_format { /// Tightly-packed planar I420: Y, then U, then V, no row padding. @@ -47,7 +47,7 @@ pub enum moq_video_pixel_format { /// Not every codec has a backend on every machine: H.265 is hardware-only, so /// publishing it fails where no hardware encoder is available. #[repr(C)] -#[allow(non_camel_case_types)] +#[expect(non_camel_case_types, reason = "C ABI type names match moq.h")] #[derive(Clone, Copy, Debug)] pub enum moq_video_codec { /// H.264 / AVC, published as an `avc3` track. @@ -58,7 +58,7 @@ pub enum moq_video_codec { /// Which encoder implementation [`moq_encode_video`] should use. #[repr(C)] -#[allow(non_camel_case_types)] +#[expect(non_camel_case_types, reason = "C ABI type names match moq.h")] #[derive(Clone, Copy, Debug)] pub enum moq_video_encoder_kind { /// Prefer a platform hardware encoder, falling back to software. @@ -75,7 +75,6 @@ pub enum moq_video_encoder_kind { /// the resolution and rate the encoder is opened at. Every published frame must /// match `width` x `height`; scale before publishing if your source moves. #[repr(C)] -#[allow(non_camel_case_types)] pub struct moq_video_encoder_input { /// `moq_video_pixel_format` discriminant. pub format: u32, @@ -91,7 +90,6 @@ pub struct moq_video_encoder_input { /// Codec-side configuration for [`moq_encode_video`]. Every knob spells /// "unset" as 0. #[repr(C)] -#[allow(non_camel_case_types)] pub struct moq_video_encoder_output { /// `moq_video_codec` discriminant. pub codec: u32, @@ -117,7 +115,6 @@ pub struct moq_video_encoder_output { /// returning). The decode side has its own [`moq_video_frame`], which does carry /// dimensions, since there they are what the stream turned out to be. #[repr(C)] -#[allow(non_camel_case_types)] pub struct moq_video_encoder_frame { /// Presentation timestamp, in microseconds. pub timestamp_us: u64, @@ -136,7 +133,6 @@ pub struct moq_video_encoder_frame { /// field changes its layout, so rebuild callers against the `moq.h` that ships /// with the `libmoq.a` they link. #[repr(C)] -#[allow(non_camel_case_types)] pub struct moq_video_decoder_output { /// Upper bound on buffering before skipping a stalled group, in /// microseconds. Same congestion-control knob as @@ -167,7 +163,6 @@ pub struct moq_video_decoder_output { /// The publish side has its own [`moq_video_encoder_frame`], which carries no /// dimensions because the encoder already fixed them. #[repr(C)] -#[allow(non_camel_case_types)] pub struct moq_video_frame { pub timestamp_us: u64, pub width: u32, diff --git a/rs/moq-cli/Cargo.toml b/rs/moq-cli/Cargo.toml index 0abb35dde87..fa5e41e3562 100644 --- a/rs/moq-cli/Cargo.toml +++ b/rs/moq-cli/Cargo.toml @@ -178,3 +178,6 @@ harness = false [[example]] name = "interop-tail" path = "../../test/interop/clients/rust/tail.rs" + +[lints] +workspace = true diff --git a/rs/moq-cli/benches/play_buffer.rs b/rs/moq-cli/benches/play_buffer.rs index 758c6ea8276..b7643b0b3e1 100644 --- a/rs/moq-cli/benches/play_buffer.rs +++ b/rs/moq-cli/benches/play_buffer.rs @@ -1,7 +1,10 @@ //! Encoded retention cost and peak memory, swept over delay and bitrate. //! Run with `cargo bench -p moq-cli --bench play_buffer`. -#[allow(dead_code)] +#[allow( + dead_code, + reason = "the bench compiles the private module from source and uses only part of it" +)] #[path = "../src/play/buffer.rs"] mod buffer; diff --git a/rs/moq-cli/src/args.rs b/rs/moq-cli/src/args.rs index f64ac22a7b9..fed9db85a52 100644 --- a/rs/moq-cli/src/args.rs +++ b/rs/moq-cli/src/args.rs @@ -124,7 +124,7 @@ pub struct ParseError { impl ParseError { /// The broad failure category. - #[cfg_attr(not(test), allow(dead_code))] + #[cfg_attr(not(test), allow(dead_code, reason = "only tests use it"))] pub fn kind(&self) -> ParseErrorKind { self.kind } diff --git a/rs/moq-cli/src/play/mod.rs b/rs/moq-cli/src/play/mod.rs index f1ddf5e22ff..acf91e4a78b 100644 --- a/rs/moq-cli/src/play/mod.rs +++ b/rs/moq-cli/src/play/mod.rs @@ -10,9 +10,13 @@ //! recorder (`fake`), and `just rs play` runs those on every PR that reaches //! this crate. -// With `play` off the event loop is gone and nothing calls the modules below. -// They are still compiled and tested, which is the point. -#![cfg_attr(not(feature = "play"), allow(dead_code))] +#![cfg_attr( + not(feature = "play"), + allow( + dead_code, + reason = "with `play` off the event loop is gone and nothing calls the modules below. They are still compiled and tested, which is the point" + ) +)] mod args; mod buffer; diff --git a/rs/moq-cli/src/publish.rs b/rs/moq-cli/src/publish.rs index 8c37632f784..8e74889264f 100644 --- a/rs/moq-cli/src/publish.rs +++ b/rs/moq-cli/src/publish.rs @@ -272,9 +272,13 @@ fn ts_import( Ok((import, catalog)) } -// Exactly one Source exists per process, so the size gap between the small -// Stream variant and the larger Capture config is irrelevant. -#[allow(clippy::large_enum_variant)] +#[cfg_attr( + feature = "capture", + expect( + clippy::large_enum_variant, + reason = "exactly one Source exists per process, so the gap between Stream and the larger Capture config is irrelevant" + ) +)] enum Source { /// Decode a container read from stdin. Stream { @@ -1028,7 +1032,13 @@ pub(crate) mod tests { broadcast.announce(Default::default()).unwrap(); settle().await; let mut publish = Publish::new(broadcast, &PublishFormat::Ts { program: None }, Default::default()).unwrap(); - #[allow(irrefutable_let_patterns)] + #[cfg_attr( + not(feature = "capture"), + expect( + irrefutable_let_patterns, + reason = "`Source::Capture` exists only with the capture feature" + ) + )] let Source::Stream { decoder, .. } = &mut publish.source else { panic!("expected a stream source"); }; @@ -1105,7 +1115,13 @@ pub(crate) mod tests { Default::default(), ) .unwrap(); - #[allow(irrefutable_let_patterns)] + #[cfg_attr( + not(feature = "capture"), + expect( + irrefutable_let_patterns, + reason = "`Source::Capture` exists only with the capture feature" + ) + )] let Source::Stream { decoder, .. } = &mut publish.source else { panic!("expected a stream source"); }; @@ -1213,7 +1229,13 @@ pub(crate) mod tests { Default::default(), ) .unwrap(); - #[allow(irrefutable_let_patterns)] + #[cfg_attr( + not(feature = "capture"), + expect( + irrefutable_let_patterns, + reason = "`Source::Capture` exists only with the capture feature" + ) + )] let Source::Stream { decoder, .. } = &mut publish.source else { panic!("expected a stream source"); }; @@ -1362,7 +1384,13 @@ pub(crate) mod tests { let broadcast = moq_net::broadcast::Info::new().produce(); let consumer = broadcast.consume(); let mut publish = Publish::new(broadcast, &PublishFormat::Ts { program: None }, Default::default()).unwrap(); - #[allow(irrefutable_let_patterns)] + #[cfg_attr( + not(feature = "capture"), + expect( + irrefutable_let_patterns, + reason = "`Source::Capture` exists only with the capture feature" + ) + )] let Source::Stream { decoder, .. } = &mut publish.source else { panic!("expected a stream source"); }; @@ -1420,7 +1448,13 @@ pub(crate) mod tests { let broadcast = moq_net::broadcast::Info::new().produce(); let publish = Publish::new(broadcast, &PublishFormat::Ts { program: None }, Default::default()).unwrap(); - #[allow(irrefutable_let_patterns)] + #[cfg_attr( + not(feature = "capture"), + expect( + irrefutable_let_patterns, + reason = "`Source::Capture` exists only with the capture feature" + ) + )] let Source::Stream { decoder, catalog } = publish.source else { panic!("expected a stream source"); }; @@ -1456,7 +1490,13 @@ pub(crate) mod tests { let input = tokio::fs::File::open(file.path()).await.unwrap(); let broadcast = moq_net::broadcast::Info::new().produce(); let publish = Publish::new(broadcast, &PublishFormat::Ts { program: None }, Default::default()).unwrap(); - #[allow(irrefutable_let_patterns)] + #[cfg_attr( + not(feature = "capture"), + expect( + irrefutable_let_patterns, + reason = "`Source::Capture` exists only with the capture feature" + ) + )] let Source::Stream { decoder, catalog } = publish.source else { panic!("expected a stream source"); }; @@ -1480,7 +1520,13 @@ pub(crate) mod tests { let publish = Publish::new(broadcast, &PublishFormat::Ts { program: None }, Default::default()).unwrap(); let mut catalogs = hang::catalog::Catalog::<()>::subscribe(&consumer).await.unwrap(); - #[allow(irrefutable_let_patterns)] + #[cfg_attr( + not(feature = "capture"), + expect( + irrefutable_let_patterns, + reason = "`Source::Capture` exists only with the capture feature" + ) + )] let Source::Stream { decoder, catalog } = publish.source else { panic!("expected a stream source"); }; @@ -1512,7 +1558,13 @@ pub(crate) mod tests { let publish = Publish::new(broadcast, &PublishFormat::Ts { program: None }, Default::default()).unwrap(); let mut catalogs = hang::catalog::Catalog::<()>::subscribe(&consumer).await.unwrap(); - #[allow(irrefutable_let_patterns)] + #[cfg_attr( + not(feature = "capture"), + expect( + irrefutable_let_patterns, + reason = "`Source::Capture` exists only with the capture feature" + ) + )] let Source::Stream { decoder, catalog } = publish.source else { panic!("expected a stream source"); }; @@ -1564,7 +1616,13 @@ pub(crate) mod tests { let mut announced = consumer.announced(); let broadcast = origin.create_broadcast("demo").unwrap(); let publish = Publish::new(broadcast.clone(), &format, Default::default()).unwrap(); - #[allow(irrefutable_let_patterns)] + #[cfg_attr( + not(feature = "capture"), + expect( + irrefutable_let_patterns, + reason = "`Source::Capture` exists only with the capture feature" + ) + )] let Source::Stream { decoder, catalog } = publish.source else { panic!("expected a stream source"); }; @@ -1631,7 +1689,13 @@ pub(crate) mod tests { .subscribe(None) .await .unwrap(); - #[allow(irrefutable_let_patterns)] + #[cfg_attr( + not(feature = "capture"), + expect( + irrefutable_let_patterns, + reason = "`Source::Capture` exists only with the capture feature" + ) + )] let Source::Stream { decoder, catalog } = publish.source else { panic!("stream source"); }; @@ -1660,7 +1724,13 @@ pub(crate) mod tests { let mut announced = origin.consume().announced(); let broadcast = origin.create_broadcast("demo").unwrap(); let publish = Publish::new(broadcast.clone(), &format, Default::default()).unwrap(); - #[allow(irrefutable_let_patterns)] + #[cfg_attr( + not(feature = "capture"), + expect( + irrefutable_let_patterns, + reason = "`Source::Capture` exists only with the capture feature" + ) + )] let Source::Stream { decoder, catalog } = publish.source else { panic!("expected a stream source"); }; @@ -1773,7 +1843,13 @@ pub(crate) mod tests { fn a_multiplex_is_refused_with_the_programs_and_the_flag() { let broadcast = moq_net::broadcast::Info::new().produce(); let mut publish = Publish::new(broadcast, &PublishFormat::Ts { program: None }, Default::default()).unwrap(); - #[allow(irrefutable_let_patterns)] + #[cfg_attr( + not(feature = "capture"), + expect( + irrefutable_let_patterns, + reason = "`Source::Capture` exists only with the capture feature" + ) + )] let Source::Stream { decoder, .. } = &mut publish.source else { panic!("expected a stream source"); }; diff --git a/rs/moq-clock/Cargo.toml b/rs/moq-clock/Cargo.toml index bcb9d8f629d..00c795cb3d1 100644 --- a/rs/moq-clock/Cargo.toml +++ b/rs/moq-clock/Cargo.toml @@ -58,3 +58,6 @@ wasm-bindgen-test = "=0.3.79" # Test the installed manual clock, which needs tokio's runtime and so is native only. moq-clock = { path = ".", default-features = false, features = ["manual", "sim"] } tokio = { workspace = true, features = ["rt", "rt-multi-thread", "test-util", "time"] } + +[lints] +workspace = true diff --git a/rs/moq-clock/macros/Cargo.toml b/rs/moq-clock/macros/Cargo.toml index f5d01f2a94a..6af8280d5ce 100644 --- a/rs/moq-clock/macros/Cargo.toml +++ b/rs/moq-clock/macros/Cargo.toml @@ -16,3 +16,6 @@ categories = ["development-tools::testing"] [lib] proc-macro = true + +[lints] +workspace = true diff --git a/rs/moq-clock/src/installed.rs b/rs/moq-clock/src/installed.rs index 634ee7c08f2..de7730c01aa 100644 --- a/rs/moq-clock/src/installed.rs +++ b/rs/moq-clock/src/installed.rs @@ -231,7 +231,10 @@ mod tests { assert!(poll_once(&mut sleep).is_pending()); // Idle on tokio's paused clock for an hour: the installed clock stays put. - #[allow(clippy::disallowed_methods)] + #[expect( + clippy::disallowed_methods, + reason = "the test idles on tokio's clock, not the installed one" + )] tokio::time::sleep(Duration::from_secs(3_600)).await; assert_eq!(crate::now(), start); assert!(poll_once(&mut sleep).is_pending()); diff --git a/rs/moq-clock/src/runtime.rs b/rs/moq-clock/src/runtime.rs index 46f90574fce..63169598bbc 100644 --- a/rs/moq-clock/src/runtime.rs +++ b/rs/moq-clock/src/runtime.rs @@ -4,7 +4,10 @@ //! //! Without the `runtime` feature there are no timers, and reads fall back to std, //! except in the browser, where std has no clock and `web_async::time` still reads. -#![allow(clippy::disallowed_methods)] +#![cfg_attr( + not(target_arch = "wasm32"), + expect(clippy::disallowed_methods, reason = "this backend is where the host clock is read") +)] #[cfg(feature = "runtime")] use std::{future::Future, pin::Pin}; diff --git a/rs/moq-e2ee/Cargo.toml b/rs/moq-e2ee/Cargo.toml index 7a33cb7d5d2..f3cb7a08338 100644 --- a/rs/moq-e2ee/Cargo.toml +++ b/rs/moq-e2ee/Cargo.toml @@ -30,3 +30,6 @@ tokio = { workspace = true, features = ["macros", "rt", "sync", "time"] } [[bench]] name = "protect" harness = false + +[lints] +workspace = true diff --git a/rs/moq-e2ee/tests/support/harness.rs b/rs/moq-e2ee/tests/support/harness.rs index 71844103988..055a811e69c 100644 --- a/rs/moq-e2ee/tests/support/harness.rs +++ b/rs/moq-e2ee/tests/support/harness.rs @@ -5,7 +5,7 @@ //! over a [`moq_net::transport::memory`] pair and spawns both protocol drivers, giving tests //! two live sessions ready for pub/sub without any real QUIC or network I/O. -#![allow(dead_code)] +#![allow(dead_code, reason = "shared by several test binaries, each using only part of it")] use moq_net::{Client, Server, Session, Version, origin}; diff --git a/rs/moq-ffi/Cargo.toml b/rs/moq-ffi/Cargo.toml index ce92509f6a6..eaadf5ea4a9 100644 --- a/rs/moq-ffi/Cargo.toml +++ b/rs/moq-ffi/Cargo.toml @@ -104,3 +104,6 @@ moq-video = { path = "../moq-video", features = ["openh264"] } [target.'cfg(unix)'.dev-dependencies] # Process CPU time for the benchmark's baselines. libc = { workspace = true } + +[lints] +workspace = true diff --git a/rs/moq-ffi/src/android.rs b/rs/moq-ffi/src/android.rs index 7f5a836d02a..f5948a0b6f7 100644 --- a/rs/moq-ffi/src/android.rs +++ b/rs/moq-ffi/src/android.rs @@ -14,7 +14,7 @@ use moq_tokio::jni::{Env, JavaVM, jni_sig, jni_str}; /// Called by the JVM on `System.loadLibrary("moq_ffi")`. The name is fixed by /// the JNI spec, so it can't follow Rust's snake_case convention. #[unsafe(no_mangle)] -#[allow(non_snake_case)] +#[expect(non_snake_case, reason = "the JNI spec names this symbol")] pub extern "system" fn JNI_OnLoad(vm: *mut sys::JavaVM, _reserved: *mut c_void) -> jint { // SAFETY: per the JNI spec the JVM hands `JNI_OnLoad` a valid `JavaVM` pointer. let vm = unsafe { JavaVM::from_raw(vm) }; diff --git a/rs/moq-ffi/src/ffi.rs b/rs/moq-ffi/src/ffi.rs index fc20b92ca1e..ee4b2208253 100644 --- a/rs/moq-ffi/src/ffi.rs +++ b/rs/moq-ffi/src/ffi.rs @@ -80,7 +80,13 @@ pub(crate) fn test_clock() -> Option<&'static moq_clock::Installed> { #[cfg(not(target_arch = "wasm32"))] impl Runtime { - fn new(#[cfg_attr(not(feature = "testing"), allow(unused_variables))] test_clock: bool) -> Self { + fn new( + #[cfg_attr( + not(feature = "testing"), + allow(unused_variables, reason = "only the `testing` feature uses it") + )] + test_clock: bool, + ) -> Self { let runtime = tokio::runtime::Builder::new_multi_thread() .thread_name("moq-ffi-worker") .enable_all() diff --git a/rs/moq-ffi/src/lib.rs b/rs/moq-ffi/src/lib.rs index 5b741a8efce..db908c64a83 100644 --- a/rs/moq-ffi/src/lib.rs +++ b/rs/moq-ffi/src/lib.rs @@ -1,4 +1,7 @@ -#![cfg_attr(test, allow(clippy::disallowed_methods))] +#![cfg_attr( + test, + expect(clippy::disallowed_methods, reason = "tests read the host clock directly") +)] //! UniFFI bindings for [`moq_net`]. //! @@ -9,7 +12,13 @@ // `Rc`-backed, so clippy sees a pointlessly atomic `Arc` at every construction site. The // `Arc` is uniffi's ABI rather than our choice, and the target is single-threaded, so the // wasted atomics are what one type serving both targets costs. -#![cfg_attr(target_arch = "wasm32", allow(clippy::arc_with_non_send_sync))] +#![cfg_attr( + target_arch = "wasm32", + expect( + clippy::arc_with_non_send_sync, + reason = "`Arc` is uniffi's ABI, and wasm is single-threaded" + ) +)] #[cfg(target_os = "android")] mod android; diff --git a/rs/moq-flate/Cargo.toml b/rs/moq-flate/Cargo.toml index 4374bb74e29..9e75bddcfef 100644 --- a/rs/moq-flate/Cargo.toml +++ b/rs/moq-flate/Cargo.toml @@ -24,3 +24,6 @@ tracing = { workspace = true } [dev-dependencies] futures = { workspace = true } + +[lints] +workspace = true diff --git a/rs/moq-flate/src/lib.rs b/rs/moq-flate/src/lib.rs index 1c17293eef9..ddd4dfe9641 100644 --- a/rs/moq-flate/src/lib.rs +++ b/rs/moq-flate/src/lib.rs @@ -52,10 +52,6 @@ //! [RFC 7692]: https://www.rfc-editor.org/rfc/rfc7692.html#section-7.2.1 #![warn(missing_docs)] -// The browser transport is `!Send`, so on wasm the shared state behind the track modes' `Arc`s is -// too and clippy suggests `Rc`. The same code is genuinely cross-thread on native, so `Arc` stays -// and the lint is unactionable here. -#![cfg_attr(target_arch = "wasm32", allow(clippy::arc_with_non_send_sync))] pub mod snapshot; pub mod stream; diff --git a/rs/moq-gst/Cargo.toml b/rs/moq-gst/Cargo.toml index a63a6cdb28d..a7d3b05c042 100644 --- a/rs/moq-gst/Cargo.toml +++ b/rs/moq-gst/Cargo.toml @@ -41,3 +41,6 @@ tokio = { workspace = true, features = ["test-util"] } [[bench]] name = "catalog" harness = false + +[lints] +workspace = true diff --git a/rs/moq-hls/Cargo.toml b/rs/moq-hls/Cargo.toml index 6b6d9570f47..6804504b482 100644 --- a/rs/moq-hls/Cargo.toml +++ b/rs/moq-hls/Cargo.toml @@ -43,3 +43,6 @@ moq-archive = { path = "../moq-archive" } moq-tokio = { path = "../moq-tokio", default-features = false, features = ["tcp", "quic", "aws-lc-rs"] } tokio = { workspace = true, features = ["test-util"] } tower = { version = "0.5", features = ["util"] } + +[lints] +workspace = true diff --git a/rs/moq-hls/src/export/mod.rs b/rs/moq-hls/src/export/mod.rs index 5af0c533bae..ed3816440d2 100644 --- a/rs/moq-hls/src/export/mod.rs +++ b/rs/moq-hls/src/export/mod.rs @@ -128,9 +128,13 @@ impl Default for Config { /// All renditions of one broadcast, kept in sync with its catalog. pub struct Broadcaster { - // Read only by the serve path's `is_closed`/`closed` (server-gated); a recording consumer - // observes close through its `renditions()` cursor ending instead. - #[cfg_attr(not(feature = "server"), allow(dead_code))] + #[cfg_attr( + not(feature = "server"), + allow( + dead_code, + reason = "read only by the serve path's `is_closed`/`closed` (server-gated); a recording consumer observes close through its `renditions()` cursor ending instead" + ) + )] broadcast: moq_net::broadcast::Consumer, /// The current rendition set, reconciled from the catalog by the watcher task. renditions: renditions::Producer, @@ -194,7 +198,10 @@ impl Broadcaster { } /// Resolve once the master playlist lists at least one rendition. - #[cfg_attr(not(feature = "server"), allow(dead_code))] + #[cfg_attr( + not(feature = "server"), + allow(dead_code, reason = "only the `server` feature uses it") + )] pub(crate) async fn advertised(&self) { self.renditions.advertised().await; } @@ -329,7 +336,10 @@ impl Broadcaster { /// Build every rendition's init segment, so the manifest can name each by its hash. A /// rendition whose init can't be built yet is left out of the render. - #[cfg_attr(not(feature = "server"), allow(dead_code))] + #[cfg_attr( + not(feature = "server"), + allow(dead_code, reason = "only the `server` feature uses it") + )] pub(crate) async fn build_inits(&self) { for rendition in self.renditions.snapshot() { if let Err(err) = rendition.init().await { @@ -342,7 +352,10 @@ impl Broadcaster { /// already-ended timeline). Every rendition's window is fed from the same timeline, so the /// first rendition's readiness stands in for the broadcast's. Bounding the wait is the /// caller's policy. - #[cfg_attr(not(feature = "server"), allow(dead_code))] + #[cfg_attr( + not(feature = "server"), + allow(dead_code, reason = "only the `server` feature uses it") + )] pub(crate) async fn playable(&self) { if let Some(rendition) = self.renditions.snapshot().into_iter().next() { rendition.playable().await; @@ -350,7 +363,10 @@ impl Broadcaster { } /// Whether the current catalog contains no servable renditions (serve path). - #[cfg_attr(not(feature = "server"), allow(dead_code))] + #[cfg_attr( + not(feature = "server"), + allow(dead_code, reason = "only the `server` feature uses it") + )] pub(crate) fn is_empty(&self) -> bool { self.renditions.is_empty() } diff --git a/rs/moq-hls/src/export/rendition.rs b/rs/moq-hls/src/export/rendition.rs index 5ae3016b491..80f337e14bd 100644 --- a/rs/moq-hls/src/export/rendition.rs +++ b/rs/moq-hls/src/export/rendition.rs @@ -540,7 +540,10 @@ impl Rendition { } /// The generation every segment URL currently carries. - #[cfg_attr(not(feature = "server"), allow(dead_code))] + #[cfg_attr( + not(feature = "server"), + allow(dead_code, reason = "only the `server` feature uses it") + )] pub(crate) fn generation(&self) -> Option> { self.run().generation } @@ -908,7 +911,10 @@ impl Rendition { /// Fetch and transmux the segment of the reference tagged `tag` whose timeline `pts` is /// `time`, in the timeline's timescale (DASH `$Time$` addressing of the same bytes /// [`segment`](Self::segment) serves by aligned number). - #[cfg_attr(not(feature = "server"), allow(dead_code))] + #[cfg_attr( + not(feature = "server"), + allow(dead_code, reason = "only the `server` feature uses it") + )] pub(crate) async fn segment_at(&self, tag: &str, time: u64) -> Result> { self.media.sync(&self.live); let Some(segment) = self.live.segment_number_at(tag, time, self.timescale()) else { @@ -992,7 +998,10 @@ impl Rendition { /// The init segment served at `init.{hash}.mp4`: `None` when `hash` names any other bytes, /// so a URL never serves an init it does not describe. - #[cfg_attr(not(feature = "server"), allow(dead_code))] + #[cfg_attr( + not(feature = "server"), + allow(dead_code, reason = "only the `server` feature uses it") + )] pub(crate) async fn init_versioned(&self, hash: &str) -> Result> { let init = self.load_init().await?; Ok(init.filter(|init| init.hash == hash).map(|init| init.bytes.clone())) diff --git a/rs/moq-hls/src/export/renditions.rs b/rs/moq-hls/src/export/renditions.rs index 06cf273443f..01a1b42b23d 100644 --- a/rs/moq-hls/src/export/renditions.rs +++ b/rs/moq-hls/src/export/renditions.rs @@ -190,7 +190,10 @@ impl Producer { } /// Whether the current catalog contains no servable renditions (serve path). - #[cfg_attr(not(feature = "server"), allow(dead_code))] + #[cfg_attr( + not(feature = "server"), + allow(dead_code, reason = "only the `server` feature uses it") + )] pub fn is_empty(&self) -> bool { self.state.read().renditions.is_empty() } @@ -449,7 +452,10 @@ impl Producer { /// Resolve once at least one enabled rendition is [advertised](Rendition::is_advertised), so a /// master playlist can list it. - #[cfg_attr(not(feature = "server"), allow(dead_code))] + #[cfg_attr( + not(feature = "server"), + allow(dead_code, reason = "only the `server` feature uses it") + )] pub(crate) async fn advertised(&self) { let _ = kio::wait(|waiter| { self.state.poll_ref(waiter, |current| { diff --git a/rs/moq-hls/src/export/segments.rs b/rs/moq-hls/src/export/segments.rs index fe2b7489da6..46fb5afcb07 100644 --- a/rs/moq-hls/src/export/segments.rs +++ b/rs/moq-hls/src/export/segments.rs @@ -177,7 +177,10 @@ impl Row { } /// A consistent read of the window, for rendering one playlist (the serve path only). -#[cfg_attr(not(feature = "server"), allow(dead_code))] +#[cfg_attr( + not(feature = "server"), + allow(dead_code, reason = "only the `server` feature uses it") +)] pub(crate) struct Window { /// The `EXT-X-MEDIA-SEQUENCE` of the first listed segment: its source segment number, so /// sequence numbers line up across renditions and edges. @@ -202,7 +205,10 @@ enum Next { impl State { /// Snapshot the current window. Every row is a complete segment, so all are listed. - #[cfg_attr(not(feature = "server"), allow(dead_code))] + #[cfg_attr( + not(feature = "server"), + allow(dead_code, reason = "only the `server` feature uses it") + )] fn window(&self) -> Window { Window { sequence: self.sequence, @@ -329,7 +335,10 @@ impl Producer { } /// Snapshot the current window (serve path). - #[cfg_attr(not(feature = "server"), allow(dead_code))] + #[cfg_attr( + not(feature = "server"), + allow(dead_code, reason = "only the `server` feature uses it") + )] pub fn window(&self) -> Window { self.state.read().window() } @@ -349,7 +358,10 @@ impl Producer { /// (DASH `$Time$` addressing), or `None` when no listed row starts there. Exact match is /// safe because the rendered `S@t` and this lookup convert the same [`Row::pts`] the same /// way. - #[cfg_attr(not(feature = "server"), allow(dead_code))] + #[cfg_attr( + not(feature = "server"), + allow(dead_code, reason = "only the `server` feature uses it") + )] pub fn segment_number_at(&self, tag: &str, time: u64, timescale: moq_net::Timescale) -> Option { let state = self.state.read(); state @@ -374,14 +386,20 @@ impl Producer { /// Whether the playlist has anything to serve yet (at least one segment, or the broadcast /// already ended). - #[cfg_attr(not(feature = "server"), allow(dead_code))] + #[cfg_attr( + not(feature = "server"), + allow(dead_code, reason = "only the `server` feature uses it") + )] pub fn is_playable(&self) -> bool { let state = self.state.read(); state.ended || !state.rows.is_empty() } /// Poll until [`is_playable`](Self::is_playable), for the serve path's long-poll. - #[cfg_attr(not(feature = "server"), allow(dead_code))] + #[cfg_attr( + not(feature = "server"), + allow(dead_code, reason = "only the `server` feature uses it") + )] pub fn poll_playable(&self, waiter: &kio::Waiter) -> Poll<()> { let poll = self.state.poll_ref(waiter, |state| { if state.ended || !state.rows.is_empty() { diff --git a/rs/moq-ice/Cargo.toml b/rs/moq-ice/Cargo.toml index e34bbdc354c..eca8fc0d6b4 100644 --- a/rs/moq-ice/Cargo.toml +++ b/rs/moq-ice/Cargo.toml @@ -21,3 +21,6 @@ tracing = { workspace = true } [dev-dependencies] tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } + +[lints] +workspace = true diff --git a/rs/moq-ice/src/agent.rs b/rs/moq-ice/src/agent.rs index 20f310f2e53..b0da6de91b4 100644 --- a/rs/moq-ice/src/agent.rs +++ b/rs/moq-ice/src/agent.rs @@ -61,8 +61,10 @@ impl Error { /// What [`Agent::next`] surfaced. #[derive(Debug)] #[non_exhaustive] -// Moved once per poll; boxing would allocate for every data channel message. -#[allow(clippy::large_enum_variant)] +#[expect( + clippy::large_enum_variant, + reason = "moved once per poll; boxing would allocate for every data channel message" +)] pub enum Event { /// An event from str0m. ICE disconnection is reported as [`Error::Closed`] instead. Rtc(str0m::Event), diff --git a/rs/moq-json/Cargo.toml b/rs/moq-json/Cargo.toml index 4745f532b92..4764208414c 100644 --- a/rs/moq-json/Cargo.toml +++ b/rs/moq-json/Cargo.toml @@ -49,3 +49,6 @@ harness = false [[example]] name = "teleop" test = true + +[lints] +workspace = true diff --git a/rs/moq-json/benches/window.rs b/rs/moq-json/benches/window.rs index e406cbc694a..acf790c1697 100644 --- a/rs/moq-json/benches/window.rs +++ b/rs/moq-json/benches/window.rs @@ -49,7 +49,7 @@ unsafe impl GlobalAlloc for Counter { /// A stats-shaped record: flat counters plus one nested object, nothing owned on the heap. #[derive(serde::Deserialize)] -#[allow(dead_code)] +#[allow(dead_code, reason = "the bench only measures deserializing it")] struct Record { bytes: u64, frames: u64, @@ -59,7 +59,7 @@ struct Record { } #[derive(serde::Deserialize)] -#[allow(dead_code)] +#[allow(dead_code, reason = "the bench only measures deserializing it")] struct Nested { bytes: u64, frames: u64, diff --git a/rs/moq-json/src/snapshot/decoder.rs b/rs/moq-json/src/snapshot/decoder.rs index 3159b851c4e..323b069e3f2 100644 --- a/rs/moq-json/src/snapshot/decoder.rs +++ b/rs/moq-json/src/snapshot/decoder.rs @@ -389,12 +389,12 @@ mod test { #[test] fn a_rejected_field_names_its_path() { #[derive(serde::Deserialize, Debug)] - #[allow(dead_code)] + #[allow(dead_code, reason = "the test only checks that deserializing fails")] struct Inner { count: u8, } #[derive(serde::Deserialize, Debug)] - #[allow(dead_code)] + #[allow(dead_code, reason = "the test only checks that deserializing fails")] struct Outer { inner: Inner, } diff --git a/rs/moq-json/src/snapshot/mod.rs b/rs/moq-json/src/snapshot/mod.rs index 6bc03283839..b0cee1f2ae1 100644 --- a/rs/moq-json/src/snapshot/mod.rs +++ b/rs/moq-json/src/snapshot/mod.rs @@ -1183,12 +1183,12 @@ mod test { #[test] fn rejected_field_names_its_path() { #[derive(serde::Deserialize)] - #[allow(dead_code)] + #[allow(dead_code, reason = "the test only checks that deserializing fails")] struct Inner { count: u8, } #[derive(serde::Deserialize)] - #[allow(dead_code)] + #[allow(dead_code, reason = "the test only checks that deserializing fails")] struct Outer { inner: Inner, } diff --git a/rs/moq-loc/Cargo.toml b/rs/moq-loc/Cargo.toml index 5388b4d1475..0507e77e3ea 100644 --- a/rs/moq-loc/Cargo.toml +++ b/rs/moq-loc/Cargo.toml @@ -16,3 +16,6 @@ categories = ["multimedia", "network-programming", "web-programming"] bytes = { workspace = true } moq-net = { workspace = true } thiserror = { workspace = true } + +[lints] +workspace = true diff --git a/rs/moq-msf/Cargo.toml b/rs/moq-msf/Cargo.toml index b93878fd685..931c0563b6f 100644 --- a/rs/moq-msf/Cargo.toml +++ b/rs/moq-msf/Cargo.toml @@ -16,3 +16,6 @@ categories = ["multimedia", "network-programming", "web-programming"] serde = { workspace = true } serde_json = { workspace = true } serde_with = { workspace = true } + +[lints] +workspace = true diff --git a/rs/moq-msf/src/lib.rs b/rs/moq-msf/src/lib.rs index d335f486ae6..851eb855166 100644 --- a/rs/moq-msf/src/lib.rs +++ b/rs/moq-msf/src/lib.rs @@ -227,7 +227,10 @@ impl Catalog { } /// Deserialize an MSF catalog from a JSON string. - #[allow(clippy::should_implement_trait)] + #[expect( + clippy::should_implement_trait, + reason = "public inherent parser; switching to `FromStr` is a breaking change" + )] pub fn from_str(s: &str) -> Result { serde_json::from_str(s) } diff --git a/rs/moq-mux/Cargo.toml b/rs/moq-mux/Cargo.toml index 16f90fc6ab0..25184ab913a 100644 --- a/rs/moq-mux/Cargo.toml +++ b/rs/moq-mux/Cargo.toml @@ -68,3 +68,6 @@ harness = false [[bench]] name = "containers" harness = false + +[lints] +workspace = true diff --git a/rs/moq-mux/benches/ts_schedule.rs b/rs/moq-mux/benches/ts_schedule.rs index dad04ee369d..40cf20bc333 100644 --- a/rs/moq-mux/benches/ts_schedule.rs +++ b/rs/moq-mux/benches/ts_schedule.rs @@ -10,7 +10,10 @@ mod export { use std::time::Duration; } #[path = "../src/container/ts/schedule.rs"] -#[allow(dead_code)] +#[allow( + dead_code, + reason = "the bench compiles the private module from source and uses only part of it" +)] mod schedule; fn packet(pid: u16) -> [u8; 188] { diff --git a/rs/moq-mux/src/catalog/consumer.rs b/rs/moq-mux/src/catalog/consumer.rs index f2109f029a4..b109964912d 100644 --- a/rs/moq-mux/src/catalog/consumer.rs +++ b/rs/moq-mux/src/catalog/consumer.rs @@ -28,9 +28,10 @@ pub struct Consumer { inner: State, } -// One per catalog subscription, and the live variant is the working state, so boxing -// it would only add an allocation. -#[allow(clippy::large_enum_variant)] +#[allow( + clippy::large_enum_variant, + reason = "one per catalog subscription, and the live variant is the working state; it is only large when a workspace build unifies extra features" +)] enum State { Hang(super::hang::Consumer), Msf(super::msf::Consumer), diff --git a/rs/moq-mux/src/catalog/producer.rs b/rs/moq-mux/src/catalog/producer.rs index 65108d16292..4a9f17bda30 100644 --- a/rs/moq-mux/src/catalog/producer.rs +++ b/rs/moq-mux/src/catalog/producer.rs @@ -443,13 +443,8 @@ impl Producer { let hangz = moq_json::snapshot::Producer::new(hangz_track, json_config); let timeline = crate::timeline::Timelines::new(broadcast); - #[allow(clippy::arc_with_non_send_sync)] let catalog_timeline = Arc::new(Mutex::new(CatalogTimeline::default())); - // The contents are `Send + Sync` natively; on wasm moq-net's handles are - // `Rc`-backed, so clippy sees a pointlessly atomic `Arc`. Keeping one type for - // both targets is worth the unused atomics on the single-threaded one. - #[allow(clippy::arc_with_non_send_sync)] Ok(Self { outputs: Outputs { hang, diff --git a/rs/moq-mux/src/container/ts/import.rs b/rs/moq-mux/src/container/ts/import.rs index 700b188ba6e..cdd2d4c24dc 100644 --- a/rs/moq-mux/src/container/ts/import.rs +++ b/rs/moq-mux/src/container/ts/import.rs @@ -8024,7 +8024,6 @@ pub(super) mod test { /// Import `data` with an `mpegts` catalog, failing on any import error. The importer is /// returned to keep its renditions in the catalog. - #[allow(clippy::type_complexity)] fn import_all( data: &[u8], ) -> anyhow::Result<( diff --git a/rs/moq-mux/src/lib.rs b/rs/moq-mux/src/lib.rs index 81802d8b006..2ccebea9f29 100644 --- a/rs/moq-mux/src/lib.rs +++ b/rs/moq-mux/src/lib.rs @@ -1,4 +1,7 @@ -#![cfg_attr(test, allow(clippy::disallowed_methods))] +#![cfg_attr( + test, + expect(clippy::disallowed_methods, reason = "tests read the host clock directly") +)] //! Media muxers and demuxers for MoQ. //! diff --git a/rs/moq-mux/src/timeline.rs b/rs/moq-mux/src/timeline.rs index 4fed58ca324..0e3cf3ce6cd 100644 --- a/rs/moq-mux/src/timeline.rs +++ b/rs/moq-mux/src/timeline.rs @@ -583,9 +583,6 @@ pub struct Timelines { impl Timelines { /// Timelines for tracks of `broadcast`. pub fn new(broadcast: &moq_net::broadcast::Producer) -> Self { - // The contents are `Send + Sync` natively; on wasm moq-net's handles are `Rc`-backed, so - // clippy sees a pointlessly atomic `Arc`. One type for both targets is worth it. - #[allow(clippy::arc_with_non_send_sync)] let registry = Arc::new(Mutex::new(Registry { tracks: BTreeMap::new(), finished: false, @@ -629,7 +626,6 @@ impl Timelines { let timeline = hang::timeline::default_name(name); let track = self.broadcast.create_track(timeline.as_str(), Producer::info())?; - #[allow(clippy::arc_with_non_send_sync)] let live = Arc::new(Mutex::new(Live { segmenter: Segmenter::new(config), on_declare: None, diff --git a/rs/moq-native/Cargo.toml b/rs/moq-native/Cargo.toml index 121a0afd9bd..c9c38e89c14 100644 --- a/rs/moq-native/Cargo.toml +++ b/rs/moq-native/Cargo.toml @@ -26,3 +26,6 @@ tcp = [] uds = [] ring = [] android-logcat = [] + +[lints] +workspace = true diff --git a/rs/moq-net/Cargo.toml b/rs/moq-net/Cargo.toml index 0f1809f8aee..3cd2e0fa93e 100644 --- a/rs/moq-net/Cargo.toml +++ b/rs/moq-net/Cargo.toml @@ -69,9 +69,6 @@ wasm-bindgen-test = "=0.3.79" [target.'cfg(unix)'.dev-dependencies] libc = { workspace = true } -[lints.rust] -unexpected_cfgs = { level = "warn", check-cfg = ['cfg(loom)'] } - # Writes the generated fuzzer corpus to disk. Needs the `fuzz` feature, so a default # `--all-targets` build skips it rather than failing to find the module. [[example]] @@ -190,3 +187,6 @@ required-features = ["async"] name = "memory" harness = false required-features = ["async"] + +[lints] +workspace = true diff --git a/rs/moq-net/benches/admission.rs b/rs/moq-net/benches/admission.rs index 9fa481e15db..52956defa76 100644 --- a/rs/moq-net/benches/admission.rs +++ b/rs/moq-net/benches/admission.rs @@ -1,7 +1,9 @@ //! Admission guard cost across serving threads and already admitted connections. -// Custom timings measure the real time the work took, not the ambient clock. -#![allow(clippy::disallowed_methods)] +#![expect( + clippy::disallowed_methods, + reason = "custom timings measure the real time the work took, not the ambient clock" +)] use std::{sync::Barrier, time::Instant}; diff --git a/rs/moq-net/benches/memory.rs b/rs/moq-net/benches/memory.rs index 59e4fa58c7e..84caeb0f528 100644 --- a/rs/moq-net/benches/memory.rs +++ b/rs/moq-net/benches/memory.rs @@ -13,8 +13,10 @@ //! //! Run with `cargo bench -p moq-net --bench memory`. -// Custom timings measure the real time the work took, not the ambient clock. -#![allow(clippy::disallowed_methods)] +#![expect( + clippy::disallowed_methods, + reason = "custom timings measure the real time the work took, not the ambient clock" +)] use std::alloc::{GlobalAlloc, Layout, System}; use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; diff --git a/rs/moq-net/benches/origin.rs b/rs/moq-net/benches/origin.rs index 4cd654e56cb..257fcd37973 100644 --- a/rs/moq-net/benches/origin.rs +++ b/rs/moq-net/benches/origin.rs @@ -24,8 +24,10 @@ //! //! Run with `cargo bench -p moq-net --bench origin`. -// Custom timings measure the real time the work took, not the ambient clock. -#![allow(clippy::disallowed_methods)] +#![expect( + clippy::disallowed_methods, + reason = "custom timings measure the real time the work took, not the ambient clock" +)] #[path = "../tests/integration/support/mod.rs"] mod support; diff --git a/rs/moq-net/benches/priority.rs b/rs/moq-net/benches/priority.rs index 0bb25f0914b..fb17860ccf3 100644 --- a/rs/moq-net/benches/priority.rs +++ b/rs/moq-net/benches/priority.rs @@ -5,7 +5,10 @@ use criterion::{BatchSize, BenchmarkId, Criterion, criterion_group, criterion_ma // Compiled straight from source so the queue stays private to the crate; a `pub` re-export // just for the bench would widen the crate's surface. #[path = "../src/priority.rs"] -#[allow(dead_code)] +#[allow( + dead_code, + reason = "the bench compiles the private module from source and uses only part of it" +)] mod priority; // The queue names `crate::track::Order`, which is public. diff --git a/rs/moq-net/benches/refresh.rs b/rs/moq-net/benches/refresh.rs index ab437136dd9..50371c918bd 100644 --- a/rs/moq-net/benches/refresh.rs +++ b/rs/moq-net/benches/refresh.rs @@ -5,8 +5,10 @@ //! //! Run with `cargo bench -p moq-net --bench refresh`. -// Custom timings measure the real time the work took, not the ambient clock. -#![allow(clippy::disallowed_methods)] +#![expect( + clippy::disallowed_methods, + reason = "custom timings measure the real time the work took, not the ambient clock" +)] use std::time::{Duration, Instant}; diff --git a/rs/moq-net/benches/schedule.rs b/rs/moq-net/benches/schedule.rs index e02c647e6c1..4f1ef3c0a30 100644 --- a/rs/moq-net/benches/schedule.rs +++ b/rs/moq-net/benches/schedule.rs @@ -25,7 +25,10 @@ use criterion::{BatchSize, BenchmarkId, Criterion, criterion_group, criterion_ma // Both schedulers compile straight from source, so neither widens its crate's API for this. #[path = "../src/priority.rs"] -#[allow(dead_code)] +#[allow( + dead_code, + reason = "the bench compiles the private module from source and uses only part of it" +)] mod priority; // The queue names `crate::track::Order`, which is public. @@ -36,7 +39,7 @@ mod track { // Keeps moq-quic's own formatting. #[rustfmt::skip] #[path = "../../moq-quic/src/connection/streams/schedule.rs"] -#[allow(dead_code)] +#[allow(dead_code, reason = "the bench compiles the private module from source and uses only part of it")] mod schedule; use priority::{Priority, PriorityHandle, PriorityQueue}; diff --git a/rs/moq-net/benches/session.rs b/rs/moq-net/benches/session.rs index c4fe599cdb4..4d6fbaf8d16 100644 --- a/rs/moq-net/benches/session.rs +++ b/rs/moq-net/benches/session.rs @@ -42,8 +42,10 @@ //! //! Run with `cargo bench -p moq-net --bench session`. -// Custom timings measure the real time the work took, not the ambient clock. -#![allow(clippy::disallowed_methods)] +#![expect( + clippy::disallowed_methods, + reason = "custom timings measure the real time the work took, not the ambient clock" +)] #[path = "../tests/integration/support/mod.rs"] mod support; diff --git a/rs/moq-net/benches/track.rs b/rs/moq-net/benches/track.rs index f471d193563..b79eff4053b 100644 --- a/rs/moq-net/benches/track.rs +++ b/rs/moq-net/benches/track.rs @@ -72,8 +72,10 @@ //! //! Run with `cargo bench -p moq-net --bench track`. -// Custom timings measure the real time the work took, not the ambient clock. -#![allow(clippy::disallowed_methods)] +#![expect( + clippy::disallowed_methods, + reason = "custom timings measure the real time the work took, not the ambient clock" +)] use std::hint::black_box; use std::sync::{Arc, Barrier}; diff --git a/rs/moq-net/fuzz/Cargo.toml b/rs/moq-net/fuzz/Cargo.toml index 721e1874124..0fdff664654 100644 --- a/rs/moq-net/fuzz/Cargo.toml +++ b/rs/moq-net/fuzz/Cargo.toml @@ -65,3 +65,6 @@ bench = false [dependencies] libfuzzer-sys = "0.4" moq-net = { workspace = true, features = ["fuzz"] } + +[lints] +workspace = true diff --git a/rs/moq-net/src/auth.rs b/rs/moq-net/src/auth.rs index 0bdeccb2320..b540ee7caa9 100644 --- a/rs/moq-net/src/auth.rs +++ b/rs/moq-net/src/auth.rs @@ -40,7 +40,7 @@ use bytes::Bytes; use crate::{Error, Patterns, Result, SessionError, time::Instant}; /// Classify malformed AUTH messages separately from transport and local failures. -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn protocol_error(err: Error) -> Error { match err { Error::Decode(_) @@ -98,7 +98,7 @@ impl Grant { /// The paths both grants allow, lapsing at the earlier expiry. /// /// Fails closed: an intersection too large to hold grants nothing, never more. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] fn intersect(&self, other: &Self) -> Self { let both = |a: &Patterns, b: &Patterns| { a.intersect(b).unwrap_or_else(|err| { @@ -132,7 +132,7 @@ pub(crate) struct State { requests: bool, /// Set once the session ends; every waiter resolves with it. closed: Option, - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] next_id: u64, /// Every token this side presented that has not ended. tokens: BTreeMap, @@ -149,7 +149,7 @@ pub(crate) struct State { /// The grants the application issued to the peer's AUTH tokens, by stream, in the /// peer's terms. A token on a single request never joins them. issued: BTreeMap, - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] next_issue: u64, /// The session's scope for the peer: the limit and every issued grant, `None` while the /// limit is. @@ -162,17 +162,17 @@ pub(crate) struct State { /// One presented token. pub(crate) struct Slot { - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] token: Bytes, /// Presented by the session itself at setup, so enforcement waits on it. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] setup: bool, /// The latest AUTH_OK, `None` before the first and after the token ends. grant: Option, /// Handed to the driver to open its AUTH stream, which then owns ending it. streamed: bool, /// The first reply: `Ok` for an AUTH_OK, the refusal otherwise. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] answered: Option>, /// Why the token ended, once it has. ended: Option, @@ -187,10 +187,10 @@ enum Acceptor { #[default] Undecided, /// The app answers every token. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] App(Pending), /// The session answers from its own origin handles. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] Default, } @@ -232,7 +232,7 @@ impl State { /// The union's and the scope's patterns for `direction`, each `None` while /// unrestricted. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] fn parts(&self, direction: Direction) -> (Option<&Patterns>, Option<&Patterns>) { // The peer's grant names what we may do; the scope names what the peer may, // so what we send is what the peer may subscribe to, and the other way around. @@ -249,7 +249,7 @@ impl State { } /// What `direction` allows right now. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] fn permit(&self, direction: Direction) -> Permit { let (granted, limit) = self.parts(direction); Permit { @@ -259,7 +259,7 @@ impl State { } /// Whether `direction` allows `path` right now, without copying the patterns. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] fn allows(&self, direction: Direction, path: &str) -> bool { let (granted, limit) = self.parts(direction); granted.is_none_or(|granted| granted.matches(path)) && limit.is_none_or(|limit| limit.matches(path)) @@ -270,7 +270,7 @@ impl State { /// union of its tokens) and the limit this side set on the peer, each `None` /// while unrestricted. #[derive(Clone, Debug, Default, PartialEq, Eq)] -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) struct Permit { granted: Option, limit: Option, @@ -278,7 +278,7 @@ pub(crate) struct Permit { impl Permit { /// Whether both allow `path`. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn matches(&self, path: &str) -> bool { self.granted(path) && self.within_limit(path) } @@ -290,14 +290,14 @@ impl Permit { /// Whether the limit alone allows `path`: for what the peer offers us, which our /// own grant does not decide. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn within_limit(&self, path: &str) -> bool { self.limit.as_ref().is_none_or(|limit| limit.matches(path)) } /// Whether this allows everything `other` does, judged part by part, so a `false` /// may be spurious but a `true` never is. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn covers(&self, other: &Self) -> bool { let covers = |this: &Option, other: &Option| match (this, other) { (None, _) => true, @@ -318,7 +318,7 @@ pub struct Handle { impl Handle { /// A handle for a session that speaks AUTH (`supported`) or never will. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn new(supported: bool) -> Self { Self { state: kio::Shared::new(State { @@ -330,7 +330,7 @@ impl Handle { /// A moq-transport handle: like [`new`](Self::new), but a request can carry a token /// itself, so [`add`](Self::add) succeeds without AUTH. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn ietf(supported: bool) -> Self { Self { state: kio::Shared::new(State { @@ -343,7 +343,7 @@ impl Handle { /// Whether this side speaks AUTH: false on a version without it, on a side that does /// not offer it, and once the peer turns out not to. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn supported(&self) -> bool { self.state.lock().supported } @@ -374,7 +374,7 @@ impl Handle { } /// Queue a token for the driver to present. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn present(&self, token: Bytes, setup: bool) -> Result { let mut state = self.state.lock(); if !state.supported && !state.requests { @@ -413,7 +413,7 @@ impl Handle { /// The token a request carries for `auth`, or `None` when the request goes out unnamed /// under the session's scope: `auth` came from another handle, it ended, or requests /// carry no token on this version. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn token(&self, auth: &Auth) -> Option { if !auth.presented.state.same_channel(&self.state) { return None; @@ -467,7 +467,7 @@ impl Handle { /// and for an empty token, which on AUTH means the connection's own credential and so would /// reach the acceptor as that credential. `hold` is the request's slot, kept while the /// application verifies the token. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn verify_request(&self, token: crate::setup::Token, hold: Option) -> RequestVerdict { let Some(queue) = self.acceptor() else { return RequestVerdict { issue: None }; @@ -486,7 +486,7 @@ impl Handle { /// Decide who answers the peer's tokens: the app if it took the requests, /// otherwise the session itself (`None`). Idempotent. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn acceptor(&self) -> Option { let mut state = self.state.lock(); match &state.acceptor { @@ -500,7 +500,7 @@ impl Handle { } /// The next token to open a stream for, or `Ready(None)` once the session ends. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn poll_opening(&self, waiter: &kio::Waiter) -> Poll> { let mut state = ready_or!(self.state.poll(waiter, |state| { match state.opening.is_empty() && state.closed.is_none() { @@ -527,7 +527,7 @@ impl Handle { } /// Whether the token's handle dropped, so its stream should close. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn poll_withdrawn(&self, id: u64, waiter: &kio::Waiter) -> Poll<()> { let _ = ready_or!(self.state.poll(waiter, |state| match state.tokens.get(&id) { Some(slot) if !slot.withdrawn => Poll::Pending, @@ -537,7 +537,7 @@ impl Handle { } /// Record an AUTH_OK for the token. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn granted(&self, id: u64, grant: Grant) { // One parseable line per AUTH_OK, so the grant the peer actually sent is observable // without an API; the interop harness checks it against the token it minted. @@ -560,7 +560,7 @@ impl Handle { /// Record an AUTH_ERROR for the token: a reply that grants nothing, so a refused /// setup token leaves an empty union rather than an unknown (unrestricted) one. /// The driver still ends the token with [`ended`](Self::ended). - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn refused(&self, id: u64) { let mut state = self.state.lock(); if state.tokens.contains_key(&id) { @@ -570,7 +570,7 @@ impl Handle { /// End the token: refused or revoked by the peer, withdrawn by us, or its /// stream lost. A token that was never answered records `err` as its answer. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn ended(&self, id: u64, err: Error) { let mut state = self.state.lock(); let Some(slot) = state.tokens.get_mut(&id) else { @@ -590,7 +590,7 @@ impl Handle { /// Resolve once every token the session presented at setup has its first /// reply, so enforcement never waits on a token the app added later. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn poll_setup_answered(&self, waiter: &kio::Waiter) -> Poll<()> { let _ = ready_or!(self.state.poll(waiter, |state| { match state.tokens.values().any(|slot| slot.setup && slot.answered.is_none()) { @@ -602,7 +602,7 @@ impl Handle { } /// Wait only when a token already presented might widen the grant for this path. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] fn poll_presented(&self, direction: Direction, path: &str, waiter: &kio::Waiter) -> Poll<()> { let _ = ready_or!(self.state.poll(waiter, |state| { let (granted, _) = state.parts(direction); @@ -664,7 +664,7 @@ impl Handle { /// The union once it changed since `epoch` last saw it, advancing `epoch`. It /// only ever changes into `Some`: no answer yet is the initial state. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn poll_union(&self, epoch: &mut u64, waiter: &kio::Waiter) -> Poll> { let state = ready_or!(self.poll_epoch(*epoch, waiter)); *epoch = state.epoch; @@ -673,7 +673,7 @@ impl Handle { /// What `direction` allows once it may have changed since `epoch` last saw it, /// advancing `epoch`. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn poll_permit(&self, direction: Direction, epoch: &mut u64, waiter: &kio::Waiter) -> Poll { let state = ready_or!(self.poll_epoch(*epoch, waiter)); *epoch = state.epoch; @@ -681,14 +681,14 @@ impl Handle { } /// The limit once it may have changed since `epoch` last saw it, advancing `epoch`. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn poll_limit(&self, epoch: &mut u64, waiter: &kio::Waiter) -> Poll> { let state = ready_or!(self.poll_epoch(*epoch, waiter)); *epoch = state.epoch; Poll::Ready(state.limit.clone()) } - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] fn poll_epoch(&self, seen: u64, waiter: &kio::Waiter) -> Poll> { self.state.poll(waiter, |state| match state.epoch != seen { true => Poll::Ready(()), @@ -699,7 +699,7 @@ impl Handle { /// Whether `direction` allows `path` right now: the union (allowing everything /// while it is `None`, before an answer or on a version without AUTH) and the /// limit both. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn allows(&self, direction: Direction, path: &str) -> bool { self.state.read().allows(direction, path) } @@ -710,7 +710,7 @@ impl Handle { /// would leave the peer believing it backs a request this side holds to its scope. A side /// that neither scopes the peer nor answers tokens has nothing to check one against, and /// admits as it would without it. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn token_decides(&self, direction: Direction) -> bool { let state = self.state.read(); let (_, scope) = state.parts(direction); @@ -719,7 +719,7 @@ impl Handle { /// Whether the peer's grant alone allows `direction` at `path`, allowing everything /// while it is `None`: what bounds this side whatever authorized the request. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn within_grant(&self, direction: Direction, path: &str) -> bool { let state = self.state.read(); let (granted, _) = state.parts(direction); @@ -728,7 +728,7 @@ impl Handle { /// Whether the scope alone allows `direction` at `path`: for a route the peer /// offers us, which our own grant does not decide. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn within_limit(&self, direction: Direction, path: &str) -> bool { let state = self.state.read(); let (_, scope) = state.parts(direction); @@ -739,7 +739,7 @@ impl Handle { /// moq-transport every token we presented stays, with an unknown grant, for the /// requests that name it; elsewhere each fails as unsupported. The peer's tokens can /// still ride its requests, so their queue stays open. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn unsupported(&self) { let mut state = self.state.lock(); state.supported = false; @@ -759,7 +759,7 @@ impl Handle { /// End the session: fail every pending token, end every watch, and close the /// requests. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn close(&self, err: Error) { let mut state = self.state.lock(); if state.closed.is_some() { @@ -834,7 +834,7 @@ impl Auth { .await } - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] fn poll_answered(&self, waiter: &kio::Waiter) -> Poll> { let Presented { state, id } = &*self.presented; let state = ready_or!(state.poll(waiter, |state| match state.tokens.get(id) { @@ -1019,7 +1019,7 @@ impl Pending { } /// Queue the token for the application, or refuse it when closed. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn push(&self, request: Request) { let mut state = self.state.lock(); // Dropping the request refuses it as unanswered. @@ -1063,9 +1063,9 @@ impl Pending { /// What the acceptor writes on one peer token's stream. pub(crate) enum Reply { - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] Grant(Grant), - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] Refuse { code: SessionError, reason: String }, } @@ -1118,7 +1118,7 @@ pub(crate) type Hold = std::sync::Arc; /// /// Dropping it settles [`Issued::closed`] with the session's error, unless the task /// already recorded why the stream ended, so no exit path leaves the acceptor waiting. -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) struct Serving { pub issue: kio::Shared, handle: Handle, @@ -1126,7 +1126,7 @@ pub(crate) struct Serving { impl Serving { /// A fresh stream's shared state, settled by the session `handle` if the task drops. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn new(handle: Handle) -> Self { let id = { let mut state = handle.state.lock(); @@ -1144,7 +1144,7 @@ impl Serving { /// Record why the stream ended on the peer's side; the first reason wins. Whatever it /// granted leaves the scope. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn end(&self, err: Error) { let mut issue = self.issue.lock(); issue.peer.get_or_insert(err); @@ -1174,7 +1174,7 @@ pub struct Request { } impl Request { - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn new(token: Bytes, issue: kio::Shared) -> Self { Self { token, @@ -1240,7 +1240,7 @@ fn refuse(issue: &kio::Shared, code: SessionError, reason: String) { /// Which request a token rode on. #[derive(Clone, Copy, Debug, PartialEq, Eq)] -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) enum RequestKind { /// A SUBSCRIBE: the peer reads the named track. Subscribe, @@ -1253,7 +1253,7 @@ impl RequestKind { /// `path`. A grant names what its holder may do, so a request to read is covered by its /// `subscribe` patterns and a request to announce by its `publish` patterns. An announce /// routes everything beneath its namespace, so the grant must cover that whole subtree. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn covers(self, grant: &Grant, path: &str) -> bool { match self { Self::Subscribe => grant.subscribe.matches(path), @@ -1275,7 +1275,7 @@ pub(crate) struct RequestVerdict { /// Why a request token did not authorize its request: the error whose code the peer is /// sent, and the reason phrase with it, which the acceptor chose when it refused. #[derive(Debug)] -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) struct Refusal { pub error: Error, pub reason: String, @@ -1297,7 +1297,7 @@ impl From for Refusal { } } -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] impl RequestVerdict { /// Wait for the acceptor's first answer. See [`poll_grant`](Self::poll_grant). #[cfg(test)] @@ -1382,10 +1382,10 @@ impl Drop for RequestVerdict { /// Clones share the grant: the request's [`until`] watches it end while the request renews it. /// Ending a request grant never touches the session: only that one request ends. #[derive(Clone)] -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) struct RequestGrant(std::sync::Arc>); -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] struct Held { verdict: RequestVerdict, grant: Grant, @@ -1400,7 +1400,7 @@ struct Held { clock: crate::time::Deadlines, } -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] impl RequestGrant { /// Hold the acceptor's first answer `res` for the request's life, armed to lapse at its /// expiry, or the refusal to answer the request with: the acceptor's own, or @@ -1542,7 +1542,7 @@ impl RequestGrant { /// A dropped `body` releases what it holds; anything it was writing stays buffered whole in /// the stream's [`Writer`](crate::coding::Writer) as long as each message is buffered before /// its first await, so the caller can still end the request on the wire. -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) async fn until( body: F, mut ended: impl FnMut(&kio::Waiter) -> Poll, @@ -1559,13 +1559,13 @@ pub(crate) async fn until( /// Whether `grant` covers a `kind` request at `path` and has not already expired: admitting /// an expired one until its deadline fires would let others act on it meanwhile. -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] fn live(clock: &crate::time::Deadlines, kind: RequestKind, path: &str, grant: &Grant) -> bool { kind.covers(grant, path) && grant.expires.is_none_or(|expires| expires > clock.now()) } /// Whether the acceptor granted the token behind `issue` and still holds the grant. -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] fn granted(issue: &kio::Shared) -> bool { let issue = issue.read(); !issue.done && issue.outbox.iter().any(|reply| matches!(reply, Reply::Grant(_))) @@ -1623,7 +1623,7 @@ async fn closed(issue: &kio::Shared) -> Error { /// Which way media flows, from this side's view. #[derive(Clone, Copy)] -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) enum Direction { /// This side sends to the peer: our grant's `publish`, and the limit's `subscribe`. Publish, @@ -1637,7 +1637,7 @@ pub(crate) enum Direction { /// Create it at the request's first check and hold it to the end, so a change /// landing in between is never missed. Cheap to poll on every wakeup: the path is /// only re-matched when the union or the limit changes. -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) struct Gate { handle: Handle, path: crate::PathOwned, @@ -1663,7 +1663,7 @@ impl Drop for Waiting { } /// Which part of a [`Permit`] a [`Gate`] watches. -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] enum Part { /// The peer's grant and the scope both. Both, @@ -1674,7 +1674,7 @@ enum Part { } impl Gate { - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn new(handle: Handle, path: crate::PathOwned, direction: Direction) -> Self { let within_limit = handle.within_limit(direction, path.as_str()); Self { @@ -1690,7 +1690,7 @@ impl Gate { } /// Hold the request to the peer's grant alone, once its own token authorized it. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn named(mut self) -> Self { self.part = Part::Granted; self @@ -1698,7 +1698,7 @@ impl Gate { /// A gate for a request under a namespace the peer announced, while `live` stays open: /// the announce stands in for the scope, as its own token may have authorized it. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn announced( handle: Handle, path: crate::PathOwned, @@ -1712,7 +1712,7 @@ impl Gate { } /// Whether the session allows the path right now. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn allows(&self) -> bool { let path = self.path.as_str(); self.handle.within_grant(self.direction, path) @@ -1724,31 +1724,31 @@ impl Gate { } /// Whether the peer's request token must be verified separately from session scope. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn token_decides(&self) -> bool { self.handle.token_decides(self.direction) } /// Verify an incoming request's token against the local acceptor. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn verify(&self, token: crate::setup::Token, hold: Option) -> RequestVerdict { self.handle.verify_request(token, hold) } /// What the session allows in this gate's direction, once it may have changed since `epoch`. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn poll_permit(&self, epoch: &mut u64, waiter: &kio::Waiter) -> Poll { self.handle.poll_permit(self.direction, epoch, waiter) } /// Preserve setup ordering before the first discovery snapshot. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn poll_setup_answered(&self, waiter: &kio::Waiter) -> Poll<()> { self.handle.poll_setup_answered(waiter) } /// Settle tokens that might admit this request before its first wire operation. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn poll_ready(&mut self, waiter: &kio::Waiter) -> Poll<()> { if self.admitted { return Poll::Ready(()); @@ -1790,7 +1790,7 @@ impl Gate { /// Resolve once the session no longer allows the path. A union that is still /// `None` (no answer yet, or a version without AUTH) and a session never limited /// allow everything. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn poll_denied(&mut self, waiter: &kio::Waiter) -> Poll<()> { while let Poll::Ready(permit) = self.handle.poll_permit(self.direction, &mut self.epoch, waiter) { let path = self.path.as_str(); @@ -1812,7 +1812,7 @@ impl Gate { /// The default acceptor's answer to the peer's connection credential: the grant /// the session's origin handles allow, within the limit as it changes. -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) struct DefaultGrant { handle: Handle, base: Grant, @@ -1823,7 +1823,7 @@ pub(crate) struct DefaultGrant { } impl DefaultGrant { - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn new(handle: Handle, base: Grant) -> Self { let limit = handle.state.read().limit.clone(); Self { @@ -1836,7 +1836,7 @@ impl DefaultGrant { } /// The grant to send next: the first, then each one a new limit changes. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn poll(&mut self, waiter: &kio::Waiter) -> Poll { while let Poll::Ready(limit) = self.handle.poll_limit(&mut self.epoch, waiter) { self.limit = limit; @@ -1855,7 +1855,7 @@ impl DefaultGrant { /// The close reason naming a broadcast published outside the grant. [`Error`] carries /// no payload, so the path travels here, in the session's own terms. -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn unauthorized_reason(path: &crate::Path) -> String { format!("unauthorized: {path}") } @@ -1870,7 +1870,7 @@ pub(crate) fn unauthorized_reason(path: &crate::Path) -> String { /// publication. Only the dialing side enforces: a server's publish origin is everything /// the peer may read, not what it intends to push. #[derive(Default)] -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) struct Enforce { epoch: u64, permit: Option, @@ -1885,7 +1885,7 @@ pub(crate) struct Enforce { impl Enforce { /// Resolve with the first broadcast announced outside the union, or `None` once the /// origin ends. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn poll( &mut self, handle: &Handle, diff --git a/rs/moq-net/src/coding/codes.rs b/rs/moq-net/src/coding/codes.rs index 860419f14c4..2bd51bc3ce4 100644 --- a/rs/moq-net/src/coding/codes.rs +++ b/rs/moq-net/src/coding/codes.rs @@ -13,7 +13,7 @@ use crate::{Error, StreamError, ietf, lite}; /// /// Encoding and decoding live on one trait so a peer cannot be told a code from one table /// and read against another: implement both halves or neither. -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub trait StreamCodes { /// The code to reset a stream, or send STOP_SENDING, with. fn encode_stream_code(&self, err: &StreamError) -> u32; diff --git a/rs/moq-net/src/coding/decode.rs b/rs/moq-net/src/coding/decode.rs index dd756e7034a..76fc11af785 100644 --- a/rs/moq-net/src/coding/decode.rs +++ b/rs/moq-net/src/coding/decode.rs @@ -6,7 +6,7 @@ use super::{BoundsExceeded, Form, varint}; /// Read the value from a [`Decoder`] using the given version. /// /// If [DecodeError::Short] is returned, the caller should try again with more data. -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub trait Decode: Sized { /// Decode the value from the front of the decoder. fn decode(r: &mut Decoder<'_>, version: V) -> Result; @@ -113,7 +113,7 @@ pub enum DecodeError { impl DecodeError { /// A complete frame cannot be extended by reading more stream bytes. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn complete(self) -> Self { match self { Self::Short => Self::InvalidValue, @@ -133,7 +133,7 @@ impl From for DecodeError { /// A read either consumes exactly what it returns or fails and consumes nothing, so a /// [`DecodeError::Short`] can be retried once more bytes arrive. #[derive(Debug, Clone)] -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub struct Decoder<'a> { buf: &'a [u8], form: Form, @@ -141,31 +141,31 @@ pub struct Decoder<'a> { impl<'a> Decoder<'a> { /// Read `buf`, with varints in the given form. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn new(buf: &'a [u8], form: Form) -> Self { Self { buf, form } } /// The varint form this decoder reads. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn form(&self) -> Form { self.form } /// The number of unread bytes. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn remaining(&self) -> usize { self.buf.len() } /// Whether every byte has been read. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn is_empty(&self) -> bool { self.buf.is_empty() } /// Read `len` raw bytes. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn slice(&mut self, len: usize) -> Result<&'a [u8], DecodeError> { let Some((head, rest)) = self.buf.split_at_checked(len) else { return Err(DecodeError::Short); @@ -175,32 +175,32 @@ impl<'a> Decoder<'a> { } /// Read every remaining byte. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn rest(&mut self) -> &'a [u8] { std::mem::take(&mut self.buf) } /// Split off the next `len` bytes as their own decoder, e.g. a size-prefixed body. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn sub(&mut self, len: usize) -> Result { Ok(Self::new(self.slice(len)?, self.form)) } /// Read a single byte. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn u8(&mut self) -> Result { Ok(self.slice(1)?[0]) } /// Read a big-endian `u16`. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn u16(&mut self) -> Result { let b = self.slice(2)?; Ok(u16::from_be_bytes([b[0], b[1]])) } /// Read a byte that must be 0 or 1. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn bool(&mut self) -> Result { match self.u8()? { 0 => Ok(false), @@ -212,7 +212,7 @@ impl<'a> Decoder<'a> { /// Read a varint. #[cfg_attr(target_arch = "wasm32", inline)] #[cfg_attr(not(target_arch = "wasm32"), inline(always))] - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn varint(&mut self) -> Result { let (value, rest) = varint::read(self.buf, self.form)?; self.buf = rest; @@ -220,13 +220,13 @@ impl<'a> Decoder<'a> { } /// Read an optional varint: 0 is `None`, and `n + 1` is `Some(n)`. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn varint_opt(&mut self) -> Result, DecodeError> { Ok(self.varint()?.checked_sub(1)) } /// Read a varint length, then that many raw bytes. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn bytes(&mut self) -> Result<&'a [u8], DecodeError> { let start = self.buf; let len = usize::try_from(self.varint()?).map_err(|_| DecodeError::BoundsExceeded)?; @@ -234,7 +234,7 @@ impl<'a> Decoder<'a> { } /// Read a varint length, then that many bytes of UTF-8. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn string(&mut self) -> Result { Ok(String::from_utf8(self.bytes()?.to_vec())?) } diff --git a/rs/moq-net/src/coding/encode.rs b/rs/moq-net/src/coding/encode.rs index 34bfa547a5a..709454df43c 100644 --- a/rs/moq-net/src/coding/encode.rs +++ b/rs/moq-net/src/coding/encode.rs @@ -36,7 +36,7 @@ impl From for EncodeError { } /// Write the value to an [`Encoder`] using the given version. -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub trait Encode { /// Encode the value to the given encoder, which may hold partial output on error. fn encode(&self, w: &mut Encoder<'_>, version: V) -> Result<(), EncodeError>; @@ -68,7 +68,7 @@ impl<'a> Encoder<'a> { } /// The varint form this encoder writes. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn form(&self) -> Form { self.form } @@ -79,19 +79,19 @@ impl<'a> Encoder<'a> { } /// Write a single byte. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn u8(&mut self, v: u8) { self.buf.push(v); } /// Write a big-endian `u16`. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn u16(&mut self, v: u16) { self.buf.extend_from_slice(&v.to_be_bytes()); } /// Write a bool as a 0 or 1 byte. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn bool(&mut self, v: bool) { self.buf.push(v as u8); } @@ -104,7 +104,7 @@ impl<'a> Encoder<'a> { } /// Write an optional varint: `None` as 0, and `Some(n)` as `n + 1`. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn varint_opt(&mut self, v: Option) -> Result<(), EncodeError> { let v = match v { Some(v) => v.checked_add(1).ok_or(EncodeError::TooLarge)?, @@ -114,7 +114,7 @@ impl<'a> Encoder<'a> { } /// Write a varint length, then the raw bytes. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn bytes(&mut self, v: &[u8]) -> Result<(), EncodeError> { self.varint(v.len() as u64)?; self.slice(v); @@ -122,7 +122,7 @@ impl<'a> Encoder<'a> { } /// Write a varint length, then the UTF-8 bytes. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn string(&mut self, v: &str) -> Result<(), EncodeError> { self.bytes(v.as_bytes()) } @@ -130,7 +130,7 @@ impl<'a> Encoder<'a> { /// Reserve a varint size prefix for the body written next; [`Self::fill`] sizes it. /// /// One byte is reserved, which most bodies fit, so they never move. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn prefix_varint(&mut self) -> Prefix { self.buf.push(0); Prefix { @@ -140,7 +140,7 @@ impl<'a> Encoder<'a> { } /// Reserve a big-endian `u16` size prefix for the body written next; [`Self::fill`] sizes it. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn prefix_u16(&mut self) -> Prefix { self.buf.extend_from_slice(&[0, 0]); Prefix { @@ -150,13 +150,13 @@ impl<'a> Encoder<'a> { } /// The number of bytes written since `prefix` was reserved. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn since(&self, prefix: &Prefix) -> usize { self.buf.len() - prefix.body } /// Drop a reserved prefix and everything written since, as if neither was written. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn discard(&mut self, prefix: Prefix) { let start = match prefix.kind { PrefixKind::Varint => prefix.body - 1, @@ -166,7 +166,7 @@ impl<'a> Encoder<'a> { } /// Size a reserved prefix to everything written since. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn fill(&mut self, prefix: Prefix) -> Result<(), EncodeError> { let body = prefix.body; let end = self.buf.len(); @@ -201,7 +201,7 @@ impl<'a> Encoder<'a> { /// A size prefix reserved ahead of a body, sized by [`Encoder::fill`] once it is written. #[must_use = "an unfilled prefix leaves a zero size on the wire"] #[derive(Debug)] -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub struct Prefix { /// Where the body starts, just past the reserved bytes. body: usize, @@ -209,7 +209,7 @@ pub struct Prefix { } #[derive(Debug)] -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] enum PrefixKind { Varint, U16, diff --git a/rs/moq-net/src/coding/varint.rs b/rs/moq-net/src/coding/varint.rs index 982fd6802fc..33e4ec6945d 100644 --- a/rs/moq-net/src/coding/varint.rs +++ b/rs/moq-net/src/coding/varint.rs @@ -168,7 +168,7 @@ fn write_leading_ones(value: u64, out: &mut Vec) { /// Decode a varint in `form` from the front of `buf`, returning it and the rest of `buf`. #[cfg_attr(target_arch = "wasm32", inline)] #[cfg_attr(not(target_arch = "wasm32"), inline(always))] -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(super) fn read(buf: &[u8], form: Form) -> Result<(u64, &[u8]), DecodeError> { match form { Form::Quic => read_quic(buf), @@ -200,7 +200,7 @@ fn read_quic(buf: &[u8]) -> Result<(u64, &[u8]), DecodeError> { #[cfg_attr(target_arch = "wasm32", inline)] #[cfg_attr(not(target_arch = "wasm32"), inline(always))] -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] fn read_leading_ones(buf: &[u8], seven: bool) -> Result<(u64, &[u8]), DecodeError> { let Some((&first, rest)) = buf.split_first() else { return Err(DecodeError::Short); @@ -288,13 +288,13 @@ pub fn encode_quic(value: u64, w: &mut W) -> Result<(), Encode /// Map a signed value onto the unsigned range: `(n << 1) ^ (n >> 63)`. /// /// Small magnitudes stay small (-1 -> 1, 1 -> 2, -2 -> 3, ...), and all of `i64` fits. -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) const fn zigzag(signed: i64) -> u64 { ((signed << 1) ^ (signed >> 63)) as u64 } /// The inverse of [`zigzag`]. -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) const fn unzigzag(value: u64) -> i64 { ((value >> 1) as i64) ^ -((value & 1) as i64) } diff --git a/rs/moq-net/src/coding/version.rs b/rs/moq-net/src/coding/version.rs index 4d89150a8e6..ef66c323cdd 100644 --- a/rs/moq-net/src/coding/version.rs +++ b/rs/moq-net/src/coding/version.rs @@ -40,7 +40,7 @@ impl fmt::Debug for Version { /// A list of versions in preferred order. #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub struct Versions(Vec); impl Decode for Versions { diff --git a/rs/moq-net/src/epoch.rs b/rs/moq-net/src/epoch.rs index ee23e564b76..12e3eaf941f 100644 --- a/rs/moq-net/src/epoch.rs +++ b/rs/moq-net/src/epoch.rs @@ -35,14 +35,14 @@ impl Epoch { impl Epoch { /// The UUID's 16 bytes, as the wire carries them. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn to_bytes(&self) -> [u8; 16] { // Parsing enforces the canonical form, so this cannot fail. uuid::Uuid::parse_str(&self.0).unwrap().into_bytes() } /// Parse the wire's 16 bytes, refusing anything but a UUIDv7 with the RFC variant. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn from_bytes(bytes: &[u8]) -> Result { let uuid = uuid::Uuid::from_slice(bytes).map_err(|_| InvalidEpoch)?; uuid.hyphenated().to_string().parse() diff --git a/rs/moq-net/src/fuzz.rs b/rs/moq-net/src/fuzz.rs index 29abae75ae5..a1ac17e7001 100644 --- a/rs/moq-net/src/fuzz.rs +++ b/rs/moq-net/src/fuzz.rs @@ -283,7 +283,7 @@ pub fn excluding(origin: crate::origin::Consumer, peer: crate::Hop) -> crate::or /// A session's snapshot of its peer's initial announcements, for the synced bench. /// Drop it to land the snapshot. -pub struct Snapshot(#[allow(dead_code)] crate::model::Snapshot); +pub struct Snapshot(#[allow(dead_code, reason = "held for its drop, which lands the snapshot")] crate::model::Snapshot); /// Start a snapshot under `prefix`, as a session requesting announcements there does. pub fn snapshot(origin: &crate::origin::Producer, prefix: &str) -> Snapshot { diff --git a/rs/moq-net/src/goaway.rs b/rs/moq-net/src/goaway.rs index f1659e60c9c..47266a8b40e 100644 --- a/rs/moq-net/src/goaway.rs +++ b/rs/moq-net/src/goaway.rs @@ -180,7 +180,7 @@ impl Consumer { /// why the flag is not merely a read of the channel), and a wakeup for the /// per-source tasks, which have to react to a peer that drains and then goes quiet. #[derive(Clone)] -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) struct GoingAway { flag: Arc, received: Consumer, @@ -188,13 +188,13 @@ pub(crate) struct GoingAway { impl GoingAway { /// Mark the session as going away, returning whether this was the first time. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn set(&self) -> bool { !self.flag.swap(true, Ordering::AcqRel) } /// Whether a GOAWAY has been received. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn is_set(&self) -> bool { self.flag.load(Ordering::Acquire) } @@ -204,7 +204,7 @@ impl GoingAway { /// /// Stays `Ready` once set, so a caller must treat what it does in response as /// idempotent rather than as an edge. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn poll(&self, waiter: &kio::Waiter) -> Poll<()> { // Presence only, rather than [`Consumer::poll`]: this stays ready for the rest // of the session, and every wakeup of every per-source task would otherwise @@ -239,7 +239,7 @@ impl Default for GoingAway { /// The halves handed to a protocol driver's `start()`. #[derive(Clone)] -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) struct Protocol { /// Awaited by the driver's send path; firing means "encode and send GOAWAY now". trigger: kio::Consumer>, @@ -258,7 +258,7 @@ impl Protocol { /// require the session be closed over (draft-19 sect 10.4). Keeping the first /// payload instead would leave an observer acting on a URI the peer has since /// replaced, with no way to tell. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn record(&self, goaway: Goaway) -> Result<()> { if !self.going_away.set() { return Err(Error::ProtocolViolation); @@ -273,7 +273,7 @@ impl Protocol { /// /// `None` if the trigger was dropped without firing (the session is closing /// without a drain), so nothing should be sent. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn poll_triggered(&self, waiter: &kio::Waiter) -> Poll> { match self.trigger.poll(waiter, |state| match &**state { Some(goaway) => Poll::Ready(goaway.clone()), @@ -291,7 +291,7 @@ impl Protocol { /// The draft makes the deadline the sender's promise, not the peer's, so the /// driver arms this after the message hits the wire rather than making the /// caller hold a handle and await it. -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) struct Enforce { session: S, /// The armed deadline, or `None` when the GOAWAY carried no timeout (ready @@ -300,7 +300,7 @@ pub(crate) struct Enforce { } impl Enforce { - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn new(runtime: &crate::time::Deadlines, session: S, timeout: Option) -> Self { Self { session, @@ -309,7 +309,7 @@ impl Enforce { } /// Ready once the session closes on its own or the deadline passes (closing it). - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn poll(&mut self, waiter: &kio::Waiter) -> Poll<()> { let Some((deadline, timeout)) = &mut self.deadline else { return Poll::Ready(()); @@ -342,7 +342,7 @@ pub(crate) async fn enforce( } /// The halves held by the public [`crate::Session`]. -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) struct Handle { /// Cloned into each [`Producer`] handed out by `crate::Session::drain`. trigger: kio::Producer>, @@ -356,7 +356,7 @@ impl Handle { /// Create the session-side handle and its protocol-side counterpart. /// /// `redirect` is whether this side may name a URI in its own GOAWAY. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn new(redirect: bool) -> (Self, Protocol) { let trigger = kio::Producer::new(None); let received = kio::Producer::new(None); @@ -385,7 +385,7 @@ impl Handle { /// A send half. Handing one out is always allowed; sending twice is what /// [`Producer::send`] refuses, so a caller never has to ask whether the slot /// is still free before deciding how to shut down. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn producer(&self) -> Producer { Producer { trigger: self.trigger.clone(), @@ -394,7 +394,7 @@ impl Handle { } /// A fresh handle on the receive half. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn consumer(&self) -> Consumer { self.consumer.clone() } diff --git a/rs/moq-net/src/ietf/mod.rs b/rs/moq-net/src/ietf/mod.rs index 6b08cb6ea84..d10db6687d9 100644 --- a/rs/moq-net/src/ietf/mod.rs +++ b/rs/moq-net/src/ietf/mod.rs @@ -4,8 +4,14 @@ //! //! You should not use this module directly; see [crate] for the high-level API. -// Private codec entry points remain testable when their session callers are absent. -#![cfg_attr(not(feature = "async"), allow(dead_code, unused_imports))] +#![cfg_attr( + not(feature = "async"), + allow( + dead_code, + unused_imports, + reason = "private codec entry points remain testable when their session callers are absent" + ) +)] #[macro_use] mod parameters; diff --git a/rs/moq-net/src/ietf/parameters.rs b/rs/moq-net/src/ietf/parameters.rs index a662500e4b8..d99afbb0473 100644 --- a/rs/moq-net/src/ietf/parameters.rs +++ b/rs/moq-net/src/ietf/parameters.rs @@ -500,7 +500,7 @@ pub(crate) fn skip_unlisted(r: &mut Decoder<'_>, version: Version, key: u64) -> /// ``` macro_rules! encode_params { ($w:expr, $version:expr, $($key:expr => $val:expr),* $(,)?) => {{ - #[allow(unused)] + #[allow(unused, reason = "a compile-time key order check")] const _: () = { let _keys: &[u64] = &[$($key),*]; let mut _i = 1; @@ -512,14 +512,14 @@ macro_rules! encode_params { let _version: $crate::ietf::Version = $version; - #[allow(unused_mut)] + #[allow(unused_mut, reason = "a call with no parameters never counts one")] let mut _count: usize = 0; $(_count += if $crate::ietf::Param::param_present(&$val) { 1 } else { 0 };)* $w.varint(_count as u64)?; - #[allow(unused_mut, unused_assignments)] + #[allow(unused_mut, unused_assignments, reason = "a call with no parameters never tracks a key")] let mut _prev_key: u64 = 0; - #[allow(unused_mut, unused_assignments)] + #[allow(unused_mut, unused_assignments, reason = "a call with no parameters never tracks a key")] let mut _first: bool = true; $( if $crate::ietf::Param::param_present(&$val) { @@ -561,7 +561,7 @@ macro_rules! encode_params { /// ``` macro_rules! decode_params { ($r:expr, $version:expr, $($key:expr => $name:ident: $ty:ty $(where $gate:expr)?),* $(,)?) => { - #[allow(unused)] + #[allow(unused, reason = "a compile-time key order check")] const _: () = { let _keys: &[u64] = &[$($key),*]; let mut _i = 1; @@ -572,7 +572,7 @@ macro_rules! decode_params { }; // Use internal Option wrapper for duplicate detection, then shadow with Default. - $(#[allow(unused_mut, non_snake_case)] let mut $name: Option<$ty> = None;)* + $(#[allow(unused_mut, non_snake_case, reason = "names come from the call site, and an absent parameter is never assigned")] let mut $name: Option<$ty> = None;)* { let _version: $crate::ietf::Version = $version; @@ -581,7 +581,7 @@ macro_rules! decode_params { return Err($crate::coding::DecodeError::TooMany); } - #[allow(unused_mut, unused_assignments)] + #[allow(unused_mut, unused_assignments, reason = "a call with no parameters never tracks a key")] let mut _prev_key: u64 = 0; for _i in 0.._count { let _wire = $r.varint()?; @@ -614,7 +614,7 @@ macro_rules! decode_params { } // Shadow with unwrap_or_default: Option defaults to None, T defaults to T::default() - $(#[allow(unused_variables)] let $name: $ty = $name.unwrap_or_default();)* + $(#[allow(unused_variables, reason = "a caller may decode a parameter it never reads")] let $name: $ty = $name.unwrap_or_default();)* }; } diff --git a/rs/moq-net/src/ietf/publisher.rs b/rs/moq-net/src/ietf/publisher.rs index 61f61d9cd60..8456e27ce45 100644 --- a/rs/moq-net/src/ietf/publisher.rs +++ b/rs/moq-net/src/ietf/publisher.rs @@ -4772,9 +4772,13 @@ struct GroupServe { budget: kio::coop::Budget, } -// A state machine's enum is its storage: one transient instance per stream, so the -// big variant is the working state, not padding held in bulk. -#[allow(clippy::large_enum_variant)] +#[cfg_attr( + target_pointer_width = "64", + expect( + clippy::large_enum_variant, + reason = "a state machine's enum is its storage: one transient instance per stream, so the big variant is the working state, not padding held in bulk" + ) +)] enum GroupState { /// Waiting for stream credit on this machine's own session handle. Open, diff --git a/rs/moq-net/src/ietf/session.rs b/rs/moq-net/src/ietf/session.rs index 8c7b01bd03e..f1bddb44241 100644 --- a/rs/moq-net/src/ietf/session.rs +++ b/rs/moq-net/src/ietf/session.rs @@ -768,7 +768,10 @@ fn peer_from_params(params: &ietf::Parameters, version: Version) -> Result( runtime: crate::time::Deadlines, mut session: S, diff --git a/rs/moq-net/src/ietf/subscriber.rs b/rs/moq-net/src/ietf/subscriber.rs index d590a411019..1301737dbe7 100644 --- a/rs/moq-net/src/ietf/subscriber.rs +++ b/rs/moq-net/src/ietf/subscriber.rs @@ -819,7 +819,10 @@ impl Subscriber where S: crate::transport::poll::Boxable, { - #[allow(clippy::too_many_arguments)] + #[expect( + clippy::too_many_arguments, + reason = "private plumbing; a single-use argument struct would only rename the parameters" + )] pub fn new( runtime: crate::time::Deadlines, session: S, @@ -1212,7 +1215,10 @@ where /// `live` tracks the suffixes this stream has advertised, so a repeat is recognized /// as an update rather than a second advertisement, and the caller can release /// whatever is still held when the stream ends. - #[allow(clippy::too_many_arguments)] + #[expect( + clippy::too_many_arguments, + reason = "private plumbing; a single-use argument struct would only rename the parameters" + )] async fn run_namespace_entries( &mut self, stream: &mut Stream, @@ -4662,7 +4668,10 @@ where /// /// A pre-draft-20 join resuming partway through a group asks for all of it, so the /// objects below `resume` are dropped: another route already delivered them. - #[allow(clippy::too_many_arguments)] + #[expect( + clippy::too_many_arguments, + reason = "private plumbing; a single-use argument struct would only rename the parameters" + )] async fn run_fill_objects( &mut self, stream: &mut Reader, diff --git a/rs/moq-net/src/ietf/token.rs b/rs/moq-net/src/ietf/token.rs index 70f80f000e5..c68720edeec 100644 --- a/rs/moq-net/src/ietf/token.rs +++ b/rs/moq-net/src/ietf/token.rs @@ -37,7 +37,7 @@ pub fn from_setup(params: &Parameters, version: Version) -> Result } /// Present `token` in our SETUP, by value. -#[cfg_attr(not(test), expect(dead_code))] +#[cfg_attr(not(test), expect(dead_code, reason = "only tests use it"))] pub fn into_setup(params: &mut Parameters, token: &Token, version: Version) -> Result<(), EncodeError> { params.set_bytes(ParameterBytes::AuthorizationToken, encode(token, version)?); Ok(()) diff --git a/rs/moq-net/src/lib.rs b/rs/moq-net/src/lib.rs index c7999766c73..60c0a12dc11 100644 --- a/rs/moq-net/src/lib.rs +++ b/rs/moq-net/src/lib.rs @@ -1,5 +1,3 @@ -#![cfg_attr(test, allow(clippy::disallowed_methods))] - //! # moq-net: Media over QUIC networking layer //! //! `moq-net` is the networking layer for Media over QUIC: real-time pub/sub with built-in @@ -76,10 +74,6 @@ //! instant. #![warn(missing_docs)] -// The browser transport is `!Send`, so on wasm the shared state behind these `Arc`s is -// too and clippy suggests `Rc`. The same code is genuinely cross-thread on native, so -// `Arc` stays and the lint is unactionable here. -#![cfg_attr(target_arch = "wasm32", allow(clippy::arc_with_non_send_sync))] pub mod auth; #[cfg(feature = "async")] diff --git a/rs/moq-net/src/lite/mod.rs b/rs/moq-net/src/lite/mod.rs index c2453f181b8..e16195e30f9 100644 --- a/rs/moq-net/src/lite/mod.rs +++ b/rs/moq-net/src/lite/mod.rs @@ -4,8 +4,14 @@ //! //! Specification: [] -// Private codec entry points remain testable when their session callers are absent. -#![cfg_attr(not(feature = "async"), allow(dead_code, unused_imports))] +#![cfg_attr( + not(feature = "async"), + allow( + dead_code, + unused_imports, + reason = "private codec entry points remain testable when their session callers are absent" + ) +)] mod announce; mod auth; diff --git a/rs/moq-net/src/lite/publisher.rs b/rs/moq-net/src/lite/publisher.rs index 63504585370..25d191a0efa 100644 --- a/rs/moq-net/src/lite/publisher.rs +++ b/rs/moq-net/src/lite/publisher.rs @@ -290,9 +290,6 @@ struct Control { state: ControlState, } -// A state machine's enum is its storage: one transient instance per stream, so the -// big variant is the working state, not padding held in bulk. -#[allow(clippy::large_enum_variant)] enum ControlState { /// Reading the stream's type. Start { @@ -842,9 +839,10 @@ struct AnnounceServe { state: AnnounceState, } -// A state machine's enum is its storage: one transient instance per stream, so the -// big variant is the working state, not padding held in bulk. -#[allow(clippy::large_enum_variant)] +#[expect( + clippy::large_enum_variant, + reason = "a state machine's enum is its storage: one transient instance per stream, so the big variant is the working state, not padding held in bulk" +)] enum AnnounceState { /// Reading the ANNOUNCE_REQUEST. Decode, @@ -2220,9 +2218,10 @@ impl Request for SubscribeServe { } /// Answers a FETCH stream: a single cached group, streamed in order. -// A state machine's enum is its storage: one transient instance per stream, so the -// big variant is the working state, not padding held in bulk. -#[allow(clippy::large_enum_variant)] +#[expect( + clippy::large_enum_variant, + reason = "a state machine's enum is its storage: one transient instance per stream, so the big variant is the working state, not padding held in bulk" +)] enum FetchServe { /// Waiting for the fetched group. Fetch { @@ -3398,10 +3397,10 @@ fn buffer_zigzag_delta( /// What [`recv_next`] pulled from the one subscriber: the next group to serve, the next /// best-effort datagram to forward, the track declaring its exclusive final sequence, or /// the track finishing (the live edge having reached that boundary). -// A `group::Consumer` carries an inline frame prefetch, so the `Group` variant dwarfs the -// others. This is a transient, one-at-a-time return value, so the padding is never held in -// bulk; boxing would only add a per-group allocation. -#[allow(clippy::large_enum_variant)] +#[expect( + clippy::large_enum_variant, + reason = "a `group::Consumer` carries an inline frame prefetch, so the `Group` variant dwarfs the others. This is a transient, one-at-a-time return value, so the padding is never held in bulk; boxing would only add a per-group allocation" +)] enum Recv { Group(group::Consumer), Datagram(crate::model::datagram::Stored), @@ -4213,9 +4212,13 @@ struct GroupServe { budget: kio::coop::Budget, } -// A state machine's enum is its storage: one transient instance per stream, so the -// big variant is the working state, not padding held in bulk. -#[allow(clippy::large_enum_variant)] +#[cfg_attr( + target_pointer_width = "64", + expect( + clippy::large_enum_variant, + reason = "a state machine's enum is its storage: one transient instance per stream, so the big variant is the working state, not padding held in bulk" + ) +)] enum GroupState { /// Waiting for stream credit on this machine's own session handle. Open, diff --git a/rs/moq-net/src/lite/subscriber.rs b/rs/moq-net/src/lite/subscriber.rs index 2254f3c7014..1713b89ce9a 100644 --- a/rs/moq-net/src/lite/subscriber.rs +++ b/rs/moq-net/src/lite/subscriber.rs @@ -267,7 +267,10 @@ impl Subscriber { /// Records the advertisement either way. Returns `Ok(true)` if it was accepted /// and attached a route, or `Ok(false)` if it was declined locally. - #[allow(clippy::too_many_arguments)] + #[expect( + clippy::too_many_arguments, + reason = "private plumbing; a single-use argument struct would only rename the parameters" + )] fn start_announce( &mut self, path: PathOwned, @@ -738,9 +741,10 @@ struct UniServe { state: UniState, } -// A state machine's enum is its storage: one transient instance per stream, so the -// big variant is the working state, not padding held in bulk. -#[allow(clippy::large_enum_variant)] +#[expect( + clippy::large_enum_variant, + reason = "a state machine's enum is its storage: one transient instance per stream, so the big variant is the working state, not padding held in bulk" +)] enum UniState { /// Reading the stream's type. Start { @@ -845,9 +849,10 @@ struct GroupRecv { state: GroupRecvState, } -// A state machine's enum is its storage: one transient instance per stream, so the -// big variant is the working state, not padding held in bulk. -#[allow(clippy::large_enum_variant)] +#[expect( + clippy::large_enum_variant, + reason = "a state machine's enum is its storage: one transient instance per stream, so the big variant is the working state, not padding held in bulk" +)] enum GroupRecvState { /// Reading the GROUP header. Header, @@ -1308,9 +1313,10 @@ struct RecvBandwidth { state: BandwidthState, } -// A state machine's enum is its storage: one transient instance per stream, so the -// big variant is the working state, not padding held in bulk. -#[allow(clippy::large_enum_variant)] +#[expect( + clippy::large_enum_variant, + reason = "a state machine's enum is its storage: one transient instance per stream, so the big variant is the working state, not padding held in bulk" +)] enum BandwidthState { /// lite-05+ negotiates probing: only open a PROBE stream if the peer /// advertised it (Report or higher) in its SETUP. Older versions have no @@ -2444,7 +2450,7 @@ mod tests { fixtures.push((track, callers, tail, sub, scan, fetches)); } let (track, _callers, tail, sub, scan, fetches) = &mut fixtures[0]; - #[allow(clippy::disallowed_methods)] + #[expect(clippy::disallowed_methods, reason = "the scan cost is real elapsed time")] let began = std::time::Instant::now(); for sequence in runs * 2..runs * 2 + EVENTS { arrive(track, tail, sequence, start); @@ -5352,9 +5358,13 @@ impl SubStream { } } -// One per track copy, which holds a live stream while anyone reads it, so boxing it -// would add an allocation per upstream subscription without saving memory. -#[allow(clippy::large_enum_variant)] +#[cfg_attr( + target_pointer_width = "64", + expect( + clippy::large_enum_variant, + reason = "one per track copy, which holds a live stream while anyone reads it, so boxing it would add an allocation per upstream subscription without saving memory" + ) +)] enum Sub { None, Active(SubStream), @@ -5966,9 +5976,10 @@ impl TrackServe { } /// What a demand change asks the serve loop to do next. -// A state machine's enum is its storage: one transient instance per stream, so the -// big variant is the working state, not padding held in bulk. -#[allow(clippy::large_enum_variant)] +#[expect( + clippy::large_enum_variant, + reason = "a state machine's enum is its storage: one transient instance per stream, so the big variant is the working state, not padding held in bulk" +)] enum Begin { /// Nothing further: the update (if any) sits in the active stream's write /// buffer, flushed by the loop. @@ -6118,9 +6129,10 @@ struct TrackServeRun { gate: crate::auth::Gate, } -// A state machine's enum is its storage: one transient instance per stream, so the -// big variant is the working state, not padding held in bulk. -#[allow(clippy::large_enum_variant)] +#[expect( + clippy::large_enum_variant, + reason = "a state machine's enum is its storage: one transient instance per stream, so the big variant is the working state, not padding held in bulk" +)] enum TrackRunState { /// Lite05+ learns the track's immutable properties once, up front, via a /// TRACK stream. The timescale then flows into every SUBSCRIBE and FETCH @@ -6474,9 +6486,10 @@ struct ServeLoop { held: Option>, } -// A state machine's enum is its storage: one transient instance per stream, so the -// big variant is the working state, not padding held in bulk. -#[allow(clippy::large_enum_variant)] +#[expect( + clippy::large_enum_variant, + reason = "a state machine's enum is its storage: one transient instance per stream, so the big variant is the working state, not padding held in bulk" +)] enum ServeMode { /// Selecting the next event. Select, diff --git a/rs/moq-net/src/model/bandwidth.rs b/rs/moq-net/src/model/bandwidth.rs index c225bca57c7..61d3268cccd 100644 --- a/rs/moq-net/src/model/bandwidth.rs +++ b/rs/moq-net/src/model/bandwidth.rs @@ -105,7 +105,7 @@ impl Producer { } /// A handle that mints consumers without being one, so holding it is not demand. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn weak(&self) -> Weak { Weak(self.state.weak()) } @@ -172,12 +172,12 @@ impl Default for Producer { /// Mints [`Consumer`]s on demand without counting as one, nor keeping the channel open. #[derive(Clone)] -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub struct Weak(kio::ProducerWeak); impl Weak { /// A new consumer, which reports the closure once the producer is gone. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn consume(&self) -> Consumer { Consumer { inner: Inner::Whole(self.0.consume()), diff --git a/rs/moq-net/src/model/broadcast.rs b/rs/moq-net/src/model/broadcast.rs index c84c445b631..f6e82588fcb 100644 --- a/rs/moq-net/src/model/broadcast.rs +++ b/rs/moq-net/src/model/broadcast.rs @@ -651,7 +651,7 @@ impl Drop for Alive { /// Whether a path request still names the source that handed out its track. #[derive(Clone, Default)] -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/answer.md pub(crate) enum RequestValidity { #[default] @@ -663,13 +663,13 @@ pub(crate) enum RequestValidity { } impl RequestValidity { - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/answer.md pub(crate) fn token(route: Option>) -> Self { route.map(Self::Route).unwrap_or_default() } - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/answer.md pub(crate) fn for_source(route: &crate::origin::Dynamic, path: &crate::Path) -> Self { route @@ -679,7 +679,7 @@ impl RequestValidity { } /// Capture one selection period so a pending request never revives after a replacement. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/answer.md pub(crate) fn start(&self) -> Self { match self { @@ -688,7 +688,7 @@ impl RequestValidity { } } - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/answer.md pub(crate) fn check(&self, waiter: &kio::Waiter) -> Result<(), crate::Error> { match self { @@ -721,7 +721,7 @@ impl RequestValidity { } #[cfg(test)] -#[allow(missing_docs)] // test-only assertion helpers +#[expect(missing_docs, reason = "test-only assertion helpers")] impl Producer { pub fn assert_create_track( &mut self, @@ -738,12 +738,12 @@ impl Producer { /// /// A peer's retraction and a dead session end the source the same way: a broadcast /// carries no end cause past this hop. Shared by the lite and IETF subscribers. -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/answer.md pub(crate) struct SourceGuard(Producer); impl SourceGuard { - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn new(producer: Producer) -> Self { Self(producer) } @@ -906,7 +906,7 @@ impl Dynamic { use futures::FutureExt; #[cfg(test)] -#[allow(missing_docs)] // test-only assertion helpers +#[expect(missing_docs, reason = "test-only assertion helpers")] impl Dynamic { pub fn assert_request(&mut self) -> track::Request { kio::wait(|waiter| self.poll_requested_track(waiter)) @@ -1248,7 +1248,7 @@ impl Demand { } #[cfg(test)] -#[allow(missing_docs)] // test-only assertion helpers +#[expect(missing_docs, reason = "test-only assertion helpers")] impl Consumer { pub fn assert_not_closed(&self) { assert!( diff --git a/rs/moq-net/src/model/frame.rs b/rs/moq-net/src/model/frame.rs index 0846c7ff098..14b81739700 100644 --- a/rs/moq-net/src/model/frame.rs +++ b/rs/moq-net/src/model/frame.rs @@ -169,23 +169,23 @@ impl Buffer { /// size fits what remains is allocated up front; past that, its buffer grows with the /// bytes received. Each frame returns its share once it completes or aborts. #[derive(Clone)] -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/ingest.md pub(crate) struct Budget(Arc); impl Budget { /// Enough for a handful of large keyframes in flight at once. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] const DEFAULT: usize = 16 * 1024 * 1024; - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/ingest.md pub(crate) fn new(bytes: usize) -> Self { Self(Arc::new(AtomicUsize::new(bytes))) } /// Take `size` bytes of the budget, or `None` if that is more than remains. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(super) fn reserve(&self, size: usize) -> Option { self.0 .fetch_update(Ordering::Relaxed, Ordering::Relaxed, |left| left.checked_sub(size)) @@ -204,7 +204,7 @@ impl Default for Budget { } /// A frame's share of a [`Budget`], returned on drop. -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(super) struct Reservation { budget: Budget, size: usize, @@ -308,7 +308,7 @@ impl FrameBuf { } /// A buffer for a frame of `size` bytes that allocates only as bytes arrive. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(super) fn growing(size: usize) -> Self { Self::with_growth(size, true) } @@ -603,7 +603,7 @@ impl<'a> Producer<'a> { /// frame or a group finish cannot race this frame. /// /// Holds the frame's share of the session's [`Budget`], if it got one, until then. -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/ingest.md pub(crate) struct ProducerOwned { raw: Raw, @@ -620,7 +620,7 @@ impl std::ops::Deref for ProducerOwned { impl ProducerOwned { /// Transfer a receive handler's cancellation cleanup into its in-flight frame. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // private: capability gap // Public drivers still borrow frames; the owned public writer belongs to ingest. pub(crate) fn cancel_on_drop(mut self) -> Self { @@ -628,7 +628,7 @@ impl ProducerOwned { self } - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(super) fn new(group: group::Producer, buf: FrameBuf, info: Info, reserved: Option) -> Self { Self { raw: Raw { @@ -644,14 +644,14 @@ impl ProducerOwned { } /// Attach the parent group's ingress meter, so written chunks bump `bytes`. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(super) fn with_meter(mut self, meter: stats::Meter) -> Self { self.raw.stats = meter; self } /// Bytes still needed to complete the frame. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn remaining(&self) -> usize { self.raw.remaining() } @@ -664,28 +664,28 @@ impl ProducerOwned { /// to publish bytes nobody can observe yet. /// /// `coding::Reader::poll_read_frame` owns the pairing and is the only caller. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // private: tuning pub(crate) fn write(&mut self, chunk: B) -> Result<()> { self.raw.write(chunk) } /// Publish what has been written so far, waking consumers parked on the group. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // private: tuning pub(crate) fn notify(&self) { self.raw.group.as_ref().expect("frame owns its group").frame_notify(); } /// Commit the frame, verifying that all bytes were written. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn finish(mut self) -> Result { self.raw.finish()?; Ok(self.raw.group.take().expect("frame owns its group")) } /// Abort the frame (and its group) with the given error. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn abort(mut self, err: Error) -> Result<()> { self.raw.abort(err) } @@ -747,7 +747,7 @@ pub struct Consumer { // The group's channel, used to park while a partial frame fills. state: kio::Consumer, info: Info, - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // private: passthrough pub(crate) fields: Option>, source: Source, diff --git a/rs/moq-net/src/model/group.rs b/rs/moq-net/src/model/group.rs index a6737f39043..ecb73218d25 100644 --- a/rs/moq-net/src/model/group.rs +++ b/rs/moq-net/src/model/group.rs @@ -275,7 +275,7 @@ struct Relay { } /// The IETF header state that cannot be inferred from a plain frame list. -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] #[derive(Clone, Debug)] // private: passthrough pub(crate) struct Wire { @@ -1069,7 +1069,7 @@ impl Producer { /// /// The declared size is the peer's claim, so the buffer is allocated up front only /// while it fits the session's `budget`; otherwise it grows with the bytes received. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/ingest.md pub(crate) fn create_frame_owned( mut self, @@ -1291,8 +1291,10 @@ impl Producer { /// Abort with `err` only while nothing consumes the group, returning whether it is /// closed. Consumer creation and the check share a lock, so a reader arriving after /// [`poll_unused`](Self::poll_unused) keeps the group alive instead of reading the abort. - #[allow(dead_code)] - // The answering API retains these on the writer as well as the session observer. + #[allow( + dead_code, + reason = "the answering API retains these on the writer as well as the session observer" + )] // pending: /quest/m1/public-model/answer.md pub(crate) fn abort_unused(&self, err: Error) -> bool { self.handle.abort_unused(err) @@ -1327,8 +1329,10 @@ impl Producer { } /// Poll for the group becoming unused (every consumer dropped). - #[allow(dead_code)] - // The answering API retains these on the writer as well as the session observer. + #[allow( + dead_code, + reason = "the answering API retains these on the writer as well as the session observer" + )] // pending: /quest/m1/public-model/answer.md pub(crate) fn poll_unused(&self, waiter: &kio::Waiter) -> Poll<()> { self.handle.poll_unused(waiter) @@ -1440,7 +1444,7 @@ impl Handle { /// Abort with `err` only while nothing consumes the group, returning whether it is /// closed. Consumer creation and the check share a lock, so a reader arriving after /// [`poll_unused`](Self::poll_unused) keeps the group alive instead of reading the abort. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/answer.md pub(crate) fn abort_unused(&self, err: Error) -> bool { match self.state.write_unused() { @@ -1530,13 +1534,13 @@ impl Handle { } /// Whether `other` is a handle to this same group. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(super) fn is_clone(&self, other: &Self) -> bool { self.state.same_channel(&other.state) } /// Whether the group opened its first frame, or ended without one. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/ingest.md pub(crate) fn is_started(&self) -> bool { self.state.read().started() @@ -1714,7 +1718,7 @@ impl Handle { } /// Poll for the group becoming unused (every consumer dropped). - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/answer.md pub(crate) fn poll_unused(&self, waiter: &kio::Waiter) -> Poll<()> { self.state.poll_unused(waiter).map(|_| ()) diff --git a/rs/moq-net/src/model/ledger.rs b/rs/moq-net/src/model/ledger.rs index 64dad02890e..3ea6281ca49 100644 --- a/rs/moq-net/src/model/ledger.rs +++ b/rs/moq-net/src/model/ledger.rs @@ -134,7 +134,7 @@ impl Ledger { } // Gap timing shared by a subscription tail and its track's live arrivals. -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] impl Ledger { /// How long a gap is waited for once a later group opened it. pub fn grace(&self) -> Duration { diff --git a/rs/moq-net/src/model/listing.rs b/rs/moq-net/src/model/listing.rs index 50d755a1df9..4bdf315aaa1 100644 --- a/rs/moq-net/src/model/listing.rs +++ b/rs/moq-net/src/model/listing.rs @@ -65,7 +65,7 @@ pub(crate) struct Owner(u64); impl Owner { // private: capability gap // Sessions dedup a peer's listings per broadcast; a custom session has no public owner yet. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn new() -> Self { static NEXT: AtomicU64 = AtomicU64::new(0); Self(NEXT.fetch_add(1, Ordering::Relaxed)) @@ -477,7 +477,7 @@ impl Consumer { /// [`Error::Cancel`]. // private: capability gap // Sessions dedup a peer's listings per broadcast; a custom session has no public owner yet. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn tracks_as(&self, owner: Owner) -> Result { self.list(Some(owner)) } diff --git a/rs/moq-net/src/model/origin.rs b/rs/moq-net/src/model/origin.rs index dcea246547d..77282951afd 100644 --- a/rs/moq-net/src/model/origin.rs +++ b/rs/moq-net/src/model/origin.rs @@ -80,7 +80,7 @@ impl Hop { } /// Build a hop from an id read off the wire, where 0 is legal. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/answer.md pub(crate) fn from_wire(id: u64) -> Result { if id >= 1u64 << 62 { @@ -388,12 +388,12 @@ impl Cost { /// A peer without a wire cost: the same as [`Cost::default`], so only the /// local link price counts. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/answer.md pub(crate) const UNKNOWN: Self = Self(0); /// Add a link's static price without overflowing the wire ceiling. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/answer.md pub(crate) fn charged(self, link_cost: u64) -> Self { Self::new(self.0.saturating_add(link_cost)) @@ -548,7 +548,7 @@ impl Route { /// /// Not part of the advertised route: an assigned identity is private selection /// state and must not be forwarded. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/answer.md pub(crate) fn with_via(mut self, via: Hop) -> Self { self.via = via; @@ -625,7 +625,10 @@ fn fnv_key(name: &str, origins: impl IntoIterator) -> u64 { /// itself for an advertisement. Keying the hash on the requested path is what /// spreads equal-cost advertisers of one prefix: each path picks its own winner /// from the pool, rather than every path under the prefix hashing alike. -#[allow(clippy::type_complexity)] +#[expect( + clippy::type_complexity, + reason = "the tuple is the sort key; naming it would only move the type" +)] fn route_order<'a>( path: &Path, entry: &'a RouteEntry, @@ -709,7 +712,7 @@ struct ReleaseState { held: Held, hold: Duration, clock: Deadlines, - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] deadline: crate::time::Deadline, } @@ -743,7 +746,7 @@ impl Release { } /// `Ready` once released, registering `waiter` until then. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] fn poll(&self, waiter: &kio::Waiter) -> Poll<()> { let mut state = self.0.lock().unwrap(); let now = state.clock.now(); @@ -1564,7 +1567,7 @@ impl Mount { impl OriginScope { /// A view that reaches nothing. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] fn empty() -> Self { Self { allowed: Patterns::new(), @@ -1815,7 +1818,7 @@ impl Producer { } /// The ingress stats context this handle was tagged with. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/answer.md pub(crate) fn stats(&self) -> &stats::Session { &self.stats @@ -1889,7 +1892,7 @@ impl Producer { /// advertises no subscribe interest (its `allowed()` is empty, so the /// subscriber issues no ANNOUNCE_PLEASE). Used to fill an unset session half /// so both the publisher and subscriber loops still run. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/answer.md pub(crate) fn empty(hop: Hop) -> Self { // No allowed prefixes means no broadcast is ever created, so nothing will @@ -2012,7 +2015,7 @@ impl Producer { /// is *not* entered into the route table. Sessions answer /// [`Dynamic`] requests with one of these; the requester already holds /// the request's result channel, so the table never needs to resolve it. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/answer.md pub(crate) fn create_source(&self, path: impl AsPath) -> broadcast::Producer { let path = path.as_path(); @@ -2052,7 +2055,7 @@ impl Producer { /// Start a [`Snapshot`] under `prefix`: the announce consumers it overlaps are not /// synced until the returned guard drops. Taken before the request goes out, so /// nothing reads as synced in between. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/answer.md pub(crate) fn snapshot(&self, prefix: impl AsPath) -> Snapshot { let prefix = self.root.join(prefix.as_path()).to_owned(); @@ -3765,7 +3768,7 @@ struct Watched { enum WatchProducer { Changes(kio::Producer), - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] Selection(kio::Producer), } @@ -3832,7 +3835,7 @@ impl Selected { } /// The lifetime of path requests while this peer still selects the held instance. -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/answer.md pub(crate) struct Selection { shared: SendCell>, @@ -3842,7 +3845,7 @@ pub(crate) struct Selection { } impl Selection { - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(super) fn current(&self) -> kio::Consumer<()> { self.signal .read() @@ -3854,7 +3857,7 @@ impl Selection { /// `Ready` once the current period's replacement is released, registering /// `waiter` until then. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(super) fn poll_retired(&self, waiter: &kio::Waiter) -> Poll<()> { match self.signal.poll(waiter, |selected| match &selected.retiring { Some(release) => release.poll(waiter), @@ -3934,7 +3937,7 @@ pub(crate) struct Snapshot { impl Snapshot { /// A snapshot nothing waits on. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/answer.md pub(crate) fn landed() -> Self { Self { @@ -4758,7 +4761,7 @@ pub struct Dynamic { } impl Dynamic { - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(super) fn request_validity(&self, path: &Path) -> Option { let shared = &self.announcement.shared; let mut table = shared.lock(); @@ -4822,7 +4825,7 @@ impl Dynamic { /// Retire an explicit peer withdrawal, hiding derived paths only once its /// last live advertisement at the prefix is gone. A lost session just drops. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/answer.md pub(crate) fn withdrawn(self) { self.announcement.retract(true); @@ -5345,7 +5348,7 @@ impl Consumer { /// nobody, so the announcing session's assigned identity is what keeps an /// anonymous route from echoing back. Pass [`Hop::UNKNOWN`] for an anonymous /// peer. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/answer.md pub(crate) fn excluding(mut self, peer: Hop) -> Self { self.horizon.exclude = Some(peer); @@ -5374,7 +5377,7 @@ impl Consumer { /// A clone whose [`announced`](Self::announced) reports only the routes a feed /// from `outer` hides, for a stream topping up that feed. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/answer.md pub(crate) fn beyond(mut self, outer: &Consumer) -> Self { self.hidden.beyond = Some( @@ -5389,7 +5392,7 @@ impl Consumer { } /// Set wire discovery visibility relative to this consumer's requested root. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/answer.md pub(crate) fn discovery(mut self, hidden: bool) -> Self { self.hidden.include = hidden; @@ -5398,14 +5401,14 @@ impl Consumer { } /// Whether [`announced`](Self::announced) reports hidden routes too. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/answer.md pub(crate) fn includes_hidden(&self) -> bool { self.hidden.include } /// The egress stats context this handle was tagged with. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/answer.md pub(crate) fn stats(&self) -> &stats::Session { &self.stats @@ -5433,7 +5436,7 @@ impl Consumer { /// [`announced`](Self::announced) yields nothing. Used to answer a peer's /// announce-interest for a prefix outside our scope by announcing nothing, /// rather than tearing the stream down. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/answer.md pub(crate) fn empty(&self) -> Self { Self { @@ -6341,7 +6344,7 @@ impl Drop for AnnounceConsumer { use futures::FutureExt; #[cfg(test)] -#[allow(missing_docs)] // test-only assertion helpers +#[expect(missing_docs, reason = "test-only assertion helpers")] impl AnnounceConsumer { /// The route of an active event at `expected`. fn active(event: AnnounceEvent, expected: &Path) -> Route { diff --git a/rs/moq-net/src/model/resume.rs b/rs/moq-net/src/model/resume.rs index a5c9232e0c4..b7144470219 100644 --- a/rs/moq-net/src/model/resume.rs +++ b/rs/moq-net/src/model/resume.rs @@ -451,7 +451,7 @@ impl Subscriber { /// Poll for where the serving copy's live feed starts; see /// [`track::Subscriber::poll_start`]. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(super) fn poll_start(&mut self, waiter: &kio::Waiter) -> Poll> { let mut reader = self.reader(); let sub = ready!(reader.poll_serving(waiter)); @@ -473,7 +473,7 @@ impl Subscriber { } /// Poll for sequences the serving copy gave up; see [`track::Subscriber::poll_drop`]. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(super) fn poll_drop(&mut self, waiter: &kio::Waiter) -> Poll> { let mut reader = self.reader(); let sub = ready!(reader.poll_serving(waiter)); @@ -490,7 +490,7 @@ impl Subscriber { /// Move the local read floor to `start`, including downward. /// See [`track::Subscriber::start_at`]. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(super) fn start_at(&mut self, start: u64) { self.reader().start_at(start) } @@ -509,7 +509,7 @@ impl Subscriber { } /// The newest sequence any copy has. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(super) fn latest(&self) -> Option { self.reader().latest() } @@ -548,7 +548,7 @@ impl Subscriber { /// Poll for the serving copy's cache reflecting its live feed; see /// [`track::Subscriber::poll_live`]. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(super) fn poll_live(&mut self, waiter: &kio::Waiter) -> Poll> { let mut reader = self.reader(); let sub = ready!(reader.poll_serving(waiter)); @@ -1108,7 +1108,7 @@ impl Reader { /// The serving copy's subscription, once it answered; `None` once the track ended /// without one. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] fn poll_serving(&mut self, waiter: &kio::Waiter) -> Poll> { loop { self.sync(waiter); @@ -1145,7 +1145,7 @@ impl Reader { /// from the mirrored subscription when it resolves; one already reading has /// to be moved, or a group it skipped stays skipped. Never below a copy's own /// resume point: groups under it were handed out by an earlier route, or never owed. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] fn start_at(&mut self, start: u64) { self.peeked = None; self.groups.0 = start; @@ -1166,7 +1166,7 @@ impl Reader { } } - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] fn latest(&self) -> Option { self.copies.iter().filter_map(|copy| copy.track.latest_sequence()).max() } diff --git a/rs/moq-net/src/model/track.rs b/rs/moq-net/src/model/track.rs index db1942a7c40..205b42ecef4 100644 --- a/rs/moq-net/src/model/track.rs +++ b/rs/moq-net/src/model/track.rs @@ -154,7 +154,7 @@ pub struct Info { /// /// Relay-only: moq-lite does not carry them. Shared, since every group holds a copy /// of the info. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // private: passthrough pub(crate) properties: Option>, } @@ -261,11 +261,11 @@ enum Feed { Live, /// The upstream subscription ended with the copy still held, so how stale the cache /// is cannot be told until the route answers again. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] Idle, /// The route answered that its feed reaches group `from`, which the cache cannot show /// yet: until it can, the newest group cached would read as the live edge. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] Answered { from: u64 }, } @@ -431,7 +431,7 @@ pub(crate) struct TrackState { live_floor: Option, // The newest group cached when the track went idle: what the route's answer is // judged against, whatever lands before it. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] idle_newest: Option, // Where production stopped, snapshotted when the open groups are released (an @@ -874,7 +874,7 @@ impl TrackState { } /// Whether the cached group at `sequence` is one readers saw and the publisher cut. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] fn is_cut(&self, sequence: u64) -> bool { self.lookup .get(&sequence) @@ -1762,7 +1762,7 @@ impl TrackState { } /// Show a [`Producer::receive_group`] group to readers, if `group` still holds its slot. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] fn reveal(&mut self, group: &group::Handle) { let sequence = group.sequence; let Some(slot) = self.lookup.get_mut(&sequence) else { @@ -2150,7 +2150,7 @@ impl TrackState { /// The upstream subscription ended with the copy still held: what it cached may go /// stale, so readers get nothing from it until the route answers again. Buffered /// datagrams go too, since a reader returning later must not be handed them. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] fn set_idle(&mut self) { self.feed = Feed::Idle; self.idle_newest = self @@ -2170,7 +2170,7 @@ impl TrackState { /// /// Readers wait until the cache shows that position: before then its newest group would /// read as the live edge, though the route already holds a newer one. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] fn set_live(&mut self, largest: Option) { if self.feed != Feed::Idle { return; @@ -2197,14 +2197,14 @@ impl TrackState { } /// Whether readers can already see content at or past `sequence`. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] fn shows(&self, sequence: u64) -> bool { self.lookup.range(sequence..).any(|(_, slot)| slot.is_shown()) || self.datagrams.iter().any(|datagram| datagram.sequence >= sequence) } /// The newest live group the cache holds, and the number of frames it has so far. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] fn newest(&self) -> Option<(u64, u64)> { let (sequence, slot) = self .lookup @@ -2216,7 +2216,7 @@ impl TrackState { /// The largest position the cache holds: the newest live group's last frame (its head, /// while it has none). - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] fn largest(&self) -> Option { self.newest().map(|(group, frames)| Position { group, @@ -2502,7 +2502,7 @@ impl Producer { /// header lands before its first frame. Shown in between, it would leave the group /// before it with no stamped successor, so a joiner at the live edge would be handed /// that older group first. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/ingest.md pub(crate) fn receive_group(&self, group: group::Info) -> Result { self.insert(group, true) @@ -2510,7 +2510,7 @@ impl Producer { /// Show a [`Self::receive_group`] group to readers: its first frame landed, or its /// stream ended. A no-op once another incarnation took its sequence. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/ingest.md pub(crate) fn reveal_group(&self, group: &group::Handle) { if let Ok(mut state) = self.modify() { @@ -2688,7 +2688,7 @@ impl Producer { } /// End a locally closed session's receive track without declaring a wire boundary. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/ingest.md pub(crate) fn close(self) -> Result<()> { let mut state = self.modify()?; @@ -2702,7 +2702,7 @@ impl Producer { } /// Abort the groups still receiving from a failed session before ending its track. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/ingest.md pub(crate) fn abort_session(self, err: Error) -> Result<()> { let state = self.modify()?; @@ -2759,7 +2759,7 @@ impl Producer { /// is a no-op, and a mid-group end may refine a group boundary it falls just before /// (a FETCH_OK names only the boundary). Any other second end is /// [`Error::ProtocolViolation`]. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/ingest.md pub(crate) fn finish_at_pending(&mut self, end: Position) -> Result<()> { let mut state = self.modify()?; @@ -2784,7 +2784,7 @@ impl Producer { /// While pending, readers do not end at the boundary: a lower group's stream may /// arrive after a higher one. The session clears it once its tail settles; the last /// producer going ends readers regardless. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/ingest.md pub(crate) fn set_tail_pending(&self, pending: bool) { if self.state.read().tail_pending == pending { @@ -2812,7 +2812,7 @@ impl Producer { /// Mark this track as a session's copy of a remote one: its groups are never checked /// for a rewind, which only a local publisher's writes refuse. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/ingest.md pub(crate) fn received(&self) { if let Ok(mut state) = self.modify() { @@ -2821,7 +2821,7 @@ impl Producer { } /// Record sequences the upstream publisher explicitly gave up. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/ingest.md pub(crate) fn drop_groups(&self, groups: ops::Range) { if groups.is_empty() { @@ -2834,7 +2834,7 @@ impl Producer { /// Restart the age of every arrival gap reaching into `groups`, which the live feed's /// subscription newly asks for. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/ingest.md pub(crate) fn demand_arrivals(&self, groups: ops::Range) { if let Ok(mut state) = self.modify() { @@ -2845,7 +2845,7 @@ impl Producer { /// Readers get nothing from the cache until [`Self::set_live`]: the upstream /// subscription ended with this copy still held, so what it cached may go stale. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // private: capability gap pub(crate) fn set_idle(&mut self) { if let Ok(mut state) = self.modify() { @@ -2856,7 +2856,7 @@ impl Producer { /// The route answered with its largest position, `None` for nothing yet; see /// [`Self::set_idle`]. Readers resume once the cache shows that position. A no-op /// unless idle. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // private: capability gap pub(crate) fn set_live(&mut self, largest: Option) { if let Ok(mut state) = self.modify() { @@ -2866,14 +2866,14 @@ impl Producer { /// The source reported its largest frame, which [`Self::largest`] follows before the /// frame itself arrives. A hint about the edge: it never makes the frame readable. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // private: capability gap pub(crate) fn report_largest(&self, largest: Position) { self.state.read().cache.advance_largest(largest); } /// Whether readers may take from the cache; see [`Self::set_idle`]. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // private: capability gap pub(crate) fn is_live(&self) -> bool { self.state.read().feed == Feed::Live @@ -2881,7 +2881,7 @@ impl Producer { /// While idle, the newest group cached when the track went idle: a route asked from /// its head sends it again, and its first frame says whether the cache is current. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // private: capability gap pub(crate) fn idle_newest(&self) -> Option { let state = self.state.read(); @@ -2892,7 +2892,7 @@ impl Producer { /// resolve its start: nothing below `sequence` arrives, exactly as [`Self::start_at`], /// but [`Subscriber::poll_start`] keeps waiting until a later [`Self::start_at`] /// resolves it. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/ingest.md pub(crate) fn request_start(&mut self, sequence: Option) -> Result<()> { self.modify()?.set_start(sequence, true); @@ -2986,7 +2986,7 @@ impl Producer { self.state.read().is_closed() } - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/serve.md pub(crate) fn latest_sequence(&self) -> Option { self.state.read().max_sequence @@ -3013,7 +3013,7 @@ impl Producer { } /// Ready once the track holds a group past `sequence`, or is closed. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // private: capability gap pub(crate) fn poll_past(&self, sequence: u64, waiter: &kio::Waiter) -> Poll<()> { let past = self.state.poll_ref(waiter, |state| match state.max_sequence { @@ -3783,7 +3783,7 @@ pub(crate) struct Arrivals { state: kio::ConsumerWeak, } -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] impl Arrivals { /// Whether both handles watch the same track. // A fetch batch may share only one track's arrival ledger. @@ -3813,7 +3813,7 @@ pub(crate) struct ArrivalRead<'a> { grace: Duration, } -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] impl ArrivalRead<'_> { /// Whether the live feed can no longer deliver any missing group. // The batch checks closure without re-locking the track. @@ -3986,7 +3986,7 @@ impl Consumer { /// source that never declares one). Parks while a lite-06+ session still owes its /// SUBSCRIBE_START (see [`Producer::request_start`]); a closed track is ready with /// whatever it last declared, since nothing will resolve it anymore. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] fn poll_state_start(state: &kio::Consumer, waiter: &kio::Waiter) -> Poll> { let res = state.poll(waiter, |state| match state.start_pending && state.abort.is_none() { true => Poll::Pending, @@ -4001,7 +4001,7 @@ impl Consumer { /// The newest group, when it is already cached: resolved synchronously, without /// counting as a fetch or a delivery. The IETF publisher snapshots its frame count to /// resolve Largest Object; a group that is not immediately available reads as no edge. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/deferred.md pub(crate) fn peek_latest(&self) -> Option { if let Some(serving) = self.serving() { @@ -4014,7 +4014,7 @@ impl Consumer { /// The nearest cached group below `sequence`, under the same terms as /// [`Self::peek_group`]. Walks the cache's own order, so gaps in the group numbering /// are crossed and aborted (evicted) entries are skipped. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/deferred.md pub(crate) fn peek_before(&self, sequence: u64) -> Option { if let Some(serving) = self.serving() { @@ -4036,7 +4036,7 @@ impl Consumer { /// fetch, a peek does not refresh the group's cache standing, so it never keeps a /// group alive over one a subscriber actually read; an aborted (evicted) group is a /// miss. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/deferred.md pub(crate) fn peek_group(&self, sequence: u64) -> Option { if let Some(serving) = self.serving() { @@ -4054,7 +4054,7 @@ impl Consumer { /// The live arrivals of the track this handle reads now, without joining its demand. // This batch view avoids per-fetch ledger copies and locks in the session. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // private: tuning pub(crate) fn arrivals(&self) -> Option { self.with_state(|state| state.map(|state| Arrivals { state: state.clone() })) @@ -4144,7 +4144,7 @@ impl Consumer { } /// Join the instance this handle reads at the live edge; see [`Subscriber::join`]. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] fn join(&self) { if let Some(serving) = self.serving() { return serving.join(); @@ -4158,7 +4158,7 @@ impl Consumer { /// Whether the cache is fed live, so the newest object it holds is the track's largest. /// Fetch-only, closed, and parked copies are not, even once they learn the end. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/deferred.md pub(crate) fn is_live(&self) -> bool { if let Some(serving) = self.serving() { @@ -4319,7 +4319,7 @@ impl Consumer { } /// The first group the declared end excludes whole, or `None` while the track is open ended. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/serve.md pub(crate) fn final_sequence(&self) -> Option { if let Some(serving) = self.serving() { @@ -4549,7 +4549,7 @@ impl group::Request { /// Declare the track's exclusive final sequence, as the publisher answering this /// fetch reported it. A no-op once the track declared an end, or holds a later group. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/deferred.md pub(crate) fn finish_track_at(&self, final_sequence: u64) { if let Ok(mut state) = TrackState::modify(&self.state) @@ -4889,7 +4889,7 @@ enum Inner { /// Boxed: the plain cursor is the hot path. Resume( Box, - #[allow(dead_code)] kio::Consumer, + #[allow(dead_code, reason = "held so the logical track counts as a reader")] kio::Consumer, ), } @@ -5158,20 +5158,20 @@ struct Within<'a> { /// the cache on every poll. struct DropCursor { /// Every group the publisher cuts. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] cuts: super::aborts::Watch, /// Sequences given up and not reported yet: stale skips, cuts, and upstream drops. pending: RangeSet, /// The [`TrackState::drops_revision`], span, and window revision last folded into /// `pending`. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] scanned: Option<(u64, ops::Range, u64)>, /// Every sequence this cursor already reported. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] reported: RangeSet, } -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] impl DropCursor { fn new(state: &TrackState) -> Self { // Watch before the first scan, so a cut landing between the two is still seen. @@ -5317,7 +5317,7 @@ impl Cursor { cursor } - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] fn poll_drop(&mut self, waiter: &kio::Waiter) -> Poll> { self.sync(); let within = Within { @@ -6289,7 +6289,7 @@ impl Subscriber { /// Poll for where the source's feed starts, raised to this cursor's floor, once /// resolved; see [`Subscriber::poll_start`]. A feed starting below the floor serves the /// floor's group too. `None` when the source declares none. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/serve.md pub(crate) fn poll_start(&mut self, waiter: &kio::Waiter) -> Poll> { let cursor = match &mut self.inner { @@ -6354,7 +6354,7 @@ impl Subscriber { /// /// Stale skips are recorded only once this has been polled, so a cursor no wire /// publisher forwards drops for keeps none. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/serve.md pub(crate) fn poll_drop(&mut self, waiter: &kio::Waiter) -> Poll> { match &mut self.inner { @@ -6366,7 +6366,7 @@ impl Subscriber { /// Poll for the track's cache reflecting its live feed (or the track ending), with the /// largest position it holds; `None` for a track with nothing yet. A front's logical /// track answers for the route serving it. See [`Producer::set_idle`]. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/serve.md pub(crate) fn poll_live(&mut self, waiter: &kio::Waiter) -> Poll> { let cursor = match &mut self.inner { @@ -6425,7 +6425,7 @@ impl Subscriber { /// skipped groups are still delivered and simply not returned. To ask the publisher /// to start there too, set [`Subscription::ranges`] via [`Self::update`]. /// See [Local cursor vs wire preference](Self#local-cursor-vs-wire-preference). - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/serve.md pub(crate) fn start_at(&mut self, sequence: u64) { match &mut self.inner { @@ -6572,7 +6572,7 @@ impl Subscriber { /// The track's largest location known now, ignoring [`Self::set_groups`], without waiting /// or moving [`Self::poll_largest`] on: past what the cache holds once the source /// reported a newer one. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // private: capability gap pub(crate) fn peek_largest(&mut self) -> Option { let mut seen = None; @@ -6585,7 +6585,7 @@ impl Subscriber { } } - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/serve.md pub(crate) fn latest_sequence(&self) -> Option { match &self.inner { @@ -6596,7 +6596,7 @@ impl Subscriber { /// Join again at the live edge, judged by [`Info::refresh`] like a new subscriber: a /// moq-transport NEW_GROUP_REQUEST. A front's reader joins the copy serving it. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // private: passthrough pub(crate) fn join(&self) { match &self.inner { @@ -6840,7 +6840,7 @@ impl Request { /// (lite-06+), so [`Subscriber::poll_start`] waits for its declaration instead of /// reading the requested floor as the start. Applied atomically with /// [`Self::accept`], before any reader can see the track. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/ingest.md pub(crate) fn resolving_start(mut self) -> Self { self.resolving_start = true; @@ -6905,7 +6905,7 @@ impl Request { /// Reject only while no consumer needs this pending track. Demand and the check /// share one lock, so demand returning after `Demand::wanted` went to `None` wins the race, and the /// close under that lock stops a later consumer attaching to a dead request. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // pending: /quest/m1/public-model/answer.md pub(crate) fn reject_unused(&self, err: Error) -> bool { match self.state.write_unused() { @@ -7001,7 +7001,7 @@ impl Request { use futures::FutureExt; #[cfg(test)] -#[allow(missing_docs)] // test-only assertion helpers +#[expect(missing_docs, reason = "test-only assertion helpers")] impl Subscriber { pub fn assert_group(&mut self) -> group::Consumer { kio::wait(|waiter| self.poll_recv_group(waiter)) diff --git a/rs/moq-net/src/path/mod.rs b/rs/moq-net/src/path/mod.rs index f59f87eff16..d80e33d24e7 100644 --- a/rs/moq-net/src/path/mod.rs +++ b/rs/moq-net/src/path/mod.rs @@ -138,7 +138,7 @@ impl<'a> Path<'a> { } } - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn from_escaped(s: String) -> PathOwned { if s.is_empty() { Path::empty() diff --git a/rs/moq-net/src/setup.rs b/rs/moq-net/src/setup.rs index 1e8eb5dcfd9..b9fb2441df5 100644 --- a/rs/moq-net/src/setup.rs +++ b/rs/moq-net/src/setup.rs @@ -13,16 +13,16 @@ use crate::{ }; // SETUP only carries negotiation parameters. Bound it independently of control messages. -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) const MAX_SETUP_SIZE: usize = u16::MAX as usize; -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] const CLIENT_SETUP: u8 = 0x20; -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] const SERVER_SETUP: u8 = 0x21; /// Draft-17 unified SETUP message type (varint 0x2F00) -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) const SETUP_V17: u64 = 0x2F00; /// The SETUP extensions this side offers. @@ -77,13 +77,13 @@ impl Token { /// Draft-17+ unified SETUP message, with the same encoding for both client and server. #[derive(Debug, Clone)] -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) struct Setup { pub parameters: Bytes, } impl Setup { - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] fn check_version(v: Version) { match v { Version::Ietf(ietf::Version::Draft14 | ietf::Version::Draft15 | ietf::Version::Draft16) @@ -117,7 +117,7 @@ impl Decode for Setup { } #[derive(Clone, Copy, Debug, PartialEq, Eq)] -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] enum SetupVersion { Draft14, Draft15Plus, @@ -128,7 +128,7 @@ enum SetupVersion { } impl SetupVersion { - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] fn from_version(v: Version) -> Self { match v { Version::Ietf(ietf::Version::Draft14) => Self::Draft14, @@ -147,7 +147,7 @@ impl SetupVersion { /// A version-agnostic setup message sent by the client. #[derive(Debug, Clone)] -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) struct Client { /// The list of supported versions in preferred order. pub versions: coding::Versions, @@ -157,7 +157,7 @@ pub(crate) struct Client { } impl Client { - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] fn encode_inner(&self, w: &mut Encoder<'_>, v: Version) -> Result<(), EncodeError> { match SetupVersion::from_version(v) { SetupVersion::Draft15Plus => { @@ -210,7 +210,7 @@ impl Encode for Client { } /// Read a pre-draft-17 SETUP body: its size, then that many bytes. -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] fn decode_body<'a>(r: &mut Decoder<'a>, v: Version) -> Result, DecodeError> { let size = match SetupVersion::from_version(v) { SetupVersion::Draft14 | SetupVersion::Draft15Plus => r.u16()? as usize, @@ -227,7 +227,7 @@ fn decode_body<'a>(r: &mut Decoder<'a>, v: Version) -> Result, Decod } /// Reserve the size prefix of a pre-draft-17 SETUP body. -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] fn prefix_body(w: &mut Encoder<'_>, v: Version) -> Result { match SetupVersion::from_version(v) { SetupVersion::Draft14 | SetupVersion::Draft15Plus => Ok(w.prefix_u16()), @@ -237,7 +237,7 @@ fn prefix_body(w: &mut Encoder<'_>, v: Version) -> Result, prefix: coding::Prefix) -> Result<(), EncodeError> { if w.since(&prefix) > MAX_SETUP_SIZE { w.discard(prefix); @@ -248,7 +248,7 @@ fn fill_body(w: &mut Encoder<'_>, prefix: coding::Prefix) -> Result<(), EncodeEr /// Sent by the server in response to a client setup. #[derive(Debug, Clone)] -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) struct Server { /// The list of supported versions in preferred order. pub version: coding::Version, @@ -258,7 +258,7 @@ pub(crate) struct Server { } impl Server { - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] fn encode_inner(&self, w: &mut Encoder<'_>, v: Version) -> Result<(), EncodeError> { match SetupVersion::from_version(v) { SetupVersion::Draft15Plus => { diff --git a/rs/moq-net/src/stats.rs b/rs/moq-net/src/stats.rs index 7a53f7b8430..cb9788a62c6 100644 --- a/rs/moq-net/src/stats.rs +++ b/rs/moq-net/src/stats.rs @@ -1487,9 +1487,9 @@ pub struct Session { /// Which of a session's `crate::session::Limits` a [`Session::hold`] counts against. #[derive(Clone, Copy, Debug)] pub(crate) enum Cap { - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] Announces, - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] Subscriptions, } @@ -1633,7 +1633,7 @@ impl Session { } /// Count `live` as what this session holds against `cap`, so a tier change carries it. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn track_held(&self, cap: Cap, live: &Arc) { let Some(inner) = &self.inner else { return }; let mut held = inner.held.lock().unwrap_or_else(PoisonError::into_inner); @@ -1644,7 +1644,7 @@ impl Session { /// Record that this session holds `held` of what `cap` limits, raising that peak on its /// tier and label. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn hold(&self, cap: Cap, held: u64) { let Some(inner) = &self.inner else { return }; let current = inner.current.lock().unwrap_or_else(PoisonError::into_inner); diff --git a/rs/moq-net/src/util.rs b/rs/moq-net/src/util.rs index 828c66125c1..6fecbb54423 100644 --- a/rs/moq-net/src/util.rs +++ b/rs/moq-net/src/util.rs @@ -97,7 +97,7 @@ impl Tasks { /// /// A task submitted after the set is gone is dropped: the driver has torn down, /// so the task would have been cancelled anyway. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn push(&self, task: impl MaybeBoxedExt<'static, Output = ()>) { let mut state = self.state.lock(); if !state.closed { @@ -188,7 +188,7 @@ impl TaskSet { } /// Queue a future for polling by this set. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn push(&mut self, task: impl MaybeBoxedExt<'static, Output = ()>) { self.active.push(future_task(task.maybe_boxed())); } diff --git a/rs/moq-net/src/version.rs b/rs/moq-net/src/version.rs index 4dd475fd29f..a4a9cd7e943 100644 --- a/rs/moq-net/src/version.rs +++ b/rs/moq-net/src/version.rs @@ -8,7 +8,7 @@ use crate::{coding, ietf, lite}; /// Ordered by preference, with the client's preference taking priority. /// This intentionally includes only SETUP-negotiated versions (Lite02, Lite01, Draft14); /// Lite03 and newer IETF drafts negotiate via dedicated ALPNs instead. -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) const NEGOTIATED: [Version; 3] = [ Version::Lite(lite::Version::Lite02), Version::Lite(lite::Version::Lite01), @@ -85,7 +85,7 @@ pub enum Version { } impl Version { - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn session_code(self, error: &crate::SessionError) -> u32 { match self { Self::Lite(_) => crate::lite::error::to_session_code(error), diff --git a/rs/moq-net/tests/integration/routing_contracts/model.rs b/rs/moq-net/tests/integration/routing_contracts/model.rs index 1de19b9dd74..c297f1c2c5d 100644 --- a/rs/moq-net/tests/integration/routing_contracts/model.rs +++ b/rs/moq-net/tests/integration/routing_contracts/model.rs @@ -2020,7 +2020,10 @@ impl Net { out } - #[allow(clippy::type_complexity)] + #[expect( + clippy::type_complexity, + reason = "a test model's sort key; an alias would only move the type" + )] fn rank( &self, node: Node, diff --git a/rs/moq-net/tests/integration/support/harness.rs b/rs/moq-net/tests/integration/support/harness.rs index 677e2bc5ad7..ba0b335eeb6 100644 --- a/rs/moq-net/tests/integration/support/harness.rs +++ b/rs/moq-net/tests/integration/support/harness.rs @@ -5,7 +5,7 @@ //! over a [`super::mock::MockSession`] pair and spawns both protocol drivers, giving tests //! two live sessions ready for pub/sub without any real QUIC or network I/O. -#![allow(dead_code)] +#![allow(dead_code, reason = "shared by several test binaries, each using only part of it")] use std::sync::{ Arc, diff --git a/rs/moq-net/tests/integration/support/mock.rs b/rs/moq-net/tests/integration/support/mock.rs index 3ee81a8a738..b0915ab08c9 100644 --- a/rs/moq-net/tests/integration/support/mock.rs +++ b/rs/moq-net/tests/integration/support/mock.rs @@ -658,8 +658,7 @@ impl poll::Session for MockSession { } } -// Only some test binaries steer delivery. -#[allow(dead_code)] +#[allow(dead_code, reason = "only some test binaries steer delivery")] impl MockSession { /// Writes that parked on the in-memory stream's byte window. pub fn blocked_writes(&self) -> usize { diff --git a/rs/moq-net/tests/integration/support/mod.rs b/rs/moq-net/tests/integration/support/mod.rs index 3d8549f9c81..dee03d04c5e 100644 --- a/rs/moq-net/tests/integration/support/mod.rs +++ b/rs/moq-net/tests/integration/support/mod.rs @@ -8,7 +8,7 @@ pub mod mock; use moq_net::track; /// Wait until anyone wants the track, returning the group they want. -#[allow(dead_code)] +#[allow(dead_code, reason = "shared by several test binaries, each using only part of it")] pub async fn wanted(mut demand: track::Demand) -> moq_net::Result { loop { if let Some(wanted) = demand.wanted_changed().await? { @@ -18,7 +18,7 @@ pub async fn wanted(mut demand: track::Demand) -> moq_net::Result { } /// Wait until nobody wants the track. -#[allow(dead_code)] +#[allow(dead_code, reason = "shared by several test binaries, each using only part of it")] pub async fn unwanted(mut demand: track::Demand) -> moq_net::Result<()> { while demand.wanted_changed().await?.is_some() {} Ok(()) diff --git a/rs/moq-nvenc/Cargo.toml b/rs/moq-nvenc/Cargo.toml index 1f5d5643dbe..a608e0681a7 100644 --- a/rs/moq-nvenc/Cargo.toml +++ b/rs/moq-nvenc/Cargo.toml @@ -20,3 +20,6 @@ cudarc = { workspace = true } # dlopen libnvidia-encode at runtime (the two NVENC bootstrap symbols). libloading = { workspace = true } thiserror = { workspace = true } + +[lints] +workspace = true diff --git a/rs/moq-nvenc/src/cuvid.rs b/rs/moq-nvenc/src/cuvid.rs index a795942f1bb..4099531ce3c 100644 --- a/rs/moq-nvenc/src/cuvid.rs +++ b/rs/moq-nvenc/src/cuvid.rs @@ -35,7 +35,6 @@ type UnmapVideoFrame64 = unsafe extern "C" fn(CUvideodecoder, c_ulonglong) -> CU /// ([`create_video_parser`](Self::create_video_parser)), feed it bitstream /// packets, and inside the parser callbacks create a decoder, decode pictures, /// and map/unmap the decoded frames. All calls require a current CUDA context. -#[allow(missing_debug_implementations)] pub struct Api { /// Creates a bitstream parser. #[doc(alias = "cuvidCreateVideoParser")] diff --git a/rs/moq-nvenc/src/lib.rs b/rs/moq-nvenc/src/lib.rs index a81e53c4de2..4df6febcebe 100644 --- a/rs/moq-nvenc/src/lib.rs +++ b/rs/moq-nvenc/src/lib.rs @@ -28,10 +28,12 @@ //! table; there is no higher-level safe wrapper yet. #![warn(missing_docs)] -// Vendored third-party bindings: keep the workspace's `clippy -D warnings` and -// `rustdoc -D warnings` from churning upstream code (broken intra-doc links, the -// strict clippy lints the crate opted into, etc.). -#![allow(clippy::all, clippy::pedantic, rustdoc::all)] +#![allow( + clippy::all, + clippy::pedantic, + rustdoc::all, + reason = "vendored third-party bindings: keep the workspace's `clippy -D warnings` and `rustdoc -D warnings` from churning upstream code (broken intra-doc links, the strict clippy lints the crate opted into, etc.)" +)] pub mod cuvid; pub mod safe; diff --git a/rs/moq-nvenc/src/safe/api.rs b/rs/moq-nvenc/src/safe/api.rs index 9f541024caa..147fc641cd0 100644 --- a/rs/moq-nvenc/src/safe/api.rs +++ b/rs/moq-nvenc/src/safe/api.rs @@ -174,7 +174,11 @@ impl Loader for DynamicLoader { } /// The private `NvEncodeAPI` function table. -#[allow(dead_code, missing_docs)] +#[allow( + dead_code, + missing_docs, + reason = "mirrors the whole NVENC function table, not all of which is called" +)] #[derive(Debug, Clone)] pub(crate) struct EncodeAPI { #[doc(alias = "NvEncOpenEncodeSession")] diff --git a/rs/moq-nvenc/src/safe/buffer.rs b/rs/moq-nvenc/src/safe/buffer.rs index a2f135994d3..5210abee123 100644 --- a/rs/moq-nvenc/src/safe/buffer.rs +++ b/rs/moq-nvenc/src/safe/buffer.rs @@ -445,7 +445,6 @@ impl EncoderInput for Buffer { /// This type is created via [`Buffer::lock`] or [`Buffer::try_lock`]. /// The purpose of this type is similar to [`std::sync::MutexGuard`] - /// it automatically unlocks the buffer when the lock goes out of scope. -#[allow(clippy::module_name_repetitions)] #[derive(Debug)] pub struct BufferLock<'a> { buffer: &'a Buffer, diff --git a/rs/moq-nvenc/src/sys/mod.rs b/rs/moq-nvenc/src/sys/mod.rs index a09da38c1a4..7397d6d6925 100644 --- a/rs/moq-nvenc/src/sys/mod.rs +++ b/rs/moq-nvenc/src/sys/mod.rs @@ -10,14 +10,14 @@ mod version; // The bindgen output is plain C-ABI type/enum/fn-pointer definitions, so the // "linux" bindings compile on any non-Windows target. On macOS the crate only // needs to compile (NVENC is never actually loaded there), so reuse them. -#[allow(warnings)] +#[allow(warnings, reason = "bindgen output")] #[rustfmt::skip] #[cfg(not(target_os = "windows"))] mod linux_sys; #[cfg(not(target_os = "windows"))] pub use linux_sys::*; -#[allow(warnings)] +#[allow(warnings, reason = "bindgen output")] #[rustfmt::skip] #[cfg(target_os = "windows")] mod windows_sys; diff --git a/rs/moq-nvenc/src/sys/version.rs b/rs/moq-nvenc/src/sys/version.rs index 1a7015e3fe9..d50b9ed828d 100644 --- a/rs/moq-nvenc/src/sys/version.rs +++ b/rs/moq-nvenc/src/sys/version.rs @@ -1,8 +1,8 @@ -#![allow(missing_docs)] +#![expect(missing_docs, reason = "the constants mirror nvEncodeAPI")] //! Constants from `nvEncodeAPI` that bindgen fails to generate. #[must_use] -#[allow(non_snake_case)] +#[expect(non_snake_case, reason = "mirrors the nvEncodeAPI macro name")] /// Macro to generate per-structure version for use with API. pub const fn NVENCAPI_STRUCT_VERSION(ver: u32) -> u32 { super::nvEncodeAPI::NVENCAPI_VERSION | (ver << 16) | (0x7 << 28) diff --git a/rs/moq-pattern/Cargo.toml b/rs/moq-pattern/Cargo.toml index 5cdfbd32b4d..02ee8784381 100644 --- a/rs/moq-pattern/Cargo.toml +++ b/rs/moq-pattern/Cargo.toml @@ -28,3 +28,6 @@ serde_json = { workspace = true } [[bench]] name = "matching" harness = false + +[lints] +workspace = true diff --git a/rs/moq-quic/Cargo.toml b/rs/moq-quic/Cargo.toml index c31ed007001..53627b34767 100644 --- a/rs/moq-quic/Cargo.toml +++ b/rs/moq-quic/Cargo.toml @@ -127,14 +127,5 @@ name = "wire" harness = false required-features = ["fuzz"] -# quinn's workspace lints, kept so upstream code stays clean against them. -[lints.rust] -elided_lifetimes_in_paths = "warn" -unnameable_types = "warn" -unreachable_pub = "warn" -unused_qualifications = "warn" - -[lints.clippy] -manual_let_else = "warn" -or_fun_call = "warn" -use_self = "warn" +[lints] +workspace = true diff --git a/rs/moq-quic/benches/common/mod.rs b/rs/moq-quic/benches/common/mod.rs index f24b4738ab8..c3604f7df65 100644 --- a/rs/moq-quic/benches/common/mod.rs +++ b/rs/moq-quic/benches/common/mod.rs @@ -223,8 +223,10 @@ fn drain(conn: &mut Connection, id: StreamId, sink: Sink, received: &mut Receive received.reset += 1; break; } - // Unreachable today, but keeps the suite compiling against a rewrite's new variants. - #[allow(unreachable_patterns)] + #[allow( + unreachable_patterns, + reason = "unreachable today, but keeps the suite compiling against a rewrite's new variants" + )] Err(err) => panic!("read failed: {err}"), } } diff --git a/rs/moq-quic/benches/endpoint.rs b/rs/moq-quic/benches/endpoint.rs index 6f1178812fb..dec761049e0 100644 --- a/rs/moq-quic/benches/endpoint.rs +++ b/rs/moq-quic/benches/endpoint.rs @@ -9,7 +9,10 @@ use bytes::{BufMut, BytesMut}; use criterion::{BatchSize, BenchmarkId, Criterion, Throughput, criterion_group, criterion_main}; use moq_quic::DatagramEvent; -#[allow(dead_code)] +#[allow( + dead_code, + reason = "a harness shared by several benches, each using only part of it" +)] mod common; use common::{Pair, Setup, ThreadCpu}; diff --git a/rs/moq-quic/benches/receive.rs b/rs/moq-quic/benches/receive.rs index 10989778c9c..11dd34f71bd 100644 --- a/rs/moq-quic/benches/receive.rs +++ b/rs/moq-quic/benches/receive.rs @@ -5,7 +5,10 @@ use std::time::Duration; use criterion::{BenchmarkId, Criterion, Throughput, criterion_group, criterion_main}; use moq_quic::{Dir, VarInt}; -#[allow(dead_code)] +#[allow( + dead_code, + reason = "a harness shared by several benches, each using only part of it" +)] mod common; use common::{Pair, Setup, Sink, ThreadCpu, payload}; diff --git a/rs/moq-quic/benches/streams.rs b/rs/moq-quic/benches/streams.rs index db88dd21ed4..241fc3948da 100644 --- a/rs/moq-quic/benches/streams.rs +++ b/rs/moq-quic/benches/streams.rs @@ -8,7 +8,10 @@ use criterion::{BenchmarkId, Criterion, Throughput, criterion_group, criterion_main}; use moq_quic::Dir; -#[allow(dead_code)] +#[allow( + dead_code, + reason = "a harness shared by several benches, each using only part of it" +)] mod common; use common::{Pair, Setup, ThreadCpu, payload}; diff --git a/rs/moq-quic/benches/wire.rs b/rs/moq-quic/benches/wire.rs index da0a5b92ea2..5c2801ace33 100644 --- a/rs/moq-quic/benches/wire.rs +++ b/rs/moq-quic/benches/wire.rs @@ -11,7 +11,10 @@ use cpu_time::ThreadTime; use bytes::BytesMut; use criterion::{BenchmarkId, Criterion, Throughput, criterion_group, criterion_main}; -#[allow(dead_code)] +#[allow( + dead_code, + reason = "a harness shared by several benches, each using only part of it" +)] mod common; use common::{ diff --git a/rs/moq-quic/fuzz/Cargo.toml b/rs/moq-quic/fuzz/Cargo.toml index 61bdfdee9b3..ae75a6f32d8 100644 --- a/rs/moq-quic/fuzz/Cargo.toml +++ b/rs/moq-quic/fuzz/Cargo.toml @@ -65,3 +65,6 @@ bench = false [dependencies] libfuzzer-sys = "0.4" moq-quic = { workspace = true, features = ["fuzz"] } + +[lints] +workspace = true diff --git a/rs/moq-quic/src/config/mod.rs b/rs/moq-quic/src/config/mod.rs index 826d4d02eed..760349909ac 100644 --- a/rs/moq-quic/src/config/mod.rs +++ b/rs/moq-quic/src/config/mod.rs @@ -491,7 +491,10 @@ impl ValidationTokenConfig { self } - #[allow(rustdoc::redundant_explicit_links)] // which links are redundant depends on features + #[allow( + rustdoc::redundant_explicit_links, + reason = "which links are redundant depends on features" + )] /// Set a custom [`TokenLog`] /// /// If the `bloom` feature is enabled (which it is by default), defaults to a default diff --git a/rs/moq-quic/src/congestion.rs b/rs/moq-quic/src/congestion.rs index dc96e99a43f..11c8e122d61 100644 --- a/rs/moq-quic/src/congestion.rs +++ b/rs/moq-quic/src/congestion.rs @@ -17,14 +17,20 @@ pub use unlimited::Unlimited; /// Common interface for different congestion controllers pub trait Controller: Send + Sync { /// One or more packets were just sent - #[allow(unused_variables)] + #[allow( + unused_variables, + reason = "a no-op default that keeps the parameter names for implementors" + )] fn on_sent(&mut self, now: Instant, bytes: u64, last_packet_number: u64) {} /// One packet was just sent /// /// `packet_number` identifies the packet only within `space`; every packet number space /// numbers independently from zero. - #[allow(unused_variables)] + #[allow( + unused_variables, + reason = "a no-op default that keeps the parameter names for implementors" + )] fn on_packet_sent(&mut self, now: Instant, bytes: u16, packet_number: u64, space: SpaceId) {} /// The connection had data to send but was blocked by the congestion window @@ -39,7 +45,10 @@ pub trait Controller: Send + Sync { /// including after a partial send. Congestion, pacing, and the local send window are sender /// limits. Receiver credit counts as application-limited: for MoQ, peer flow control is a /// configuration limit rather than a measure of path capacity. - #[allow(unused_variables)] + #[allow( + unused_variables, + reason = "a no-op default that keeps the parameter names for implementors" + )] fn on_app_limited(&mut self, in_flight: u64) {} /// Packet deliveries were confirmed @@ -47,7 +56,14 @@ pub trait Controller: Send + Sync { /// `app_limited` indicates whether the connection was blocked on outgoing /// application data prior to receiving these acknowledgements. /// `pn` identifies the packet only within `space`. - #[allow(unused_variables)] + #[allow( + unused_variables, + reason = "a no-op default that keeps the parameter names for implementors" + )] + #[expect( + clippy::too_many_arguments, + reason = "a public trait method; reshaping it is a breaking change" + )] fn on_ack( &mut self, now: Instant, @@ -61,7 +77,10 @@ pub trait Controller: Send + Sync { } /// Packets are acked in batches, all with the same `now` argument. This indicates one of those batches has completed. - #[allow(unused_variables)] + #[allow( + unused_variables, + reason = "a no-op default that keeps the parameter names for implementors" + )] fn on_end_acks( &mut self, now: Instant, @@ -82,6 +101,10 @@ pub trait Controller: Send + Sync { /// in the congestion event, within `space`, and `sent` is its send time. For ECN, that is the /// largest packet acknowledged by the ACK whose CE count increased, and the event fires only /// on such an increase. + #[expect( + clippy::too_many_arguments, + reason = "a public trait method; reshaping it is a breaking change" + )] fn on_congestion_event( &mut self, now: Instant, @@ -96,7 +119,10 @@ pub trait Controller: Send + Sync { /// One packet was just lost /// /// `packet_number` identifies the packet only within `space`. - #[allow(unused_variables)] + #[allow( + unused_variables, + reason = "a no-op default that keeps the parameter names for implementors" + )] fn on_packet_lost( &mut self, lost_bytes: u16, @@ -124,7 +150,10 @@ pub trait Controller: Send + Sync { /// /// Controllers can use this to refine estimates that depend on peer ACK behavior (e.g. /// BBR's offload budget). - #[allow(unused_variables)] + #[allow( + unused_variables, + reason = "a no-op default that keeps the parameter names for implementors" + )] fn on_ack_frequency_update( &mut self, ack_eliciting_threshold: u64, diff --git a/rs/moq-quic/src/connection/packet_builder.rs b/rs/moq-quic/src/connection/packet_builder.rs index 9acb63178c0..a51d0d0721a 100644 --- a/rs/moq-quic/src/connection/packet_builder.rs +++ b/rs/moq-quic/src/connection/packet_builder.rs @@ -32,6 +32,10 @@ impl PacketBuilder { /// /// Marks the connection drained and returns `None` if the confidentiality limit would be /// violated, or an Initial token leaves insufficient space for frames. + #[expect( + clippy::too_many_arguments, + reason = "private plumbing; a single-use argument struct would only rename the parameters" + )] pub(super) fn new( now: Instant, space_id: SpaceId, diff --git a/rs/moq-quic/src/connection/qlog.rs b/rs/moq-quic/src/connection/qlog.rs index 0294a695160..e1272c73be1 100644 --- a/rs/moq-quic/src/connection/qlog.rs +++ b/rs/moq-quic/src/connection/qlog.rs @@ -1,5 +1,7 @@ -// Function bodies in this module are regularly cfg'd out -#![allow(unused_variables)] +#![allow( + unused_variables, + reason = "function bodies in this module are regularly cfg'd out" +)] #[cfg(feature = "qlog")] use std::sync::{Arc, Mutex}; diff --git a/rs/moq-quic/src/connection/stats.rs b/rs/moq-quic/src/connection/stats.rs index 1a6dab4ba3b..199ad0a37a4 100644 --- a/rs/moq-quic/src/connection/stats.rs +++ b/rs/moq-quic/src/connection/stats.rs @@ -29,7 +29,10 @@ impl UdpStats { /// Number of frames transmitted or received of each frame type #[derive(Default, Copy, Clone)] #[non_exhaustive] -#[allow(missing_docs)] +#[expect( + missing_docs, + reason = "one counter per frame type; the field names say what they count" +)] pub struct FrameStats { pub acks: u64, pub ack_frequency: u64, diff --git a/rs/moq-quic/src/connection/streams/mod.rs b/rs/moq-quic/src/connection/streams/mod.rs index c3f160c3628..d231d7ddddb 100644 --- a/rs/moq-quic/src/connection/streams/mod.rs +++ b/rs/moq-quic/src/connection/streams/mod.rs @@ -34,7 +34,6 @@ pub struct Streams<'a> { pub(super) conn_state: &'a super::State, } -#[allow(clippy::needless_lifetimes)] // `new` names the lifetime, under the fuzz harness impl<'a> Streams<'a> { /// Drive a bare `StreamsState` without a connection, for the `streams` fuzz target #[cfg(any(test, feature = "fuzz"))] @@ -218,7 +217,6 @@ pub struct SendStream<'a> { pub(super) conn_state: &'a super::State, } -#[allow(clippy::needless_lifetimes)] // `new` names the lifetime, under the fuzz harness impl<'a> SendStream<'a> { /// Drive a bare `StreamsState` without a connection, for the `streams` fuzz target #[cfg(any(test, feature = "fuzz"))] diff --git a/rs/moq-quic/src/endpoint.rs b/rs/moq-quic/src/endpoint.rs index c5a737427d0..4a53ec9c5cc 100644 --- a/rs/moq-quic/src/endpoint.rs +++ b/rs/moq-quic/src/endpoint.rs @@ -909,6 +909,10 @@ impl Endpoint { incoming_buffer } + #[expect( + clippy::too_many_arguments, + reason = "private plumbing; a single-use argument struct would only rename the parameters" + )] fn add_connection( &mut self, ch: ConnectionHandle, diff --git a/rs/moq-quic/src/lib.rs b/rs/moq-quic/src/lib.rs index a52b3f2dd32..7fd14335d86 100644 --- a/rs/moq-quic/src/lib.rs +++ b/rs/moq-quic/src/lib.rs @@ -13,12 +13,21 @@ //! managing a single connection and all the related state (such as streams). #![warn(missing_docs)] -#![cfg_attr(test, allow(dead_code))] -// Fixes welcome: -#![warn(unreachable_pub)] -#![allow(clippy::cognitive_complexity)] -#![allow(clippy::too_many_arguments)] -#![warn(clippy::use_self)] +#![cfg_attr( + test, + allow(dead_code, reason = "test builds compile helpers only some tests call") +)] +// quinn's workspace lints, kept so upstream code stays clean against them. They +// live here because Cargo can't extend the workspace lint table per crate. +#![warn( + elided_lifetimes_in_paths, + unnameable_types, + unreachable_pub, + unused_qualifications, + clippy::manual_let_else, + clippy::or_fun_call, + clippy::use_self +)] use std::{ fmt, diff --git a/rs/moq-quic/src/packet.rs b/rs/moq-quic/src/packet.rs index 555acb093d5..7fbc1ccf9e0 100644 --- a/rs/moq-quic/src/packet.rs +++ b/rs/moq-quic/src/packet.rs @@ -28,7 +28,10 @@ pub struct PartialDecode { buf: io::Cursor, } -#[allow(clippy::len_without_is_empty)] +#[expect( + clippy::len_without_is_empty, + reason = "a partially decoded packet is never empty" +)] impl PartialDecode { /// Begin decoding a QUIC packet from `bytes`, returning any trailing data not part of that packet pub fn new( diff --git a/rs/moq-quic/src/range_set/btree_range_set.rs b/rs/moq-quic/src/range_set/btree_range_set.rs index 5beb4d34772..8513238117c 100644 --- a/rs/moq-quic/src/range_set/btree_range_set.rs +++ b/rs/moq-quic/src/range_set/btree_range_set.rs @@ -338,7 +338,10 @@ impl Drop for Replace<'_> { /// Tests which apply for all implementations can be found in the `tests.rs` module #[cfg(test)] mod tests { - #![allow(clippy::single_range_in_vec_init)] // https://github.com/rust-lang/rust-clippy/issues/11086 + #![expect( + clippy::single_range_in_vec_init, + reason = "a false positive on a list of one range: https://github.com/rust-lang/rust-clippy/issues/11086" + )] use super::*; #[test] diff --git a/rs/moq-quic/src/token.rs b/rs/moq-quic/src/token.rs index a3ffebae785..ab58ca28ec7 100644 --- a/rs/moq-quic/src/token.rs +++ b/rs/moq-quic/src/token.rs @@ -361,7 +361,10 @@ fn decode_unix_secs(buf: &mut B) -> Option { /// Stateless reset token /// /// Used for an endpoint to securely communicate that it has lost state for a connection. -#[allow(clippy::derived_hash_with_manual_eq)] // Custom PartialEq impl matches derived semantics +#[expect( + clippy::derived_hash_with_manual_eq, + reason = "custom PartialEq impl matches derived semantics" +)] #[derive(Debug, Copy, Clone, Hash)] pub(crate) struct ResetToken([u8; RESET_TOKEN_SIZE]); diff --git a/rs/moq-quic/src/transport_error.rs b/rs/moq-quic/src/transport_error.rs index bb530ecc67d..227b3735a77 100644 --- a/rs/moq-quic/src/transport_error.rs +++ b/rs/moq-quic/src/transport_error.rs @@ -88,7 +88,7 @@ impl From for u64 { macro_rules! errors { {$($name:ident($val:expr) $desc:expr;)*} => { - #[allow(non_snake_case, unused)] + #[allow(non_snake_case, unused, reason = "constructors are named after the wire codes, and not every code is raised")] impl Error { $( pub(crate) fn $name(reason: T) -> Self where T: Into { diff --git a/rs/moq-quic/src/transport_parameters.rs b/rs/moq-quic/src/transport_parameters.rs index 44dc0933d33..34cf5886f44 100644 --- a/rs/moq-quic/src/transport_parameters.rs +++ b/rs/moq-quic/src/transport_parameters.rs @@ -871,7 +871,10 @@ mod test { #[test] fn read_semantic_validation() { - #[allow(clippy::type_complexity)] + #[expect( + clippy::type_complexity, + reason = "a one-off test table; an alias would only move the type" + )] let illegal_params_builders: Vec> = vec![ Box::new(|t| { // This min_ack_delay is bigger than max_ack_delay! diff --git a/rs/moq-relay/Cargo.toml b/rs/moq-relay/Cargo.toml index f672b08bdda..4e3c3c39717 100644 --- a/rs/moq-relay/Cargo.toml +++ b/rs/moq-relay/Cargo.toml @@ -134,3 +134,6 @@ harness = false [[bench]] name = "auth" harness = false + +[lints] +workspace = true diff --git a/rs/moq-relay/src/cluster.rs b/rs/moq-relay/src/cluster.rs index 0dc69f2af98..b9c559e38e8 100644 --- a/rs/moq-relay/src/cluster.rs +++ b/rs/moq-relay/src/cluster.rs @@ -2960,7 +2960,7 @@ mod tests { #[derive(Debug, serde::Deserialize)] struct Doc { - #[allow(dead_code)] + #[allow(dead_code, reason = "the test only checks that deserializing fails")] connect: Vec, } let err = toml::from_str::("connect = [{ url = \"https://peer.example/\", cost = \"cheap\" }]") diff --git a/rs/moq-relay/src/connection.rs b/rs/moq-relay/src/connection.rs index 72d1d1f1404..fedc27e8e23 100644 --- a/rs/moq-relay/src/connection.rs +++ b/rs/moq-relay/src/connection.rs @@ -498,7 +498,10 @@ mod tests { .start(&tokio::runtime::Handle::current(), async { Ok::<_, anyhow::Error>(async { panic!("injected supervision panic"); - #[allow(unreachable_code)] + #[expect( + unreachable_code, + reason = "the panic is the point; the `Ok` names the future's output type" + )] Ok::<_, anyhow::Error>(()) }) }) diff --git a/rs/moq-relay/src/incoming.rs b/rs/moq-relay/src/incoming.rs index 86ea3e3d492..b4235580811 100644 --- a/rs/moq-relay/src/incoming.rs +++ b/rs/moq-relay/src/incoming.rs @@ -33,7 +33,10 @@ impl Accepted { /// /// Public in a private module, so [`Incoming`] can name it while nothing outside /// this crate can implement it. -#[allow(async_fn_in_trait)] +#[expect( + async_fn_in_trait, + reason = "a sealed trait, so no outside implementor needs a `Send` bound" +)] pub trait Sealed: Sized { /// The running session's protocol driver. type Driver; diff --git a/rs/moq-relay/src/relay.rs b/rs/moq-relay/src/relay.rs index 34e2674b852..3137ffe161b 100644 --- a/rs/moq-relay/src/relay.rs +++ b/rs/moq-relay/src/relay.rs @@ -241,7 +241,6 @@ impl Relay { #[cfg(feature = "iroh")] let iroh = config.iroh.bind(&config.quic).await?; - #[allow(unused_mut)] let mut server_config = moq_tokio::server::Config::default(); server_config.listen = listen; server_config.tls = served; diff --git a/rs/moq-relay/src/settings.rs b/rs/moq-relay/src/settings.rs index 25ad57508b0..29e0ccb34b3 100644 --- a/rs/moq-relay/src/settings.rs +++ b/rs/moq-relay/src/settings.rs @@ -4,7 +4,10 @@ //! merged flag is declared twice. [`usage_rs::config::Registry::drift`] is the test //! that the two stay in step. -#![allow(dead_code)] +#![allow( + dead_code, + reason = "declares the settings for the usage registry; nothing reads the fields" +)] /// Every setting `moq-relay` merges, flattened tokio groups included. #[derive(usage_rs::Config)] diff --git a/rs/moq-relay/src/uring.rs b/rs/moq-relay/src/uring.rs index a33d429585d..11d5c97e365 100644 --- a/rs/moq-relay/src/uring.rs +++ b/rs/moq-relay/src/uring.rs @@ -853,7 +853,6 @@ mod tests { /// `Config` is non-exhaustive, so the windows are filled in after `default` /// rather than in a struct literal. #[test] - #[allow(clippy::field_reassign_with_default)] fn windows_are_applied() { let mut quic = moq_tokio::quic::Config::default(); quic.receive_window = Some(64 << 20); @@ -870,7 +869,6 @@ mod tests { /// left at the documented defaults: the tokio backends apply `Resolved`'s /// windows as they are, and the workers must get exactly those. #[test] - #[allow(clippy::field_reassign_with_default)] fn windows_match_the_tokio_runtime() { let mut set = moq_tokio::quic::Config::default(); set.receive_window = Some(128 << 20); @@ -902,7 +900,6 @@ mod tests { /// A direct `bind` validates `[quic]` too, so a key log nobody can read back fails /// instead of binding and logging nothing. #[test] - #[allow(clippy::field_reassign_with_default)] fn bind_refuses_a_keylog_without_sslkeylogfile() { // SAFETY: nextest runs each test in its own process, so nothing else reads the environment. unsafe { std::env::remove_var("SSLKEYLOGFILE") }; diff --git a/rs/moq-relay/src/web.rs b/rs/moq-relay/src/web.rs index 1c057b99be1..2b127357da7 100644 --- a/rs/moq-relay/src/web.rs +++ b/rs/moq-relay/src/web.rs @@ -163,11 +163,17 @@ pub(crate) struct WebState { pub(crate) certificates: moq_tokio::tls::Certificates, /// Relay-wide shutdown broadcast; WebSocket sessions drain with a GOAWAY /// when it fires. Defaults to a handle that never fires. - #[cfg_attr(not(feature = "websocket"), allow(dead_code))] + #[cfg_attr( + not(feature = "websocket"), + allow(dead_code, reason = "only the `websocket` feature uses it") + )] pub(crate) shutdown: crate::shutdown::Observer, /// Live sessions on this node, so a WebSocket session is listed and nudged /// like a QUIC one. - #[cfg_attr(not(feature = "websocket"), allow(dead_code))] + #[cfg_attr( + not(feature = "websocket"), + allow(dead_code, reason = "only the `websocket` feature uses it") + )] pub(crate) sessions: crate::session::Registry, /// How long a connection may sit with no complete request in flight (TLS /// handshake and partial headers included), and a WebSocket wait for its MoQ diff --git a/rs/moq-relay/src/websocket.rs b/rs/moq-relay/src/websocket.rs index b0932506101..0fc2473e255 100644 --- a/rs/moq-relay/src/websocket.rs +++ b/rs/moq-relay/src/websocket.rs @@ -14,8 +14,10 @@ use axum::{ use crate::{web::MtlsPeer, web::WebState, web::landing_response}; -// One axum extractor per fact the upgrade needs; there is no struct to fold them into. -#[allow(clippy::too_many_arguments)] +#[expect( + clippy::too_many_arguments, + reason = "one axum extractor per fact the upgrade needs; there is no struct to fold them into" +)] // The `Err` is axum's own `ErrorResponse`, so there is nothing here to box. #[expect(clippy::result_large_err, reason = "the error type is axum's, not ours")] pub(crate) async fn serve_ws( diff --git a/rs/moq-relay/tests/integration/cluster_unknown.rs b/rs/moq-relay/tests/integration/cluster_unknown.rs index c5ecbe46411..ea44a19079d 100644 --- a/rs/moq-relay/tests/integration/cluster_unknown.rs +++ b/rs/moq-relay/tests/integration/cluster_unknown.rs @@ -27,10 +27,7 @@ async fn spawn_relay( config.connect.bind = Some("127.0.0.1:0".parse().expect("parse client bind")); config.connect.tls.insecure = Some(true); config.connect.version.extend(cluster_version); - #[allow(deprecated)] - { - config.auth.public = vec![moq_auth::Pattern::all()]; - } + config.auth.public = vec![moq_auth::Pattern::all()]; config.cluster.id = Some(id); config.cluster.connect = connect.into_iter().map(moq_relay::cluster::Peer::new).collect(); diff --git a/rs/moq-relay/tests/integration/refusals.rs b/rs/moq-relay/tests/integration/refusals.rs index ede5bec86e0..ed3d1a75671 100644 --- a/rs/moq-relay/tests/integration/refusals.rs +++ b/rs/moq-relay/tests/integration/refusals.rs @@ -42,7 +42,10 @@ struct Running { stats: moq_net::stats::Registry, origin: moq_net::origin::Consumer, quic: SocketAddr, - #[cfg_attr(not(feature = "websocket"), allow(dead_code))] + #[cfg_attr( + not(feature = "websocket"), + allow(dead_code, reason = "only the `websocket` feature uses it") + )] http: SocketAddr, metrics: String, trigger: moq_relay::shutdown::Trigger, diff --git a/rs/moq-relay/tests/integration/session_revalidate.rs b/rs/moq-relay/tests/integration/session_revalidate.rs index e76cc54948e..d3dcf7c6a5f 100644 --- a/rs/moq-relay/tests/integration/session_revalidate.rs +++ b/rs/moq-relay/tests/integration/session_revalidate.rs @@ -21,7 +21,10 @@ use moq_tokio::moq_net; const TIMEOUT: Duration = Duration::from_secs(10); #[derive(Clone)] -#[allow(clippy::large_enum_variant)] +#[expect( + clippy::large_enum_variant, + reason = "a test double, so the variant sizes don't matter" +)] enum Answer { Grant(Grant), Status(u16), diff --git a/rs/moq-room/Cargo.toml b/rs/moq-room/Cargo.toml index 0bcd19bd096..77a29f245f9 100644 --- a/rs/moq-room/Cargo.toml +++ b/rs/moq-room/Cargo.toml @@ -23,3 +23,6 @@ thiserror = { workspace = true } [dev-dependencies] moq-tokio = { path = "../moq-tokio", default-features = false } tokio = { workspace = true, features = ["macros", "rt", "test-util"] } + +[lints] +workspace = true diff --git a/rs/moq-room/src/lib.rs b/rs/moq-room/src/lib.rs index fd81f95cd43..2dec939f982 100644 --- a/rs/moq-room/src/lib.rs +++ b/rs/moq-room/src/lib.rs @@ -1,5 +1,3 @@ -#![cfg_attr(test, allow(clippy::disallowed_methods))] - //! Headless multi-participant rooms over MoQ. //! //! A room is a path prefix. There is no service and no storage: joining is diff --git a/rs/moq-rtc/Cargo.toml b/rs/moq-rtc/Cargo.toml index cd79d6ef3cf..5f63b5906cd 100644 --- a/rs/moq-rtc/Cargo.toml +++ b/rs/moq-rtc/Cargo.toml @@ -46,3 +46,6 @@ uuid = { version = "1", features = ["v4"] } aws-lc-rs = { workspace = true } tokio = { workspace = true, features = ["test-util"] } tracing-test = { workspace = true } + +[lints] +workspace = true diff --git a/rs/moq-rtmp/Cargo.toml b/rs/moq-rtmp/Cargo.toml index 21b1416b9ff..0dcd83be34a 100644 --- a/rs/moq-rtmp/Cargo.toml +++ b/rs/moq-rtmp/Cargo.toml @@ -67,3 +67,6 @@ tracing-test = { workspace = true, features = ["no-env-filter"] } [[bench]] name = "chunk_interleaving" harness = false + +[lints] +workspace = true diff --git a/rs/moq-rtmp/src/dial.rs b/rs/moq-rtmp/src/dial.rs index e534d7b2f16..7117ea35f92 100644 --- a/rs/moq-rtmp/src/dial.rs +++ b/rs/moq-rtmp/src/dial.rs @@ -554,7 +554,7 @@ impl Publisher { } #[cfg(test)] -#[allow(clippy::disallowed_methods, clippy::disallowed_types)] +#[expect(clippy::disallowed_methods, reason = "tests read the host clock directly")] mod tests { use std::time::Duration; diff --git a/rs/moq-rtmp/src/rml/mod.rs b/rs/moq-rtmp/src/rml/mod.rs index eb567a11212..59773c2b974 100644 --- a/rs/moq-rtmp/src/rml/mod.rs +++ b/rs/moq-rtmp/src/rml/mod.rs @@ -17,11 +17,11 @@ //! Kept close to upstream (its own tests included), so the whole module opts out //! of the workspace's `-D warnings` clippy/rustdoc gate rather than churning the //! vendor to satisfy our lints. -#![allow(warnings)] -#![allow(clippy::all)] -#![allow(clippy::pedantic)] -#![allow(clippy::nursery)] -#![allow(rustdoc::all)] +#![allow(warnings, reason = "vendored rml code")] +#![allow(clippy::all, reason = "vendored rml code")] +#![allow(clippy::pedantic, reason = "vendored rml code")] +#![allow(clippy::nursery, reason = "vendored rml code")] +#![allow(rustdoc::all, reason = "vendored rml code")] #![deny(clippy::disallowed_methods, clippy::disallowed_types)] pub mod amf0; diff --git a/rs/moq-rtmp/src/rml/test_utils/assert_vec_match_macro.rs b/rs/moq-rtmp/src/rml/test_utils/assert_vec_match_macro.rs index 7e04cb2e242..61a66cd5975 100644 --- a/rs/moq-rtmp/src/rml/test_utils/assert_vec_match_macro.rs +++ b/rs/moq-rtmp/src/rml/test_utils/assert_vec_match_macro.rs @@ -1,4 +1,4 @@ -#[allow(unused)] +#[allow(unused, reason = "vendored rml code")] macro_rules! assert_vec_match{ (@empty $vector:expr) => { if $vector.len() > 0 { diff --git a/rs/moq-rtmp/src/server.rs b/rs/moq-rtmp/src/server.rs index ecb160538c9..b15514c8aa7 100644 --- a/rs/moq-rtmp/src/server.rs +++ b/rs/moq-rtmp/src/server.rs @@ -1508,7 +1508,7 @@ impl Publisher { } #[cfg(test)] -#[allow(clippy::disallowed_methods, clippy::disallowed_types)] +#[expect(clippy::disallowed_methods, reason = "tests read the host clock directly")] mod tests { use super::*; #[tokio::test(start_paused = true)] diff --git a/rs/moq-rtsp/Cargo.toml b/rs/moq-rtsp/Cargo.toml index 41b4f7b63f6..9091eb9ca5f 100644 --- a/rs/moq-rtsp/Cargo.toml +++ b/rs/moq-rtsp/Cargo.toml @@ -39,3 +39,6 @@ url = { workspace = true } base64 = { workspace = true } tokio = { workspace = true, features = ["full", "test-util"] } tracing-test = { workspace = true, features = ["no-env-filter"] } + +[lints] +workspace = true diff --git a/rs/moq-shaper/Cargo.toml b/rs/moq-shaper/Cargo.toml index 232fb5c1282..c70df1c0b10 100644 --- a/rs/moq-shaper/Cargo.toml +++ b/rs/moq-shaper/Cargo.toml @@ -33,3 +33,6 @@ toml = { workspace = true } [dev-dependencies] tokio = { workspace = true, features = ["test-util"] } + +[lints] +workspace = true diff --git a/rs/moq-sock/Cargo.toml b/rs/moq-sock/Cargo.toml index e1c63232f59..839c1fb9022 100644 --- a/rs/moq-sock/Cargo.toml +++ b/rs/moq-sock/Cargo.toml @@ -32,3 +32,6 @@ cfg_aliases = "0.2" [dev-dependencies] rand = "0.10" tracing-test = "0.2" + +[lints] +workspace = true diff --git a/rs/moq-sock/src/udp/apple_fast.rs b/rs/moq-sock/src/udp/apple_fast.rs index eb556b27729..29524d678a6 100644 --- a/rs/moq-sock/src/udp/apple_fast.rs +++ b/rs/moq-sock/src/udp/apple_fast.rs @@ -83,7 +83,7 @@ fn prepare_msg_x( hdr: &mut msghdr_x, iov: &mut libc::iovec, ctrl: &mut cmsg::Aligned<[u8; cmsg::LEN]>, - #[allow(unused_variables)] encode_src_ip: bool, + #[allow(unused_variables, reason = "kept for parity with the unix `prepare_msg` signature")] encode_src_ip: bool, sendmsg_einval: bool, ) { iov.iov_base = transmit.contents.as_ptr() as *const _ as *mut _; @@ -223,7 +223,7 @@ fn resolve_symbol(lock: &std::sync::OnceLock, name: &std::ffi::CStr) -> O // Adapted from https://github.com/apple-oss-distributions/xnu/blob/8d741a5de7ff4191bf97d57b9f54c2f6d4a15585/bsd/sys/socket_private.h #[repr(C)] -#[allow(non_camel_case_types)] +#[expect(non_camel_case_types, reason = "mirrors xnu's `msghdr_x`")] pub(crate) struct msghdr_x { pub msg_name: *mut libc::c_void, pub msg_namelen: libc::socklen_t, diff --git a/rs/moq-sock/src/udp/linux.rs b/rs/moq-sock/src/udp/linux.rs index 6f8fb59bdd2..457c45a4d32 100644 --- a/rs/moq-sock/src/udp/linux.rs +++ b/rs/moq-sock/src/udp/linux.rs @@ -87,7 +87,10 @@ impl LinuxError { let required = unsafe { libc::CMSG_LEN(size_of::() as _) as usize }; - #[allow(clippy::unnecessary_cast)] // cmsg.cmsg_len defined as size_t + #[allow( + clippy::unnecessary_cast, + reason = "`cmsg_len` is `size_t` on glibc but narrower on other libcs" + )] if (cmsg.cmsg_len as usize) < required { return None; } diff --git a/rs/moq-sock/src/udp/mod.rs b/rs/moq-sock/src/udp/mod.rs index 6df8feee73f..7f9c569a3f8 100644 --- a/rs/moq-sock/src/udp/mod.rs +++ b/rs/moq-sock/src/udp/mod.rs @@ -69,9 +69,7 @@ mod imp; #[path = "wasi.rs"] mod imp; -// moq-sock always logs through `tracing`, so quinn-udp's `log` and no-op -// backends are not carried. -#[allow(unused_imports)] +#[allow(unused_imports, reason = "moq-sock always logs through `tracing`, so quinn-udp's `log` and no-op backends are not carried")] mod log { pub(crate) use tracing::{debug, error, info, trace, warn}; } @@ -165,7 +163,7 @@ impl Transmit<'_> { /// This case is actually quite common when splitting up a prepared GSO batch /// again after GSO has been disabled because the last datagram in a GSO /// batch is allowed to be smaller than the segment size. - #[cfg_attr(apple_fast, allow(dead_code))] // Used by prepare_msg, which is unused when apple_fast + #[cfg_attr(apple_fast, allow(dead_code, reason = "used by prepare_msg, which is unused when apple_fast"))] fn effective_segment_size(&self) -> Option { match self.segment_size? { size if size >= self.contents.len() => None, diff --git a/rs/moq-sock/src/udp/unix.rs b/rs/moq-sock/src/udp/unix.rs index 3f86e2c2f24..07d6ebd3c61 100644 --- a/rs/moq-sock/src/udp/unix.rs +++ b/rs/moq-sock/src/udp/unix.rs @@ -97,7 +97,7 @@ impl UdpSocketState { let mut may_fragment = false; #[cfg_attr( not(any(target_os = "linux", target_os = "android")), - expect(unused_mut) + expect(unused_mut, reason = "only the Linux GRO path sets it") )] let mut gro_segments = 1; @@ -476,12 +476,12 @@ impl UdpSocketState { #[cfg(not(any(apple, target_os = "openbsd", target_os = "netbsd")))] fn send( - #[allow(unused_variables)] // only used on Linux + #[allow(unused_variables, reason = "only used on Linux")] state: &UdpSocketState, io: SockRef<'_>, transmit: &Transmit<'_>, ) -> io::Result<()> { - #[allow(unused_mut)] // only mutable on FreeBSD + #[allow(unused_mut, reason = "only mutable on FreeBSD")] let mut encode_src_ip = true; #[cfg(target_os = "freebsd")] { @@ -599,7 +599,7 @@ fn send(state: &UdpSocketState, io: SockRef<'_>, transmit: &Transmit<'_>) -> io: } #[cfg(any(target_os = "openbsd", target_os = "netbsd", apple))] -#[cfg_attr(apple_fast, allow(dead_code))] // Unused when apple_fast is enabled +#[cfg_attr(apple_fast, allow(dead_code, reason = "unused when apple_fast is enabled"))] pub(crate) fn send_single( state: &UdpSocketState, io: SockRef<'_>, @@ -676,7 +676,7 @@ fn recv_via_recvmmsg( solarish, apple ))] -#[cfg_attr(apple_fast, allow(dead_code))] // Unused when apple_fast is enabled +#[cfg_attr(apple_fast, allow(dead_code, reason = "unused when apple_fast is enabled"))] pub(crate) fn recv_single( io: SockRef<'_>, bufs: &mut [IoSliceMut<'_>], @@ -698,14 +698,14 @@ pub(crate) fn recv_single( Ok(1) } -#[cfg_attr(apple_fast, allow(dead_code))] // Unused when apple_fast is enabled +#[cfg_attr(apple_fast, allow(dead_code, reason = "unused when apple_fast is enabled"))] fn prepare_msg( transmit: &Transmit<'_>, dst_addr: &socket2::SockAddr, hdr: &mut libc::msghdr, iov: &mut libc::iovec, ctrl: &mut cmsg::Aligned<[u8; cmsg::LEN]>, - #[allow(unused_variables)] // only used on FreeBSD & macOS + #[allow(unused_variables, reason = "only used on FreeBSD & macOS")] encode_src_ip: bool, sendmsg_einval: bool, ) { @@ -793,7 +793,7 @@ fn prepare_msg( encoder.finish(); } -#[cfg_attr(apple_fast, allow(dead_code))] // Unused when apple_fast is enabled +#[cfg_attr(apple_fast, allow(dead_code, reason = "unused when apple_fast is enabled"))] fn prepare_recv( buf: &mut IoSliceMut<'_>, name: &mut MaybeUninit, @@ -870,7 +870,10 @@ impl ControlMetadata { (libc::IPPROTO_IPV6, libc::IPV6_TCLASS) => unsafe { // Temporary hack around broken macos ABI. Remove once upstream fixes it. // https://bugreport.apple.com/web/?problemID=48761855 - #[allow(clippy::unnecessary_cast)] // cmsg.cmsg_len defined as size_t + #[allow( + clippy::unnecessary_cast, + reason = "`cmsg_len` is `size_t` on glibc but narrower on other libcs" + )] if cfg!(apple) && cmsg.cmsg_len as usize == libc::CMSG_LEN(size_of::() as _) as usize { @@ -896,7 +899,7 @@ impl ControlMetadata { (libc::IPPROTO_IPV6, libc::IPV6_PKTINFO) => { let pktinfo = unsafe { cmsg.decode::() }; self.dst_ip = Some(IpAddr::V6(Ipv6Addr::from(pktinfo.ipi6_addr.s6_addr))); - #[cfg_attr(not(target_os = "android"), expect(clippy::unnecessary_cast))] + #[cfg_attr(not(target_os = "android"), expect(clippy::unnecessary_cast, reason = "`ipi6_ifindex` is already `u32` off Android"))] { self.interface_index = Some(pktinfo.ipi6_ifindex as u32); } @@ -966,7 +969,7 @@ mod gso { 1 } - #[cfg_attr(apple_fast, allow(dead_code))] // Unused when apple_fast is enabled + #[cfg_attr(apple_fast, allow(dead_code, reason = "unused when apple_fast is enabled"))] pub(super) fn set_segment_size( #[cfg(not(apple_fast))] _encoder: &mut cmsg::Encoder<'_, libc::msghdr>, #[cfg(apple_fast)] _encoder: &mut cmsg::Encoder<'_, msghdr_x>, diff --git a/rs/moq-srt/Cargo.toml b/rs/moq-srt/Cargo.toml index 12d0b3c10c6..f3c79c93d5b 100644 --- a/rs/moq-srt/Cargo.toml +++ b/rs/moq-srt/Cargo.toml @@ -31,3 +31,6 @@ tracing = { workspace = true } hang = { path = "../hang" } srt-protocol = "0.4" tracing-test = { workspace = true, features = ["no-env-filter"] } + +[lints] +workspace = true diff --git a/rs/moq-stats/Cargo.toml b/rs/moq-stats/Cargo.toml index 45eca996a13..3c1051bd61f 100644 --- a/rs/moq-stats/Cargo.toml +++ b/rs/moq-stats/Cargo.toml @@ -46,3 +46,6 @@ harness = false name = "producer_tick" harness = false required-features = ["bench"] + +[lints] +workspace = true diff --git a/rs/moq-stats/benches/aggregate.rs b/rs/moq-stats/benches/aggregate.rs index 4a21aa0e944..1a7c97de1a3 100644 --- a/rs/moq-stats/benches/aggregate.rs +++ b/rs/moq-stats/benches/aggregate.rs @@ -9,8 +9,10 @@ //! //! Run `cargo bench -p moq-stats --bench aggregate` and compare the table across revisions. -// Custom timings measure the real time the work took, not the ambient clock. -#![allow(clippy::disallowed_methods)] +#![expect( + clippy::disallowed_methods, + reason = "custom timings measure the real time the work took, not the ambient clock" +)] use std::time::{Duration, Instant}; diff --git a/rs/moq-stats/benches/decode.rs b/rs/moq-stats/benches/decode.rs index a9760fecab9..e3ae27ede6c 100644 --- a/rs/moq-stats/benches/decode.rs +++ b/rs/moq-stats/benches/decode.rs @@ -6,8 +6,10 @@ //! //! Run `cargo bench -p moq-stats --bench decode` and compare the table across revisions. -// Custom timings measure the real time the work took, not the ambient clock. -#![allow(clippy::disallowed_methods)] +#![expect( + clippy::disallowed_methods, + reason = "custom timings measure the real time the work took, not the ambient clock" +)] use std::alloc::{GlobalAlloc, Layout, System}; use std::hint::black_box; diff --git a/rs/moq-stats/benches/producer_tick.rs b/rs/moq-stats/benches/producer_tick.rs index 0d18b6bc7d3..b6cf32858e9 100644 --- a/rs/moq-stats/benches/producer_tick.rs +++ b/rs/moq-stats/benches/producer_tick.rs @@ -19,8 +19,10 @@ //! //! Run `cargo bench -p moq-stats --features bench --bench producer_tick`. -// Custom timings measure the real time the work took, not the ambient clock. -#![allow(clippy::disallowed_methods)] +#![expect( + clippy::disallowed_methods, + reason = "custom timings measure the real time the work took, not the ambient clock" +)] use std::alloc::{GlobalAlloc, Layout, System}; use std::hint::black_box; diff --git a/rs/moq-stats/src/aggregate.rs b/rs/moq-stats/src/aggregate.rs index 51adae0e929..c505f68754a 100644 --- a/rs/moq-stats/src/aggregate.rs +++ b/rs/moq-stats/src/aggregate.rs @@ -1018,7 +1018,7 @@ mod tests { /// Kept-alive handles from [`feed`]: dropping them closes the subscription and /// announce, bumping the `_closed` counters. - #[allow(dead_code)] + #[allow(dead_code, reason = "held for their drop, never read")] struct Feed { announced: announce::Consumer, source: broadcast::Producer, @@ -1098,7 +1098,7 @@ mod tests { /// can fail one node's reader alone (the registry-driven producer only /// publishes whole broadcasts). Its route carries no epoch, so a new one at /// the same path is that node returning. Dropping it unannounces the node. - #[allow(dead_code)] + #[allow(dead_code, reason = "held for their drop, never read")] struct NodeBroadcast { source: broadcast::Producer, traffic: moq_json::snapshot::Producer, diff --git a/rs/moq-stats/src/lib.rs b/rs/moq-stats/src/lib.rs index d4a358fca7a..115ccbbd9ab 100644 --- a/rs/moq-stats/src/lib.rs +++ b/rs/moq-stats/src/lib.rs @@ -1,4 +1,3 @@ -#![cfg_attr(test, allow(clippy::disallowed_methods))] #![warn(missing_docs)] //! Publish and consume MoQ traffic stats. diff --git a/rs/moq-stats/src/produce.rs b/rs/moq-stats/src/produce.rs index 4f21883c188..cc0ad4ce7c7 100644 --- a/rs/moq-stats/src/produce.rs +++ b/rs/moq-stats/src/produce.rs @@ -1900,7 +1900,7 @@ mod tests { /// Kept-alive handles from [`feed`]: dropping them closes the subscription and the /// announce (bumping the `_closed` counters). - #[allow(dead_code)] + #[allow(dead_code, reason = "held for their drop, never read")] struct Feed { announced: announce::Consumer, source: broadcast::Producer, diff --git a/rs/moq-tokio/Cargo.toml b/rs/moq-tokio/Cargo.toml index 8da1476538e..8c78b86b08d 100644 --- a/rs/moq-tokio/Cargo.toml +++ b/rs/moq-tokio/Cargo.toml @@ -159,3 +159,6 @@ tokio = { workspace = true, features = ["test-util"] } tokio-rustls = { workspace = true } toml = "1.1" tracing-test = { workspace = true, features = ["no-env-filter"] } + +[lints] +workspace = true diff --git a/rs/moq-tokio/src/client.rs b/rs/moq-tokio/src/client.rs index 446c9f91712..0e6c214c326 100644 --- a/rs/moq-tokio/src/client.rs +++ b/rs/moq-tokio/src/client.rs @@ -409,7 +409,7 @@ impl Client { // sending it again is a protocol violation. An iroh-only build reads none of this: // that dial waits for the negotiated binding and builds its own. let moq = self.moq_with_path(setup_path(&url)); - #[allow(unused_variables)] + #[allow(unused_variables, reason = "an iroh-only build never reads it")] let moq = match setup_authority(&url) { Some(authority) => moq.with_authority(authority), None => moq, @@ -669,7 +669,7 @@ impl Dialed { feature = "tcp", feature = "uds" )), - allow(dead_code) + allow(dead_code, reason = "only a transport feature dials") )] fn new(session: moq_net::Session, transport: crate::Transport) -> Self { Self { session, transport } diff --git a/rs/moq-tokio/src/crypto.rs b/rs/moq-tokio/src/crypto.rs index 9f997fec98a..cbbf71cfd33 100644 --- a/rs/moq-tokio/src/crypto.rs +++ b/rs/moq-tokio/src/crypto.rs @@ -15,7 +15,7 @@ pub fn provider() -> Provider { return Arc::new(rustls::crypto::aws_lc_rs::default_provider()); #[cfg(all(feature = "ring", not(feature = "aws-lc-rs")))] return Arc::new(rustls::crypto::ring::default_provider()); - #[allow(unreachable_code)] + #[allow(unreachable_code, reason = "unreachable when a crypto feature returns above")] { panic!("no CryptoProvider available; install_default() or enable either the aws-lc-rs or ring feature"); } diff --git a/rs/moq-tokio/src/error.rs b/rs/moq-tokio/src/error.rs index feb4ef8c3d1..a0c71597193 100644 --- a/rs/moq-tokio/src/error.rs +++ b/rs/moq-tokio/src/error.rs @@ -5,8 +5,10 @@ use std::sync::Arc; /// Dependency errors are stored as messages so their crates stay out of this crate's public /// API. Several of them (reqwest above all) keep the useful detail in `source()`, which a /// plain `to_string()` would drop. -// A build with no transport feature compiles no backend module, so nothing calls this. -#[allow(dead_code)] +#[allow( + dead_code, + reason = "a build with no transport feature compiles no backend module, so nothing calls this" +)] pub(crate) fn message(err: impl std::error::Error) -> String { use std::fmt::Write; @@ -21,7 +23,10 @@ pub(crate) fn message(err: impl std::error::Error) -> String { /// Generates `From` conversions into message-carrying variants of the enclosing module's `Error`, /// so `?` still works on a dependency's error without that dependency reaching our public API. -#[allow(unused_macros)] +#[allow( + unused_macros, + reason = "a build with no transport feature compiles no backend module, so nothing calls this" +)] macro_rules! from_message { ($($ty:ty => $variant:ident),* $(,)?) => { $( @@ -34,7 +39,10 @@ macro_rules! from_message { }; } -#[allow(unused_imports)] +#[allow( + unused_imports, + reason = "a build with no transport feature compiles no backend module, so nothing calls this" +)] pub(crate) use from_message; /// Whether an HTTP response status means "ask again later". diff --git a/rs/moq-tokio/src/quic.rs b/rs/moq-tokio/src/quic.rs index f774b7845fd..3741b71e938 100644 --- a/rs/moq-tokio/src/quic.rs +++ b/rs/moq-tokio/src/quic.rs @@ -49,7 +49,7 @@ pub mod web; pub struct ServerId(#[serde_as(as = "serde_with::hex::Hex")] pub(crate) Vec); impl ServerId { - #[allow(dead_code)] + #[allow(dead_code, reason = "only the QUIC backend reads it")] pub(crate) fn len(&self) -> usize { self.0.len() } @@ -733,7 +733,10 @@ impl Resolved { /// Delay-based unless the operator says otherwise: BBR keeps queues short and the /// send rate steady enough for a live encoder to track, which is what this stack /// carries. - #[cfg_attr(not(any(feature = "quic", feature = "iroh")), allow(dead_code))] + #[cfg_attr( + not(any(feature = "quic", feature = "iroh")), + allow(dead_code, reason = "only the QUIC backends use it") + )] pub(crate) fn congestion(&self) -> CongestionControl { self.congestion_control.unwrap_or(CongestionControl::Delay) } @@ -742,7 +745,7 @@ impl Resolved { /// /// Only meaningful once [`Config::validate`] has passed; a build without the /// `qlog` feature never gets here with a directory set. - #[cfg_attr(not(feature = "quic"), allow(dead_code))] + #[cfg_attr(not(feature = "quic"), allow(dead_code, reason = "only the `quic` feature uses it"))] pub(crate) fn qlog_dir(&self) -> Option<&std::path::Path> { self.qlog.as_deref() } @@ -751,7 +754,7 @@ impl Resolved { /// /// Only the iroh backend consults this, to reject a GSO-off request it can't /// satisfy; the other backends toggle GSO directly. - #[cfg_attr(not(feature = "iroh"), allow(dead_code))] + #[cfg_attr(not(feature = "iroh"), allow(dead_code, reason = "only the `iroh` feature uses it"))] pub(crate) fn gso_disabled(&self) -> bool { self.gso == Some(false) } diff --git a/rs/moq-tokio/src/quic/driver/connection.rs b/rs/moq-tokio/src/quic/driver/connection.rs index 6913eb8382e..f03986876ad 100644 --- a/rs/moq-tokio/src/quic/driver/connection.rs +++ b/rs/moq-tokio/src/quic/driver/connection.rs @@ -1096,7 +1096,6 @@ pub(crate) struct State { } impl State { - #[allow(clippy::too_many_arguments)] fn new( inner: moq_quic::Connection, handle: ConnectionHandle, diff --git a/rs/moq-tokio/src/quic/web/client.rs b/rs/moq-tokio/src/quic/web/client.rs index e38cbd62e97..fd6fdcbcbdf 100644 --- a/rs/moq-tokio/src/quic/web/client.rs +++ b/rs/moq-tokio/src/quic/web/client.rs @@ -247,7 +247,10 @@ impl Default for Client { } } -#[cfg_attr(not(any(feature = "aws-lc-rs", feature = "ring")), allow(dead_code))] +#[cfg_attr( + not(any(feature = "aws-lc-rs", feature = "ring")), + allow(dead_code, reason = "only the rustls crypto backends use it") +)] #[derive(Debug)] struct ServerFingerprints { provider: crypto::Provider, diff --git a/rs/moq-tokio/src/quic/web/crypto.rs b/rs/moq-tokio/src/quic/web/crypto.rs index a1581975c97..9de3c3762ec 100644 --- a/rs/moq-tokio/src/quic/web/crypto.rs +++ b/rs/moq-tokio/src/quic/web/crypto.rs @@ -35,7 +35,7 @@ pub fn default_provider() -> Provider { { return Arc::new(rustls::crypto::ring::default_provider()); } - #[allow(unreachable_code)] + #[allow(unreachable_code, reason = "unreachable when a crypto feature returns above")] { panic!("CryptoProvider::set_default() must be called; or only enable one ring/aws-lc-rs feature."); } diff --git a/rs/moq-tokio/src/quic/web/session.rs b/rs/moq-tokio/src/quic/web/session.rs index 5215933272a..0451e260f28 100644 --- a/rs/moq-tokio/src/quic/web/session.rs +++ b/rs/moq-tokio/src/quic/web/session.rs @@ -73,8 +73,10 @@ pub struct Session { header_bi: Vec, header_datagram: Vec, - // Keep a reference to the settings and connect stream to avoid closing them until dropped. - #[allow(dead_code)] + #[allow( + dead_code, + reason = "keep a reference to the settings and connect stream to avoid closing them until dropped" + )] settings: Option>, // The send side of the CONNECT stream, used to write the CloseWebTransportSession capsule. @@ -1029,7 +1031,10 @@ impl web_transport_trait::Session for Session { Self::protocol(self) } - #[allow(refining_impl_trait)] + #[expect( + refining_impl_trait, + reason = "returns the concrete stats type rather than the trait's opaque one" + )] fn stats(&self) -> SessionStats { Self::stats(self) } diff --git a/rs/moq-tokio/src/quic/web/settings.rs b/rs/moq-tokio/src/quic/web/settings.rs index 65b69144246..26ce47c126a 100644 --- a/rs/moq-tokio/src/quic/web/settings.rs +++ b/rs/moq-tokio/src/quic/web/settings.rs @@ -25,11 +25,13 @@ pub enum SettingsError { } pub struct Settings { - // A reference to the send/recv stream, so we don't close it until dropped. - #[allow(dead_code)] + #[allow( + dead_code, + reason = "a reference to the send/recv stream, so we don't close it until dropped" + )] send: crate::quic::driver::SendStream, - #[allow(dead_code)] + #[allow(dead_code, reason = "held so the stream stays open until dropped")] recv: crate::quic::driver::RecvStream, } diff --git a/rs/moq-tokio/src/server.rs b/rs/moq-tokio/src/server.rs index b7aff6e4750..71fcb51df6c 100644 --- a/rs/moq-tokio/src/server.rs +++ b/rs/moq-tokio/src/server.rs @@ -80,7 +80,7 @@ impl crate::listen::Config { /// /// When true and [`bind`](Self::bind) is unset, the server runs stream-only /// (no default QUIC listener). - #[allow(unused_mut)] + #[allow(unused_mut, reason = "only the stream listener features set it")] fn has_stream_listener(&self) -> bool { let mut has = false; #[cfg(feature = "tcp")] @@ -335,7 +335,7 @@ impl Server { if tls.is_some() && config.tls.configured() { return Err(crate::tls::Error::ConflictingServe.into()); } - #[allow(unused_mut)] + #[allow(unused_mut, reason = "only the stream listener features set it")] let mut needed = cfg!(feature = "quic") && build_quic; #[cfg(feature = "tcp")] { @@ -550,7 +550,7 @@ impl Server { /// Available before [`listen`](Self::listen), so an owner can register these with /// a metrics endpoint at startup even though the sockets bind there. pub fn accept_health(&self) -> Vec { - #[allow(unused_mut)] + #[allow(unused_mut, reason = "only the stream listener features extend it")] let mut health = Vec::new(); #[cfg(any(feature = "tcp", all(feature = "uds", unix)))] health.extend(self.streams.health.iter().cloned()); @@ -572,8 +572,10 @@ impl Server { /// leaves nothing bound: the partially built `Listener` drops here, closing /// whatever it opened. Build a fresh `Server` from the (cloneable) config to try /// again. - // `mut` is only needed to bind the stream listeners, which a QUIC-only build has none of. - #[allow(unused_mut)] + #[allow( + unused_mut, + reason = "`mut` is only needed to bind the stream listeners, which a QUIC-only build has none of" + )] pub async fn bind(mut self) -> crate::Result { #[cfg(any(feature = "tcp", all(feature = "uds", unix)))] self.streams.bind().await?; @@ -674,13 +676,13 @@ impl Server { #[cfg(not(feature = "websocket"))] let ws_accept = std::future::ready(None::<()>); - #[allow(unused_variables)] + #[allow(unused_variables, reason = "a build without a transport feature never reads it")] let setup = Setup { activity: self.activity.clone(), server: self.moq.clone(), timeout: self.timeout, }; - #[allow(unused_variables)] + #[allow(unused_variables, reason = "a build without a transport feature never reads it")] let versions = self.versions.clone(); // An absent transport resolves `None` rather than parking, so its arm is diff --git a/rs/moq-tokio/src/settings.rs b/rs/moq-tokio/src/settings.rs index 21f7122ee44..4abd2c2569c 100644 --- a/rs/moq-tokio/src/settings.rs +++ b/rs/moq-tokio/src/settings.rs @@ -4,7 +4,10 @@ //! merged flag is declared twice: once on the `Args` structs the binaries parse, //! and once here. [`usage_rs::config::Registry::drift`] is the test that the two stay in step. -#![allow(dead_code)] +#![allow( + dead_code, + reason = "declares the settings for the usage registry; nothing reads the fields" +)] /// Accept-side settings (`[listen]`, `--listen-*`). #[derive(usage_rs::Config)] diff --git a/rs/moq-tokio/src/websocket.rs b/rs/moq-tokio/src/websocket.rs index 7dee4958e57..aadfeded63b 100644 --- a/rs/moq-tokio/src/websocket.rs +++ b/rs/moq-tokio/src/websocket.rs @@ -678,7 +678,10 @@ impl Listener { let accepted = Arc::new(Mutex::new(None::<(Option, Url)>)); let accepted_callback = accepted.clone(); let protocols = self.protocols.clone(); - #[allow(clippy::result_large_err)] + #[expect( + clippy::result_large_err, + reason = "the error type is tungstenite's handshake response, not ours" + )] let callback = move |request: &tungstenite::handshake::server::Request, mut response: tungstenite::handshake::server::Response| -> std::result::Result<_, tungstenite::handshake::server::ErrorResponse> { @@ -908,7 +911,10 @@ mod tests { let server_name = tls.get_ref().1.server_name().map(str::to_string); let host = Arc::new(Mutex::new(None)); let request_host = host.clone(); - #[allow(clippy::result_large_err)] + #[expect( + clippy::result_large_err, + reason = "the error type is tungstenite's handshake response, not ours" + )] let callback = move |request: &tungstenite::handshake::server::Request, mut response: tungstenite::handshake::server::Response| { *request_host.lock().unwrap() = request diff --git a/rs/moq-tokio/src/worker/group.rs b/rs/moq-tokio/src/worker/group.rs index 5e646aa3a03..12b49b7be2a 100644 --- a/rs/moq-tokio/src/worker/group.rs +++ b/rs/moq-tokio/src/worker/group.rs @@ -714,7 +714,6 @@ type Spawn = Box; /// built, which is what keeps this worker's packets on this thread. The server /// is handed back for the owner to build an accept loop from, which /// [`Spawner::serve`] spawns onto this same runtime. -#[allow(clippy::too_many_arguments)] fn run( member: ShardSocket, core: Option, diff --git a/rs/moq-transcode/Cargo.toml b/rs/moq-transcode/Cargo.toml index 5659e57583b..8826b199b2d 100644 --- a/rs/moq-transcode/Cargo.toml +++ b/rs/moq-transcode/Cargo.toml @@ -53,3 +53,6 @@ moq-video = { path = "../moq-video", features = ["openh264"] } tokio = { workspace = true, features = ["full", "test-util"] } url = { workspace = true } usage-rs = { workspace = true } + +[lints] +workspace = true diff --git a/rs/moq-uring/Cargo.toml b/rs/moq-uring/Cargo.toml index 9092ae33203..cd732d63b95 100644 --- a/rs/moq-uring/Cargo.toml +++ b/rs/moq-uring/Cargo.toml @@ -102,3 +102,6 @@ required-features = ["quic"] [[bench]] name = "timers" harness = false + +[lints] +workspace = true diff --git a/rs/moq-uring/benches/echo_quic.rs b/rs/moq-uring/benches/echo_quic.rs index b4b481c70c5..689e62a1e0f 100644 --- a/rs/moq-uring/benches/echo_quic.rs +++ b/rs/moq-uring/benches/echo_quic.rs @@ -1,6 +1,8 @@ //! Echo a tokio QUIC peer through the io_uring worker while ablating UDP features. -// Benchmarks measure themselves on the host clock. -#![allow(clippy::disallowed_methods)] +#![expect( + clippy::disallowed_methods, + reason = "benchmarks measure themselves on the host clock" +)] use criterion::{criterion_group, criterion_main}; diff --git a/rs/moq-uring/benches/session_lite.rs b/rs/moq-uring/benches/session_lite.rs index e59725e755d..03112cc88ea 100644 --- a/rs/moq-uring/benches/session_lite.rs +++ b/rs/moq-uring/benches/session_lite.rs @@ -6,8 +6,10 @@ //! machine and container framing on top of the same wire path. //! //! Run it with `just rs bench-session` on a Linux 6.12+ kernel. -// Benchmarks measure themselves on the host clock. -#![allow(clippy::disallowed_methods)] +#![expect( + clippy::disallowed_methods, + reason = "benchmarks measure themselves on the host clock" +)] use criterion::{criterion_group, criterion_main}; diff --git a/rs/moq-uring/benches/udp_tokio.rs b/rs/moq-uring/benches/udp_tokio.rs index b17b2becfe0..c9ab6934769 100644 --- a/rs/moq-uring/benches/udp_tokio.rs +++ b/rs/moq-uring/benches/udp_tokio.rs @@ -1,6 +1,8 @@ //! Tokio/epoll baseline for UDP receive batching and send GSO on Linux. -// Benchmarks measure themselves on the host clock. -#![allow(clippy::disallowed_methods)] +#![expect( + clippy::disallowed_methods, + reason = "benchmarks measure themselves on the host clock" +)] use criterion::{criterion_group, criterion_main}; diff --git a/rs/moq-uring/benches/udp_uring.rs b/rs/moq-uring/benches/udp_uring.rs index a2ec6a40265..645b697d4ed 100644 --- a/rs/moq-uring/benches/udp_uring.rs +++ b/rs/moq-uring/benches/udp_uring.rs @@ -1,6 +1,8 @@ //! io_uring comparison for UDP receive batching and send GSO on Linux. -// Benchmarks measure themselves on the host clock. -#![allow(clippy::disallowed_methods)] +#![expect( + clippy::disallowed_methods, + reason = "benchmarks measure themselves on the host clock" +)] use criterion::{criterion_group, criterion_main}; diff --git a/rs/moq-uring/src/clock.rs b/rs/moq-uring/src/clock.rs index 095efd66118..eab511d512b 100644 --- a/rs/moq-uring/src/clock.rs +++ b/rs/moq-uring/src/clock.rs @@ -5,7 +5,6 @@ //! so everything it runs reads the sample instead of the host clock. The host //! clock is `CLOCK_MONOTONIC`, read directly so the park can hand the next //! deadline to the kernel as an absolute timeout without a second read. -#![allow(clippy::disallowed_methods)] use std::task::Context; use std::time::Duration; @@ -28,7 +27,10 @@ pub(crate) enum Clock { /// How the worker waits for its next deadline while parked. pub(crate) enum Wait { /// The deadline already passed: run another turn instead of parking. - #[cfg_attr(not(feature = "manual"), allow(dead_code))] + #[cfg_attr( + not(feature = "manual"), + allow(dead_code, reason = "only the `manual` feature uses it") + )] Elapsed, /// Park until a completion or a wake, with no timeout. Forever, diff --git a/rs/moq-uring/src/lib.rs b/rs/moq-uring/src/lib.rs index 9ba152d82b7..17a3e79d26f 100644 --- a/rs/moq-uring/src/lib.rs +++ b/rs/moq-uring/src/lib.rs @@ -35,8 +35,13 @@ //! error instead of degrading. The crate compiles to nothing off Linux. #![warn(missing_docs)] -// Off Linux the crate compiles to nothing, so these doc links have no target. -#![cfg_attr(not(target_os = "linux"), allow(rustdoc::broken_intra_doc_links))] +#![cfg_attr( + not(target_os = "linux"), + allow( + rustdoc::broken_intra_doc_links, + reason = "off Linux the crate compiles to nothing, so these doc links have no target" + ) +)] #![cfg(target_os = "linux")] mod clock; diff --git a/rs/moq-uring/src/udp.rs b/rs/moq-uring/src/udp.rs index 13100b57acc..2ef043e0429 100644 --- a/rs/moq-uring/src/udp.rs +++ b/rs/moq-uring/src/udp.rs @@ -413,7 +413,7 @@ pub(crate) struct SockShared { /// The worker, as the I/O built on this socket carries it. owner: Owner, /// This socket's slot in a steered reuseport group, if it is in one. - #[cfg_attr(not(feature = "quic"), allow(dead_code))] + #[cfg_attr(not(feature = "quic"), allow(dead_code, reason = "only the `quic` feature uses it"))] shard: Option, /// The worker's counters, held directly rather than reached through /// `owner`, so counting a datagram is not a `Weak::upgrade`. @@ -668,13 +668,13 @@ impl Socket { } /// The worker driving this socket, which everything built on it runs on. - #[cfg_attr(not(feature = "quic"), allow(dead_code))] + #[cfg_attr(not(feature = "quic"), allow(dead_code, reason = "only the `quic` feature uses it"))] pub(crate) fn owner(&self) -> Owner { self.shared.owner.clone() } /// This socket's slot in a steered reuseport group, if it is in one. - #[cfg_attr(not(feature = "quic"), allow(dead_code))] + #[cfg_attr(not(feature = "quic"), allow(dead_code, reason = "only the `quic` feature uses it"))] pub(crate) fn shard(&self) -> Option { self.shared.shard } @@ -712,7 +712,7 @@ impl Socket { /// Report sends that find no route through /// [`take_unreachable`](Self::take_unreachable) instead of failing every /// later send, for a consumer that routes them to the right connection. - #[cfg_attr(not(feature = "quic"), allow(dead_code))] + #[cfg_attr(not(feature = "quic"), allow(dead_code, reason = "only the `quic` feature uses it"))] pub(crate) fn route_unreachable(&self) { self.shared.rx.borrow_mut().unreachable.get_or_insert_default(); } @@ -721,7 +721,7 @@ impl Socket { /// /// Reported through the receive waiters, so whoever parks in /// [`poll_recv`](Self::poll_recv) is woken to collect it. - #[cfg_attr(not(feature = "quic"), allow(dead_code))] + #[cfg_attr(not(feature = "quic"), allow(dead_code, reason = "only the `quic` feature uses it"))] pub(crate) fn take_unreachable(&self) -> Option<(SocketAddr, io::Error)> { let (to, code) = self.shared.rx.borrow_mut().unreachable.as_mut()?.pop()?; Some((to, io::Error::from_raw_os_error(code))) diff --git a/rs/moq-uring/src/worker.rs b/rs/moq-uring/src/worker.rs index 42856a95dfa..5bfcf19c5b3 100644 --- a/rs/moq-uring/src/worker.rs +++ b/rs/moq-uring/src/worker.rs @@ -650,9 +650,9 @@ pub(crate) struct Owner { /// Held directly: a timer on a dropped worker still has to exist, since /// the driver that owns it is torn down by the same drop that would need /// it. - #[cfg_attr(not(feature = "quic"), allow(dead_code))] + #[cfg_attr(not(feature = "quic"), allow(dead_code, reason = "only the `quic` feature uses it"))] deadlines: moq_clock::Deadlines, - #[cfg_attr(not(feature = "quic"), allow(dead_code))] + #[cfg_attr(not(feature = "quic"), allow(dead_code, reason = "only the `quic` feature uses it"))] metrics: std::sync::Arc, } @@ -666,7 +666,7 @@ impl Owner { } /// The worker's time: the current turn's instant, or the clock's between turns. - #[cfg_attr(not(feature = "quic"), allow(dead_code))] + #[cfg_attr(not(feature = "quic"), allow(dead_code, reason = "only the `quic` feature uses it"))] pub fn now(&self) -> Instant { self.shared .upgrade() @@ -685,7 +685,7 @@ impl Owner { } /// Run a `!Send` future on the worker, or drop it if the worker is gone. - #[cfg_attr(not(feature = "quic"), allow(dead_code))] + #[cfg_attr(not(feature = "quic"), allow(dead_code, reason = "only the `quic` feature uses it"))] pub fn spawn(&self, future: impl Future + 'static) { if let Some(handle) = self.handle() { handle.spawn(future); @@ -693,13 +693,13 @@ impl Owner { } /// A disarmed timer on the worker. - #[cfg_attr(not(feature = "quic"), allow(dead_code))] + #[cfg_attr(not(feature = "quic"), allow(dead_code, reason = "only the `quic` feature uses it"))] pub fn timer(&self) -> crate::Timer { crate::Timer::from_queue(&self.deadlines, self.metrics.clone()) } /// A timer that expires after `duration`. - #[cfg_attr(not(feature = "quic"), allow(dead_code))] + #[cfg_attr(not(feature = "quic"), allow(dead_code, reason = "only the `quic` feature uses it"))] pub fn after(&self, duration: Duration) -> crate::Timer { let mut timer = self.timer(); timer.set(self.now().checked_add(duration)); diff --git a/rs/moq-uring/tests/integration/support.rs b/rs/moq-uring/tests/integration/support.rs index baa5cc2559d..751ee48ab1d 100644 --- a/rs/moq-uring/tests/integration/support.rs +++ b/rs/moq-uring/tests/integration/support.rs @@ -1,7 +1,7 @@ //! Shared test certificates. #![cfg(target_os = "linux")] -#![allow(dead_code)] +#![allow(dead_code, reason = "shared by several test binaries, each using only part of it")] /// A self-signed certificate on disk for `localhost` and `127.0.0.1`. pub struct Certs { diff --git a/rs/moq-uring/tests/integration/web.rs b/rs/moq-uring/tests/integration/web.rs index b07faed8963..35278f97f9a 100644 --- a/rs/moq-uring/tests/integration/web.rs +++ b/rs/moq-uring/tests/integration/web.rs @@ -340,8 +340,10 @@ async fn within(handle: &moq_uring::Handle, what: &str, future: impl Future std::thread::JoinHandle { std::thread::spawn(move || { let _ = rustls::crypto::aws_lc_rs::default_provider().install_default(); @@ -703,7 +705,7 @@ fn a_reset_stream_keeps_its_header_without_credit() { let mut filler = session.accept_uni().await.expect("accept_uni"); read_all(&mut filler).await; - #[allow(clippy::disallowed_methods)] // A watchdog on the tokio peer, not the worker. + #[expect(clippy::disallowed_methods, reason = "a watchdog on the tokio peer, not the worker")] let accept = tokio::time::timeout(std::time::Duration::from_secs(5), session.accept_uni()); let mut recv = accept.await.expect("the reset stream arrives").expect("accept_uni"); let err = recv.read_chunk(usize::MAX).await.expect_err("the server reset it"); diff --git a/rs/moq-v4l/Cargo.toml b/rs/moq-v4l/Cargo.toml index e6229eaa55e..5e8c23eb269 100644 --- a/rs/moq-v4l/Cargo.toml +++ b/rs/moq-v4l/Cargo.toml @@ -15,3 +15,6 @@ categories = ["multimedia::video", "os::linux-apis"] [dependencies] bitflags = { workspace = true } libc = { workspace = true } + +[lints] +workspace = true diff --git a/rs/moq-v4l/src/buffer.rs b/rs/moq-v4l/src/buffer.rs index d08d7430096..3159e4d4202 100644 --- a/rs/moq-v4l/src/buffer.rs +++ b/rs/moq-v4l/src/buffer.rs @@ -6,7 +6,6 @@ use crate::timestamp::Timestamp; /// Buffer type /// /// Specific types of devices require buffers of corresponding types. -#[allow(clippy::unreadable_literal)] #[rustfmt::skip] #[repr(u32)] #[derive(Debug, Clone, Copy)] @@ -31,7 +30,6 @@ pub enum Type { } bitflags! { - #[allow(clippy::unreadable_literal)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct Flags: u32 { /// Buffer is mapped diff --git a/rs/moq-v4l/src/capability.rs b/rs/moq-v4l/src/capability.rs index 04b36190646..eb61f5bb52a 100644 --- a/rs/moq-v4l/src/capability.rs +++ b/rs/moq-v4l/src/capability.rs @@ -4,7 +4,6 @@ use std::{fmt, str}; use crate::sys::*; bitflags! { - #[allow(clippy::unreadable_literal)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct Flags: u32 { const VIDEO_CAPTURE = 0x00000001; diff --git a/rs/moq-v4l/src/control.rs b/rs/moq-v4l/src/control.rs index 93732a43901..5cbad62e531 100644 --- a/rs/moq-v4l/src/control.rs +++ b/rs/moq-v4l/src/control.rs @@ -5,7 +5,6 @@ use std::{ffi, fmt, mem, str}; use crate::sys::*; /// Control data type -#[allow(clippy::unreadable_literal)] #[rustfmt::skip] #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq)] @@ -64,7 +63,6 @@ impl fmt::Display for Type { } bitflags! { - #[allow(clippy::unreadable_literal)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct Flags: u32 { const DISABLED = 0x0001; diff --git a/rs/moq-v4l/src/format/description.rs b/rs/moq-v4l/src/format/description.rs index 84aff27e8af..19e1e814ac8 100644 --- a/rs/moq-v4l/src/format/description.rs +++ b/rs/moq-v4l/src/format/description.rs @@ -5,7 +5,6 @@ use crate::format::FourCC; use crate::sys::*; bitflags! { - #[allow(clippy::unreadable_literal)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct Flags : u32 { const COMPRESSED = 0x0001; diff --git a/rs/moq-v4l/src/format/fourcc.rs b/rs/moq-v4l/src/format/fourcc.rs index e0e51fbea89..f540ffb9015 100644 --- a/rs/moq-v4l/src/format/fourcc.rs +++ b/rs/moq-v4l/src/format/fourcc.rs @@ -7,7 +7,6 @@ pub struct FourCC { } impl FourCC { - #[allow(clippy::trivially_copy_pass_by_ref)] /// Returns a pixelformat as four character code /// /// # Arguments diff --git a/rs/moq-v4l/src/format/mod.rs b/rs/moq-v4l/src/format/mod.rs index 7b1d30a4bf9..18f637570b9 100644 --- a/rs/moq-v4l/src/format/mod.rs +++ b/rs/moq-v4l/src/format/mod.rs @@ -22,7 +22,6 @@ pub mod transfer; pub use transfer::TransferFunction; bitflags! { - #[allow(clippy::unreadable_literal)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct Flags : u32 { const PREMUL_ALPHA = 0x00000001; diff --git a/rs/moq-v4l/src/frameinterval.rs b/rs/moq-v4l/src/frameinterval.rs index 77dd54eb8fe..80012598ded 100644 --- a/rs/moq-v4l/src/frameinterval.rs +++ b/rs/moq-v4l/src/frameinterval.rs @@ -44,7 +44,7 @@ impl TryFrom for FrameIntervalEnum { fn try_from(desc: v4l2_frmivalenum) -> Result { unsafe { // Unsafe because of access to union __bindgen_anon_1 - #[allow(non_upper_case_globals)] + #[expect(non_upper_case_globals, reason = "the arms match bindgen's C constant names")] match desc.type_ { v4l2_frmivaltypes_V4L2_FRMIVAL_TYPE_DISCRETE => Ok(FrameIntervalEnum::Discrete(Fraction::from( desc.__bindgen_anon_1.discrete, diff --git a/rs/moq-v4l/src/framesize.rs b/rs/moq-v4l/src/framesize.rs index 809ae227f38..2efaea21d59 100644 --- a/rs/moq-v4l/src/framesize.rs +++ b/rs/moq-v4l/src/framesize.rs @@ -61,7 +61,7 @@ impl TryFrom for FrameSizeEnum { fn try_from(desc: v4l2_frmsizeenum) -> Result { unsafe { // Unsafe because of access to union __bindgen_anon_1 - #[allow(non_upper_case_globals)] + #[expect(non_upper_case_globals, reason = "the arms match bindgen's C constant names")] match desc.type_ { v4l2_frmsizetypes_V4L2_FRMSIZE_TYPE_DISCRETE => Ok({ FrameSizeEnum::Discrete(Discrete { diff --git a/rs/moq-v4l/src/memory.rs b/rs/moq-v4l/src/memory.rs index 375f4ac5a91..9efc2d7c5b7 100644 --- a/rs/moq-v4l/src/memory.rs +++ b/rs/moq-v4l/src/memory.rs @@ -1,7 +1,6 @@ use std::fmt; /// Memory used for buffer exchange -#[allow(clippy::unreadable_literal)] #[rustfmt::skip] #[repr(u32)] pub enum Memory { diff --git a/rs/moq-v4l/src/parameters.rs b/rs/moq-v4l/src/parameters.rs index 66716baea43..7e002f34b21 100644 --- a/rs/moq-v4l/src/parameters.rs +++ b/rs/moq-v4l/src/parameters.rs @@ -4,7 +4,6 @@ use std::fmt; bitflags! { #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct Capabilities: u32 { - #[allow(clippy::unreadable_literal)] const TIME_PER_FRAME = 0x1000; } } diff --git a/rs/moq-v4l/src/sys/mod.rs b/rs/moq-v4l/src/sys/mod.rs index 83dc870861d..a5845123f36 100644 --- a/rs/moq-v4l/src/sys/mod.rs +++ b/rs/moq-v4l/src/sys/mod.rs @@ -2,9 +2,9 @@ //! via `bindgen.sh` and checked in. The output is plain C-ABI struct, enum, and //! constant definitions with no layout tests, and `timeval` / `timespec` come //! from `libc`, so one file serves every Linux target. -#![allow(clippy::all)] -#![allow(non_camel_case_types)] -#![allow(non_snake_case)] -#![allow(non_upper_case_globals)] +#![allow(clippy::all, reason = "bindgen output")] +#![expect(non_camel_case_types, reason = "bindgen output")] +#![expect(non_snake_case, reason = "bindgen output")] +#![expect(non_upper_case_globals, reason = "bindgen output")] include!("videodev2.rs"); diff --git a/rs/moq-v4l/src/v4l2/vidioc.rs b/rs/moq-v4l/src/v4l2/vidioc.rs index 6699afbcb30..951cc9c40ef 100644 --- a/rs/moq-v4l/src/v4l2/vidioc.rs +++ b/rs/moq-v4l/src/v4l2/vidioc.rs @@ -1,10 +1,10 @@ use crate::sys::*; #[cfg(not(target_env = "musl"))] -#[allow(non_camel_case_types)] +#[expect(non_camel_case_types, reason = "mirrors the kernel's `_IOC_TYPE`")] pub type _IOC_TYPE = std::os::raw::c_ulong; #[cfg(target_env = "musl")] -#[allow(non_camel_case_types)] +#[expect(non_camel_case_types, reason = "mirrors the kernel's `_IOC_TYPE`")] pub type _IOC_TYPE = std::os::raw::c_int; // linux ioctl.h diff --git a/rs/moq-video/Cargo.toml b/rs/moq-video/Cargo.toml index 1223c402e98..9dcdd4a2da5 100644 --- a/rs/moq-video/Cargo.toml +++ b/rs/moq-video/Cargo.toml @@ -281,3 +281,6 @@ pollster = { workspace = true } # `start_paused`, so the capture driver tests run on mocked time. tokio = { workspace = true, features = ["test-util"] } tracing-test = { workspace = true } + +[lints] +workspace = true diff --git a/rs/moq-video/src/capture/avfoundation.rs b/rs/moq-video/src/capture/avfoundation.rs index d908e5bad6d..17beb0dc8ae 100644 --- a/rs/moq-video/src/capture/avfoundation.rs +++ b/rs/moq-video/src/capture/avfoundation.rs @@ -45,12 +45,10 @@ const ACCESS_TIMEOUT: Duration = Duration::from_secs(60); /// unauthorized process still sees the devices, just not their frames. pub(super) fn cameras() -> Result, Error> { let media = unsafe { AVMediaTypeVideo }.ok_or_else(|| Error::Codec(anyhow::anyhow!("AVMediaTypeVideo")))?; - // The suggested replacement, AVCaptureDeviceDiscoverySession, has to be handed - // an explicit list of device types, and the constants for external and - // Continuity cameras are macOS 14+. Naming them would drop those cameras on - // older systems (or miss a symbol); this returns every video device on every - // version, which is exactly what listing wants. - #[allow(deprecated)] + #[expect( + deprecated, + reason = "its replacement needs device-type constants that are macOS 14+, which would drop cameras on older systems" + )] let devices = unsafe { AVCaptureDevice::devicesWithMediaType(media) }; Ok((0..devices.count()) .map(|index| devices.objectAtIndex(index)) diff --git a/rs/moq-video/src/decode/conformance.rs b/rs/moq-video/src/decode/conformance.rs index 1fa57e97b25..a723f5205db 100644 --- a/rs/moq-video/src/decode/conformance.rs +++ b/rs/moq-video/src/decode/conformance.rs @@ -1,4 +1,7 @@ -#![cfg_attr(not(feature = "openh264"), allow(dead_code))] +#![cfg_attr( + not(feature = "openh264"), + allow(dead_code, reason = "only the `openh264` feature uses it") +)] //! H.264 conformance decode: bitstreams nothing in this crate produced. //! diff --git a/rs/moq-video/src/decode/consumer.rs b/rs/moq-video/src/decode/consumer.rs index e982a8ac425..ad60bb26ca8 100644 --- a/rs/moq-video/src/decode/consumer.rs +++ b/rs/moq-video/src/decode/consumer.rs @@ -371,7 +371,10 @@ impl Reader { #[cfg(test)] mod tests { - #![cfg_attr(not(feature = "openh264"), allow(dead_code, unused_imports))] + #![cfg_attr( + not(feature = "openh264"), + allow(dead_code, unused_imports, reason = "only the `openh264` feature uses it") + )] use bytes::Bytes; use moq_net::Timestamp; diff --git a/rs/moq-video/src/decode/decoder.rs b/rs/moq-video/src/decode/decoder.rs index acd280f6adb..f5e49398fe1 100644 --- a/rs/moq-video/src/decode/decoder.rs +++ b/rs/moq-video/src/decode/decoder.rs @@ -372,7 +372,10 @@ fn is_supported_vp9(vp9: &VP9) -> bool { #[cfg(test)] mod tests { - #![cfg_attr(not(feature = "openh264"), allow(dead_code, unused_imports))] + #![cfg_attr( + not(feature = "openh264"), + allow(dead_code, unused_imports, reason = "only the `openh264` feature uses it") + )] use moq_net::Timestamp; diff --git a/rs/moq-video/src/encode/backend/mediafoundation.rs b/rs/moq-video/src/encode/backend/mediafoundation.rs index 06fea2abe59..ff9eede829a 100644 --- a/rs/moq-video/src/encode/backend/mediafoundation.rs +++ b/rs/moq-video/src/encode/backend/mediafoundation.rs @@ -353,7 +353,10 @@ impl MediaFoundation { buffer }, Surface::I420(_) => self.upload_nv12(frame)?, - #[allow(unreachable_patterns)] + #[allow( + unreachable_patterns, + reason = "the other surfaces exist only on some platforms and features" + )] _ => { return Err(Error::Codec(anyhow::anyhow!( "unsupported frame for mediafoundation encoder" diff --git a/rs/moq-video/src/encode/backend/mod.rs b/rs/moq-video/src/encode/backend/mod.rs index ea9b000437e..05613f4e4d0 100644 --- a/rs/moq-video/src/encode/backend/mod.rs +++ b/rs/moq-video/src/encode/backend/mod.rs @@ -174,7 +174,10 @@ struct Candidate { open: fn(&Config) -> Result, Error>, /// Whether every encoder this opens honors a cut ([`Backend::can_cut`]), known before /// opening one. V4L2 learns it from the driver at open, so it cannot promise. - #[cfg_attr(not(feature = "capture"), allow(dead_code))] + #[cfg_attr( + not(feature = "capture"), + allow(dead_code, reason = "only the `capture` feature uses it") + )] cuts: bool, #[cfg(target_os = "linux")] vulkan: bool, @@ -315,7 +318,10 @@ pub(crate) fn open(config: &Config) -> Result, Error> { /// Whether whichever backend [`open`] picks for `codec` + `kind` honors a cut, answered /// before opening one: every candidate it may fall to must promise it. -#[cfg_attr(not(feature = "capture"), allow(dead_code))] +#[cfg_attr( + not(feature = "capture"), + allow(dead_code, reason = "only the `capture` feature uses it") +)] pub(crate) fn always_cuts(codec: Codec, kind: &Kind) -> bool { let attempts = attempts(codec, kind); !attempts.is_empty() && attempts.iter().all(|attempt| attempt.candidate.cuts) @@ -438,7 +444,10 @@ fn available_names(codec: Codec) -> Vec<&'static str> { } #[cfg(test)] -#[cfg_attr(not(feature = "openh264"), allow(dead_code))] +#[cfg_attr( + not(feature = "openh264"), + allow(dead_code, reason = "only the `openh264` feature uses it") +)] pub(crate) mod test_util { use h264_reader::nal::sps::SeqParameterSet; use h264_reader::nal::{Nal, RefNal, UnitType}; @@ -519,7 +528,10 @@ pub(crate) mod test_util { #[cfg(test)] mod tests { - #![cfg_attr(not(feature = "openh264"), allow(dead_code, unused_imports))] + #![cfg_attr( + not(feature = "openh264"), + allow(dead_code, unused_imports, reason = "only the `openh264` feature uses it") + )] use super::*; diff --git a/rs/moq-video/src/encode/backend/videotoolbox.rs b/rs/moq-video/src/encode/backend/videotoolbox.rs index d17d25f3475..77249dc495c 100644 --- a/rs/moq-video/src/encode/backend/videotoolbox.rs +++ b/rs/moq-video/src/encode/backend/videotoolbox.rs @@ -436,7 +436,10 @@ fn annexb_from_sample(sample: &CMSampleBuffer, codec: Codec) -> Result) -> Self { Self { @@ -563,7 +563,10 @@ impl Encoder { #[cfg(test)] mod tests { - #![cfg_attr(not(feature = "openh264"), allow(dead_code, unused_imports))] + #![cfg_attr( + not(feature = "openh264"), + allow(dead_code, unused_imports, reason = "only the `openh264` feature uses it") + )] use super::*; diff --git a/rs/moq-video/src/encode/mod.rs b/rs/moq-video/src/encode/mod.rs index 0e12c14a826..005a9709cc5 100644 --- a/rs/moq-video/src/encode/mod.rs +++ b/rs/moq-video/src/encode/mod.rs @@ -32,13 +32,18 @@ //! estimate onto the encoder's bitrate, which `publish_capture` drives for you. mod backend; +#[cfg_attr( + not(feature = "capture"), + allow( + dead_code, + reason = "compiled without `capture` so its tests stay in the default merge gate" + ) +)] +mod cuts; mod encoded; mod encoder; mod producer; mod sink; -// Compiled without `capture` so its tests stay in the default merge gate. -#[cfg_attr(not(feature = "capture"), allow(dead_code))] -mod cuts; pub use backend::NAMES; pub use encoded::Encoded; diff --git a/rs/moq-video/src/encode/producer.rs b/rs/moq-video/src/encode/producer.rs index 2d8ea2eb45f..0d35503dd1b 100644 --- a/rs/moq-video/src/encode/producer.rs +++ b/rs/moq-video/src/encode/producer.rs @@ -94,10 +94,16 @@ enum Codecs { pub struct Producer { codecs: Codecs, /// The published track, read for its largest group. - #[cfg_attr(not(feature = "capture"), allow(dead_code))] + #[cfg_attr( + not(feature = "capture"), + allow(dead_code, reason = "only the `capture` feature uses it") + )] track: moq_net::track::Producer, /// The largest group published, as last read from `track`. - #[cfg_attr(not(feature = "capture"), allow(dead_code))] + #[cfg_attr( + not(feature = "capture"), + allow(dead_code, reason = "only the `capture` feature uses it") + )] largest: Option, _ext: std::marker::PhantomData E>, } @@ -538,7 +544,7 @@ pub async fn publish_capture( /// the future ever regains a `!Send` component. Apple platforms are exempt (the inline encoder and objc /// capture session are `!Send`). #[cfg(all(feature = "capture", not(apple)))] -#[allow(dead_code)] +#[allow(dead_code, reason = "a compile-time `Send` assertion, never called")] fn assert_publish_capture_send( broadcast: moq_net::broadcast::Producer, catalog: moq_mux::catalog::Producer, @@ -830,7 +836,10 @@ fn map_capture_timestamp(epoch_micros: u64, timestamp: Timestamp) -> Result