diff --git a/Cargo.toml b/Cargo.toml index cc3642a3591..4fbf3725d34 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -115,6 +115,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/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/js/publish/src/source/file.ts b/js/publish/src/source/file.ts index f76caac57af..ef584984930 100644 --- a/js/publish/src/source/file.ts +++ b/js/publish/src/source/file.ts @@ -162,6 +162,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. @@ -171,19 +176,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), @@ -191,8 +191,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", } @@ -295,8 +294,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"); @@ -314,7 +315,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; } diff --git a/js/publish/src/source/screen.ts b/js/publish/src/source/screen.ts index 5af54e22a15..7153f925c3d 100644 --- a/js/publish/src/source/screen.ts +++ b/js/publish/src/source/screen.ts @@ -75,11 +75,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"); } @@ -90,7 +90,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 1655cacf538..605ab7c27de 100644 --- a/js/publish/src/video/encoder.ts +++ b/js/publish/src/video/encoder.ts @@ -810,7 +810,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, }; 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/quest/m0/README.md b/quest/m0/README.md index 4258edd6ed6..3b5ae4f30fa 100644 --- a/quest/m0/README.md +++ b/quest/m0/README.md @@ -46,4 +46,3 @@ Each lands its fixes in its own PR and plans only what needs a decision. - [Release shutdown backport](/quest/m0/ffi-shutdown-backport.md) - `release` publishes a non-breaking moq-ffi with an async `drain()` and qmux sessions on the QUIC stream limit - [Release fixed delay](/quest/m0/release-fixed-delay.md) - a fixed latency on `release`, which moq.dev runs, ignores the catalog's jitter and delay as `main` already does - [CI cost and latency](/quest/m0/ci/README.md) - cloud CI runs only in the merge queue as one `just ci` pass, expensive checks run nightly and gate `release`, caches move to R2, and runners are chosen last -- [Lint override and deprecation audit](/quest/m0/audit-lints.md) - every lint suppression is still needed and says why, nothing calls a deprecated API, and stale Rust overrides fail the build diff --git a/quest/m0/audit-lints.md b/quest/m0/audit-lints.md deleted file mode 100644 index 4907512110b..00000000000 --- a/quest/m0/audit-lints.md +++ /dev/null @@ -1,90 +0,0 @@ -# [M] Lint override and deprecation audit - -## Goal - -Every lint suppression in first-party code, in every language, is still -needed and says why, or is removed. Nothing calls a deprecated upstream API, -and our own deprecated items are removed or planned for removal once their -migration window has passed. - -## Plan - -Recurs once per major release (decided 2026-10-20). The PR that finishes -this run also adds the next one with the same file name at the end of the next -milestone's `Required` (m0 to m1, m1 to m2). The successor keeps the Goal -and this paragraph; the rest of its Plan is rewritten with what this run -learned: baselines, results, and what to check first. A successor placed in m2 -also lists the [release cut](/quest/m2/release/cut.md) under `Required`, so it -waits for the release in flight to ship. Only `/quest-delete` ends the -recurrence. Fixes land in the run's PR, one commit each, rather than as follow-ups. -Only a change that needs a maintainer decision (public API, scope) or is -independently landable and too large to review alongside the rest becomes a -follow-up through `/quest-plan`. - -Scope is every language (decided 2026-10-20): clippy and rustc overrides, -`clippy.toml`, `biome-ignore`, `@ts-expect-error`, `noqa` and -`type: ignore`, Kotlin `@Suppress`, and the equivalents in Go, Swift, Dart, -and C/C++. `dead_code` and `unused` suppressions belong to the [dead code -audit](/quest/m2/audit-dead-code.md); skip them here. Generated or vendored -bindings (`moq-nvenc`, `moq-v4l/src/sys`, `moq-rtmp/src/rml`, and the -untracked UniFFI output) keep their blanket allows unless the generator can -emit clean code. - -A suppression stays only when fixing the lint would make the code worse; a -signature reshaped to satisfy `too_many_arguments` or `large_enum_variant` -on a public type is an API change, so it is a follow-up. Removing one of our -own deprecated exports or hidden CLI spellings is a breaking change with a -`MIGRATE.md` entry, so it is also a follow-up. - -### Enforcement (first run only) - -Make a stale Rust suppression fail loudly instead of waiting for the next run -(decided 2026-10-20). Convert each unconditional `#[allow(clippy::...)]` to -`#[expect(clippy::..., reason = "...")]`, and add a `[workspace.lints]` -table enabling `clippy::allow_attributes_without_reason` that every crate -opts into with `lints.workspace = true`. `moq-net`, `moq-quic`, and `kio` -already have their own `[lints]` tables, which must merge into the -workspace one. A suppression needed under only some features or platforms -uses `cfg_attr` or stays an `allow` with its reason, since an `expect` fails -on the builds where the lint never fires. Later runs then only review -reasons and the conditional allows. - -Other languages are audited by hand each run. TypeScript already uses -`@ts-expect-error` everywhere (no `@ts-ignore`), which errors when unneeded; -check whether Biome reports unused `biome-ignore` comments, and whether -ruff's `RUF100` (unused `noqa`) is worth adding to the root `pyproject.toml` -selection. - -### Deprecations - -Rust deprecation warnings already fail under `-D warnings`, so look where -that gate is blind: `#[allow(deprecated)]`, and targets CI doesn't build -(the macOS AVFoundation capture path). `tsc` reports deprecated use only as -an editor hint, so sweep TypeScript once with a typed linter such as -typescript-eslint's `no-deprecated`, outside the package dependency graph -unless it can join CI cheaply. Search each binding's toolchain for its -deprecation output too. - -### Baselines (2026-10-20) - -- Rust: 147 `clippy::` allow/expect attributes (9 already `expect`). Most - common: `disallowed_methods` 37 and `disallowed_types` 13 (the ambient - clock guard in 10 `clippy.toml` files; benchmarks and the `moq-clock` - runtime opt out), `match_like_matches_macro` 23, `large_enum_variant` 19, - `too_many_arguments` 10, `result_large_err` 10, `unreadable_literal` 9, - `type_complexity` 8, `arc_with_non_send_sync` 7. `moq-quic` allows - `cognitive_complexity` and `too_many_arguments` crate-wide. -- Rust `#[allow(deprecated)]`: 2, in a `moq-relay` cluster test and - `moq-video` AVFoundation capture. No `#[deprecated]` items of our own. -- TypeScript: 39 `biome-ignore` and 47 `@ts-expect-error`, of which 6 and 2 - sit outside `js/` (`demo/carla`, `sh/gh`, `test/audio-quality`, - `test/smoke`). No `@deprecated` exports. -- Python: 30 `noqa` or `type: ignore`, 24 of them in `py/moq-rs/tests`. - Kotlin, Go, Swift, Dart, and C/C++ had none found by a plain grep; confirm - with each toolchain's own syntax. - -Count with `git grep` over the whole tree, not per language directory, so -only tracked files count and none outside `rs/`, `js/`, or `py/` are missed. Generated UniFFI bindings -are untracked (`kt/.gitignore`) and carry their own suppressions, such as -Kotlin's 139 `@Suppress`; leave them out, and fix a noisy one in the generator -config instead of the output. diff --git a/quest/m1/README.md b/quest/m1/README.md index 51a08a925f3..188960eccb4 100644 --- a/quest/m1/README.md +++ b/quest/m1/README.md @@ -158,6 +158,7 @@ tracks, so per-group stats stop costing cluster announces. - [Binding peer version](/quest/m1/binding-peer-version.md) - every binding names itself ahead of the Rust core in that parameter - [Nightly benchmark regressions](/quest/m1/bench-ci.md) - each nightly compares the Rust Criterion benches against the previous nightly's commit on the same hosted runner, publishes it to the git.moq.dev report, and alerts on a regression - [Interop audit](/quest/m1/audit-interop.md) - our interop runner entries match what we ship, and every red interop cell with a moq.dev side is fixed, reported, or noted as down +- [Lint override and deprecation audit](/quest/m1/audit-lints.md) - repeat the suppression and deprecation audit, starting with the conditional allows and the lanes clippy never runs ## Related diff --git a/quest/m1/audit-lints.md b/quest/m1/audit-lints.md new file mode 100644 index 00000000000..adb0b75607e --- /dev/null +++ b/quest/m1/audit-lints.md @@ -0,0 +1,105 @@ +# [M] Lint override and deprecation audit + +## Goal + +Every lint suppression in first-party code, in every language, is still +needed and says why, or is removed. Nothing calls a deprecated upstream API, +and our own deprecated items are removed or planned for removal once their +migration window has passed. + +## Plan + +Recurs once per major release (decided 2026-10-20). The PR that finishes +this run also adds the next one with the same file name at the end of the next +milestone's `Required` (m0 to m1, m1 to m2). The successor keeps the Goal +and this paragraph; the rest of its Plan is rewritten with what this run +learned: baselines, results, and what to check first. A successor placed in m2 +also lists the [release cut](/quest/m2/release/cut.md) under `Required`, so it +waits for the release in flight to ship. Only `/quest-delete` ends the +recurrence. Fixes land in the run's PR, one commit each, rather than as follow-ups. +Only a change that needs a maintainer decision (public API, scope) or is +independently landable and too large to review alongside the rest becomes a +follow-up through `/quest-plan`. + +Scope is every language (decided 2026-10-20): clippy and rustc overrides, +`clippy.toml`, `biome-ignore`, `@ts-expect-error`, `noqa` and +`type: ignore`, Kotlin `@Suppress`, and the equivalents in Go, Swift, Dart, +and C/C++. `dead_code` and `unused` suppressions belong to the [dead code +audit](/quest/m2/audit-dead-code.md); skip them here. Generated or vendored +bindings (`moq-nvenc`, `moq-v4l/src/sys`, `moq-rtmp/src/rml`, and the +untracked UniFFI output) keep their blanket allows unless the generator can +emit clean code. Shell `shellcheck disable` comments stay out of scope. + +A suppression stays only when fixing the lint would make the code worse; a +signature reshaped to satisfy `too_many_arguments` or `large_enum_variant` +on a public type is an API change, so it is a follow-up. Removing one of our +own deprecated exports or hidden CLI spellings is a breaking change with a +`MIGRATE.md` entry, so it is also a follow-up. + +### What the m0 run left in place + +Every workspace crate but `moq-quic` sets `lints.workspace = true`, and the +root `[workspace.lints]` enables `clippy::allow_attributes_without_reason`, so a +suppression without a reason fails clippy. Unconditional suppressions are +`#[expect(..., reason = "...")]`, so a stale one fails as +`unfulfilled_lint_expectations`. A crate needing extra lints gets its own +manifest `[lints]` tables that repeat that rule (`moq-quic/Cargo.toml`), since +Cargo can't extend the workspace table per crate and crate attributes skip +benches and examples. Biome reports an unused `biome-ignore` as +`suppressions/unused`, and ruff selects `RUF100` (root and +`demo/carla/sim`). This run only reviews what those gates can't see. + +### Check first + +- Conditional suppressions: every `cfg_attr(..., allow(...))` and every + plain `allow` with a reason. Ask whether the condition still holds or the + lint now fires everywhere (then `expect`) or nowhere (then delete). The + wasm lane also lints `moq-net` and `moq-flate` as dependencies, so a + suppression there must hold on wasm32 too. +- Lanes clippy never runs: the macOS and Windows platform lane is + `cargo check` only, so an `expect` on Apple or Windows code + (`moq-video` AVFoundation, `moq-sock`) is unverified. Run clippy there or + confirm by reading. +- Python type ignores: run pyright with + `reportUnnecessaryTypeIgnoreComment`, which m0 didn't. +- Swift: grep and build for deprecation warnings, which m0 didn't. +- TypeScript deprecations: typescript-eslint doesn't support the repo's TS 7 + yet, so m0 swept `no-deprecated` from a throwaway package pinning + typescript 6 and eslint 9. Files outside any `tsconfig` project can't be + typed-linted. Check whether typescript-eslint supports TS 7 before + repeating that setup; if it does, consider joining CI. +- `sh/rs/model-markers.py` walks attributes above a model marker, including + ones rustfmt wraps over several lines. Run its tests if a long reason moves + near a marker. + +### Results (m0, 2026-10-20) + +- Rust: workspace lints adopted, every suppression given a reason, and + stale ones removed: 27 `match_like_matches_macro` (now `matches!`), 27 + `non_camel_case_types` on `repr(C)` structs, `moq-quic`'s crate-wide + `cognitive_complexity` and `too_many_arguments`, and stale + `type_complexity`, `arc_with_non_send_sync`, `field_reassign_with_default`, + `disallowed_methods`, and pedantic allows. +- Deprecations: `js/publish` file import moved to mediabunny's async track + getters. The `moq-relay` cluster test's `#[allow(deprecated)]` was stale. + Go (staticcheck `SA1019`), Kotlin, and Dart (`--fatal-infos`) were clean. + +### Baselines (2026-10-20, after the m0 run) + +- Rust `clippy::` suppression attributes: 189 (168 `expect`, 12 `cfg_attr` + `expect`, 9 `allow`), counted 2026-10-22 after main's moq-clock move. + Most common: `disallowed_methods` 123, `disallowed_types` 48, + `large_enum_variant` 24, mostly test modules reading the host clock. +- Rust rustc and rustdoc suppressions: 64 (49 `expect`, 15 `allow`), led by + `non_camel_case_types` 19 on C ABI enums. `dead_code` and `unused`: 421, + owned by the dead code audit. +- Rust `deprecated`: 1, the macOS AVFoundation `devicesWithMediaType`. +- TypeScript: 40 `biome-ignore` and 47 `@ts-expect-error`. +- Python: 26 `noqa` or `type: ignore`. + +Count with `git grep` over the whole tree, not per language directory, so +only tracked files count and none outside `rs/`, `js/`, or `py/` are missed. +Count multi-line Rust attributes too, since rustfmt wraps long ones. +Generated UniFFI bindings are untracked (`kt/.gitignore`) and carry their own +suppressions, such as Kotlin's 139 `@Suppress`; leave them out, and fix a +noisy one in the generator config instead of the output. diff --git a/rs/hang/Cargo.toml b/rs/hang/Cargo.toml index a189907d10d..f04c3e25327 100644 --- a/rs/hang/Cargo.toml +++ b/rs/hang/Cargo.toml @@ -37,3 +37,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 d9c5a740ca0..28f70e0ae97 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 a0b47661cbc..5de2c6b1b0f 100644 --- a/rs/moq-archive/Cargo.toml +++ b/rs/moq-archive/Cargo.toml @@ -42,3 +42,6 @@ tokio = { workspace = true, features = ["macros", "net", "rt", "test-util"] } [[bench]] name = "producer" harness = false + +[lints] +workspace = true diff --git a/rs/moq-archive/benches/producer.rs b/rs/moq-archive/benches/producer.rs index 12e41f8fb7e..a2f9155cdce 100644 --- a/rs/moq-archive/benches/producer.rs +++ b/rs/moq-archive/benches/producer.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" +)] //! `Producer::run` recording every track of a broadcast into memory, swept over the number of //! tracks and the groups each one holds. Throughput is per frame, so a per-event cost that grows 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-audio/Cargo.toml b/rs/moq-audio/Cargo.toml index a0af4769257..0793a8298ed 100644 --- a/rs/moq-audio/Cargo.toml +++ b/rs/moq-audio/Cargo.toml @@ -141,3 +141,6 @@ objc2-screen-capture-kit = { workspace = true, features = ["SCStream", "SCSharea serde = { workspace = true } serde_json = { workspace = true } tokio = { workspace = true, features = ["macros", "rt", "test-util"] } + +[lints] +workspace = true diff --git a/rs/moq-audio/src/aec.rs b/rs/moq-audio/src/aec.rs index fc40ce13e63..19e41eec3e4 100644 --- a/rs/moq-audio/src/aec.rs +++ b/rs/moq-audio/src/aec.rs @@ -626,7 +626,11 @@ fn channel(rate: u32) -> (ResamplingProd, ResamplingCons) { } #[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 std::collections::VecDeque; use std::time::Duration; diff --git a/rs/moq-audio/src/capture/buffer.rs b/rs/moq-audio/src/capture/buffer.rs index cf58ad8a812..4f124ff8a28 100644 --- a/rs/moq-audio/src/capture/buffer.rs +++ b/rs/moq-audio/src/capture/buffer.rs @@ -89,8 +89,10 @@ fn relay(mut pending: HeapCons, tx: mpsc::Sender) { if !pending.write_is_held() { return; } - // The device thread runs outside any runtime, so it blocks on the host clock. - #[allow(clippy::disallowed_methods)] + #[expect( + clippy::disallowed_methods, + reason = "the device thread runs outside any runtime, so it blocks on the host clock" + )] std::thread::sleep(RELAY_POLL_INTERVAL); } } diff --git a/rs/moq-audio/src/encode/capture.rs b/rs/moq-audio/src/encode/capture.rs index 38300a6b750..0040ec8e409 100644 --- a/rs/moq-audio/src/encode/capture.rs +++ b/rs/moq-audio/src/encode/capture.rs @@ -623,7 +623,10 @@ enum DriveEvent { /// /// One per publication, moved twice in its life, so the size difference between /// the variants never costs a copy worth an allocation to avoid. -#[allow(clippy::large_enum_variant)] +#[expect( + clippy::large_enum_variant, + reason = "one per publication and moved twice, so boxing the large variant saves nothing" +)] enum Track { /// 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, @@ -1211,7 +1214,11 @@ fn frame(samples: &[f32], timestamp_us: u64) -> Result { } #[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 std::collections::VecDeque; use std::future::Future; diff --git a/rs/moq-audio/src/encode/producer.rs b/rs/moq-audio/src/encode/producer.rs index 758d7ef6016..dab38a56d52 100644 --- a/rs/moq-audio/src/encode/producer.rs +++ b/rs/moq-audio/src/encode/producer.rs @@ -571,7 +571,7 @@ impl Producer { } #[cfg(test)] -#[allow(clippy::disallowed_methods, clippy::disallowed_types)] +#[expect(clippy::disallowed_methods, reason = "tests read the host clock directly")] mod tests { async fn decoded_frame(consumer: &mut crate::decode::Consumer) -> Result, Error> { loop { diff --git a/rs/moq-audio/src/playback/driver.rs b/rs/moq-audio/src/playback/driver.rs index f902d20ce22..dcb560cab7d 100644 --- a/rs/moq-audio/src/playback/driver.rs +++ b/rs/moq-audio/src/playback/driver.rs @@ -937,8 +937,10 @@ impl Driver { } // The mixer's queue is full, which takes a burst far larger than a // device period. Give it a period to drain and try again. - // The device thread runs outside any runtime, so it blocks on the host clock. - #[allow(clippy::disallowed_methods)] + #[expect( + clippy::disallowed_methods, + reason = "the device thread runs outside any runtime, so it blocks on the host clock" + )] std::thread::sleep(SYNC_DELAY); } @@ -1010,7 +1012,7 @@ impl Driver { } #[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::playback::sink::{self, Input}; diff --git a/rs/moq-audio/src/playback/mixer.rs b/rs/moq-audio/src/playback/mixer.rs index 18c09ca142c..cdf0925db8c 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), @@ -396,7 +399,11 @@ impl Mixer { } #[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 std::sync::mpsc::{Receiver, SyncSender, sync_channel}; diff --git a/rs/moq-audio/tests/integration/main.rs b/rs/moq-audio/tests/integration/main.rs index 425e596c7e0..9c1796e78cc 100644 --- a/rs/moq-audio/tests/integration/main.rs +++ b/rs/moq-audio/tests/integration/main.rs @@ -2,7 +2,7 @@ //! //! Each `tests/*.rs` file is its own crate that links this package and its //! dependencies again, so add new integration tests here as a module. -#![allow(clippy::disallowed_methods, clippy::disallowed_types)] +#![expect(clippy::disallowed_methods, reason = "tests read the host clock directly")] mod import; mod playback; diff --git a/rs/moq-audio/tests/integration/playback.rs b/rs/moq-audio/tests/integration/playback.rs index e1362a5a995..0f81b708a1b 100644 --- a/rs/moq-audio/tests/integration/playback.rs +++ b/rs/moq-audio/tests/integration/playback.rs @@ -14,6 +14,7 @@ //! the mix is metered before it reaches the device. #![cfg(feature = "playback")] +#![expect(clippy::disallowed_types, reason = "tests read the host clock directly")] use std::time::Duration; 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/examples/asymmetric.rs b/rs/moq-auth/examples/asymmetric.rs index 6799587392d..b92f4213d1b 100644 --- a/rs/moq-auth/examples/asymmetric.rs +++ b/rs/moq-auth/examples/asymmetric.rs @@ -4,8 +4,10 @@ // and the public key verifies them. This is the recommended approach for // production: the relay only needs the public key. -// A standalone program stamping a real token, so it reads the host clock. -#![allow(clippy::disallowed_methods)] +#![expect( + clippy::disallowed_methods, + reason = "`Claims` takes `SystemTime`, so the example reads the host clock" +)] use std::time::{Duration, SystemTime}; diff --git a/rs/moq-auth/examples/basic.rs b/rs/moq-auth/examples/basic.rs index d5379a42e6b..b2f4dd5a919 100644 --- a/rs/moq-auth/examples/basic.rs +++ b/rs/moq-auth/examples/basic.rs @@ -1,7 +1,9 @@ // cargo run --example basic -// A standalone program stamping a real token, so it reads the host clock. -#![allow(clippy::disallowed_methods)] +#![expect( + clippy::disallowed_methods, + reason = "`Claims` takes `SystemTime`, so the example reads the host clock" +)] use std::time::{Duration, SystemTime}; diff --git a/rs/moq-auth/src/claims.rs b/rs/moq-auth/src/claims.rs index 9082d7bf071..2795be75e81 100644 --- a/rs/moq-auth/src/claims.rs +++ b/rs/moq-auth/src/claims.rs @@ -237,7 +237,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 a5c673d7462..96d82ee5206 100644 --- a/rs/moq-auth/src/client.rs +++ b/rs/moq-auth/src/client.rs @@ -465,7 +465,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; @@ -540,7 +544,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 12cc12eadfc..5e87e3a5dad 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('{') { @@ -699,7 +702,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 0727daebf9d..538f73f43f2 100644 --- a/rs/moq-auth/src/lease.rs +++ b/rs/moq-auth/src/lease.rs @@ -451,7 +451,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 8b58905f935..80a78e7346a 100644 --- a/rs/moq-auth/src/serve.rs +++ b/rs/moq-auth/src/serve.rs @@ -523,7 +523,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 90b0f51ca23..232f28bdfff 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 dca1d7e01c4..578e83465c8 100644 --- a/rs/moq-bench/Cargo.toml +++ b/rs/moq-bench/Cargo.toml @@ -65,3 +65,6 @@ procfs = "0.18" test-env = { path = "../test-env" } # 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 1ba2af960c0..ec1c57d0b8c 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-bench/src/connection.rs b/rs/moq-bench/src/connection.rs index ca6d0597c79..d26616ae09a 100644 --- a/rs/moq-bench/src/connection.rs +++ b/rs/moq-bench/src/connection.rs @@ -657,7 +657,11 @@ impl Drop for Gauge<'_> { } #[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::*; diff --git a/rs/moq-bench/src/host.rs b/rs/moq-bench/src/host.rs index bccc1428a43..d303b20d085 100644 --- a/rs/moq-bench/src/host.rs +++ b/rs/moq-bench/src/host.rs @@ -313,8 +313,10 @@ mod linux { ) else { return Ok(()); }; - // The sampler runs outside any runtime, so it blocks on the host clock. - #[allow(clippy::disallowed_methods)] + #[expect( + clippy::disallowed_methods, + reason = "the sampler runs outside any runtime, so it blocks on the host clock" + )] std::thread::sleep(delay); } } diff --git a/rs/moq-bench/src/stats.rs b/rs/moq-bench/src/stats.rs index b094cd313e3..ab4aba5480d 100644 --- a/rs/moq-bench/src/stats.rs +++ b/rs/moq-bench/src/stats.rs @@ -481,7 +481,11 @@ fn highest_bucket(buckets: &[u64]) -> Option { } #[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 std::sync::Arc; diff --git a/rs/moq-boy/Cargo.toml b/rs/moq-boy/Cargo.toml index 18a5ca44508..2780d571e03 100644 --- a/rs/moq-boy/Cargo.toml +++ b/rs/moq-boy/Cargo.toml @@ -44,3 +44,6 @@ usage-rs = { workspace = true, features = ["completions", "config"] } [dev-dependencies] tokio = { workspace = true, features = ["test-util"] } + +[lints] +workspace = true diff --git a/rs/moq-boy/src/input.rs b/rs/moq-boy/src/input.rs index 4099443eac5..8bcea7282e9 100644 --- a/rs/moq-boy/src/input.rs +++ b/rs/moq-boy/src/input.rs @@ -168,7 +168,7 @@ async fn handle_viewer_commands( } #[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-boy/src/main.rs b/rs/moq-boy/src/main.rs index bf19324aa5e..83b2bea4d99 100644 --- a/rs/moq-boy/src/main.rs +++ b/rs/moq-boy/src/main.rs @@ -426,8 +426,10 @@ fn run_emulator( // Wait for next frame. let now = Instant::now(); if now < next_frame { - // The emulator thread runs outside any runtime, so it blocks on the host clock. - #[allow(clippy::disallowed_methods)] + #[expect( + clippy::disallowed_methods, + reason = "the emulator thread runs outside any runtime, so it blocks on the host clock" + )] std::thread::sleep(next_frame - now); } next_frame += frame_duration; diff --git a/rs/moq-c/Cargo.toml b/rs/moq-c/Cargo.toml index 856923f3304..596320d0dfe 100644 --- a/rs/moq-c/Cargo.toml +++ b/rs/moq-c/Cargo.toml @@ -56,3 +56,6 @@ moq-video = { path = "../moq-video", features = ["openh264"] } # Runs the tests that need a variable set or unset in a child process given it. test-env = { path = "../test-env" } 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 aa7170afaa1..406bb1115bb 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. @@ -105,7 +104,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. @@ -124,7 +123,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. @@ -145,7 +144,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, split into one frame per sample. @@ -165,7 +164,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, @@ -187,7 +185,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, @@ -213,7 +210,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. @@ -265,7 +261,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, @@ -321,7 +316,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. @@ -595,7 +580,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; the default 0 is /// the midpoint. @@ -624,7 +608,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. @@ -637,7 +620,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. @@ -653,7 +635,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. @@ -666,7 +648,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. @@ -729,7 +711,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. @@ -745,7 +726,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, @@ -766,7 +746,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 @@ -823,7 +802,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 @@ -1506,7 +1480,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 0fc94c55d41..a67782172f9 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 { /// Unsigned 8-bit PCM samples, interleaved by channel. @@ -71,7 +71,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, @@ -87,7 +86,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. @@ -108,7 +106,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 { /// The moq_audio_sample_format discriminant. pub format: u32, @@ -133,7 +130,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 { /// The presentation timestamp in microseconds. pub timestamp_us: u64, diff --git a/rs/moq-c/src/error.rs b/rs/moq-c/src/error.rs index 75d7eb3d58d..c3c4342d9ad 100644 --- a/rs/moq-c/src/error.rs +++ b/rs/moq-c/src/error.rs @@ -85,7 +85,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. @@ -97,7 +97,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. @@ -156,7 +156,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/lib.rs b/rs/moq-c/src/lib.rs index 6cfc0855809..9ddd1b4b9bc 100644 --- a/rs/moq-c/src/lib.rs +++ b/rs/moq-c/src/lib.rs @@ -51,5 +51,9 @@ pub(crate) use session::*; pub(crate) use state::*; #[cfg(test)] -#[allow(clippy::disallowed_methods, clippy::disallowed_types)] +#[expect( + clippy::disallowed_methods, + clippy::disallowed_types, + reason = "tests read the host clock directly" +)] mod test; diff --git a/rs/moq-c/src/test.rs b/rs/moq-c/src/test.rs index 64aed2b4044..aabec7da78b 100644 --- a/rs/moq-c/src/test.rs +++ b/rs/moq-c/src/test.rs @@ -6022,7 +6022,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 a9fcd90232b..45cb0f437a2 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, @@ -118,7 +116,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, @@ -139,7 +136,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 @@ -170,7 +166,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 { /// The presentation timestamp in microseconds. pub timestamp_us: u64, diff --git a/rs/moq-cli/Cargo.toml b/rs/moq-cli/Cargo.toml index 6d069afeb88..36c3d0011b6 100644 --- a/rs/moq-cli/Cargo.toml +++ b/rs/moq-cli/Cargo.toml @@ -200,3 +200,6 @@ path = "../../test/interop/clients/rust/finish.rs" [[example]] name = "interop-audio" path = "../../test/interop/clients/rust/audio.rs" + +[lints] +workspace = true diff --git a/rs/moq-cli/benches/play_buffer.rs b/rs/moq-cli/benches/play_buffer.rs index 7e25af385e5..94d14ea174e 100644 --- a/rs/moq-cli/benches/play_buffer.rs +++ b/rs/moq-cli/benches/play_buffer.rs @@ -1,8 +1,15 @@ //! Encoded retention cost and peak memory, swept over delay and bitrate. //! Run with `cargo bench -p moq-cli --bench play_buffer`. -#![allow(clippy::disallowed_methods, clippy::disallowed_types)] +#![expect( + clippy::disallowed_methods, + clippy::disallowed_types, + reason = "host time measures benchmark throughput" +)] -#[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/announced.rs b/rs/moq-cli/src/announced.rs index 35deafb9a73..22f3ae353d5 100644 --- a/rs/moq-cli/src/announced.rs +++ b/rs/moq-cli/src/announced.rs @@ -168,7 +168,7 @@ impl View { } #[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::args::{Command, Invocation}; diff --git a/rs/moq-cli/src/archive.rs b/rs/moq-cli/src/archive.rs index dfc4dea8262..f7457bb4480 100644 --- a/rs/moq-cli/src/archive.rs +++ b/rs/moq-cli/src/archive.rs @@ -310,7 +310,7 @@ fn open(url: &Url) -> anyhow::Result>> { } #[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-cli/src/args.rs b/rs/moq-cli/src/args.rs index 91c928bd08c..ba021bccac2 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/main.rs b/rs/moq-cli/src/main.rs index f116e2a2e06..d95774bd53b 100644 --- a/rs/moq-cli/src/main.rs +++ b/rs/moq-cli/src/main.rs @@ -985,7 +985,7 @@ fn reject_listener_cors(cors: &crate::web::Cors, endpoint: &str) -> anyhow::Resu } #[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-cli/src/play/media.rs b/rs/moq-cli/src/play/media.rs index f20cc5c0298..d638cba7f6a 100644 --- a/rs/moq-cli/src/play/media.rs +++ b/rs/moq-cli/src/play/media.rs @@ -712,7 +712,7 @@ async fn drain(sink: impl Sink) { } #[cfg(test)] -#[allow(clippy::disallowed_methods, clippy::disallowed_types)] +#[expect(clippy::disallowed_methods, reason = "tests read the host clock directly")] mod tests { use bytes::Bytes; use hang::catalog::{AudioCodec, AudioConfig}; 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/play/timeline.rs b/rs/moq-cli/src/play/timeline.rs index 477915f4d5f..05714a00d91 100644 --- a/rs/moq-cli/src/play/timeline.rs +++ b/rs/moq-cli/src/play/timeline.rs @@ -617,7 +617,7 @@ pub(super) struct Fit { } #[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-cli/src/publish.rs b/rs/moq-cli/src/publish.rs index 9d242b19f4a..62afb3081e4 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 { @@ -787,7 +791,11 @@ impl CaptureArgs { } #[cfg(test)] -#[allow(clippy::disallowed_methods, clippy::disallowed_types)] +#[expect( + clippy::disallowed_methods, + clippy::disallowed_types, + reason = "tests read the host clock directly" +)] pub(crate) mod tests { use std::time::Duration; @@ -1037,7 +1045,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"); }; @@ -1114,7 +1128,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"); }; @@ -1224,7 +1244,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"); }; @@ -1374,7 +1400,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"); }; @@ -1432,7 +1464,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"); }; @@ -1468,7 +1506,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"); }; @@ -1492,7 +1536,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"); }; @@ -1524,7 +1574,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"); }; @@ -1577,7 +1633,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"); }; @@ -1644,7 +1706,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"); }; @@ -1673,7 +1741,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"); }; @@ -1786,7 +1860,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-cli/src/report.rs b/rs/moq-cli/src/report.rs index fdbcf7be822..97899636e2c 100644 --- a/rs/moq-cli/src/report.rs +++ b/rs/moq-cli/src/report.rs @@ -603,7 +603,7 @@ async fn read_echo( } #[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 tokio::io::{AsyncBufReadExt, BufReader}; diff --git a/rs/moq-cli/tests/integration/main.rs b/rs/moq-cli/tests/integration/main.rs index 6a0d059b216..a2c1f3790ed 100644 --- a/rs/moq-cli/tests/integration/main.rs +++ b/rs/moq-cli/tests/integration/main.rs @@ -2,7 +2,11 @@ //! //! Each `tests/*.rs` file is its own crate that links this package and its //! dependencies again, so add new integration tests here as a module. -#![allow(clippy::disallowed_methods, clippy::disallowed_types)] +#![expect( + clippy::disallowed_methods, + clippy::disallowed_types, + reason = "tests read the host clock directly" +)] mod auth_serve; mod export; 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 166b7c98914..cad8f74416a 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}; @@ -349,7 +352,7 @@ mod tests { /// On a running clock, a converted instant is the same moment on std's clock. #[test] - #[allow(clippy::disallowed_methods)] + #[expect(clippy::disallowed_methods, reason = "the test compares against std's clock")] fn std_conversion_is_exact_on_a_running_clock() { let before = std::time::Instant::now(); let now = crate::now(); 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-e2ee/tests/transport.rs b/rs/moq-e2ee/tests/transport.rs index 68665cffdc4..6de56e3699e 100644 --- a/rs/moq-e2ee/tests/transport.rs +++ b/rs/moq-e2ee/tests/transport.rs @@ -1,5 +1,5 @@ //! Grouped tracks and datagrams on moq-lite and MoQ Transport. -#![allow(clippy::disallowed_methods, clippy::disallowed_types)] +#![expect(clippy::disallowed_methods, reason = "tests read the host clock directly")] mod support; diff --git a/rs/moq-ffi/Cargo.toml b/rs/moq-ffi/Cargo.toml index c9907697636..23634c0db9a 100644 --- a/rs/moq-ffi/Cargo.toml +++ b/rs/moq-ffi/Cargo.toml @@ -106,3 +106,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 7b9bbebefd3..a0312debf53 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 160d3d60746..e3a7f685060 100644 --- a/rs/moq-ffi/src/lib.rs +++ b/rs/moq-ffi/src/lib.rs @@ -1,5 +1,8 @@ #![warn(missing_docs)] -#![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`]. //! @@ -10,7 +13,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 bf96de72da8..a603a007786 100644 --- a/rs/moq-flate/src/lib.rs +++ b/rs/moq-flate/src/lib.rs @@ -54,10 +54,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 9e64f6e744d..5814da2be5e 100644 --- a/rs/moq-gst/Cargo.toml +++ b/rs/moq-gst/Cargo.toml @@ -46,3 +46,6 @@ tokio = { workspace = true, features = ["test-util"] } [[bench]] name = "catalog" harness = false + +[lints] +workspace = true diff --git a/rs/moq-gst/src/sink/imp.rs b/rs/moq-gst/src/sink/imp.rs index 2ecda4e23c3..47fc0e9a306 100644 --- a/rs/moq-gst/src/sink/imp.rs +++ b/rs/moq-gst/src/sink/imp.rs @@ -1252,7 +1252,11 @@ fn observe_caps( } #[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 std::sync::Arc; diff --git a/rs/moq-gst/src/sink/pad.rs b/rs/moq-gst/src/sink/pad.rs index 1506a6e667c..29267acec99 100644 --- a/rs/moq-gst/src/sink/pad.rs +++ b/rs/moq-gst/src/sink/pad.rs @@ -1119,7 +1119,7 @@ pub(crate) fn h264_keyframe_au() -> Bytes { } #[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-gst/src/source/imp.rs b/rs/moq-gst/src/source/imp.rs index 12f4e265362..0650391255c 100644 --- a/rs/moq-gst/src/source/imp.rs +++ b/rs/moq-gst/src/source/imp.rs @@ -1959,7 +1959,11 @@ mod tests { } #[cfg(test)] -#[allow(clippy::disallowed_methods, clippy::disallowed_types)] +#[expect( + clippy::disallowed_methods, + clippy::disallowed_types, + reason = "tests read the host clock directly" +)] mod session_tests { use std::collections::{BTreeMap, HashSet}; use std::sync::atomic::Ordering; diff --git a/rs/moq-hls/Cargo.toml b/rs/moq-hls/Cargo.toml index a38a3a6030c..a11eb0e24b3 100644 --- a/rs/moq-hls/Cargo.toml +++ b/rs/moq-hls/Cargo.toml @@ -44,3 +44,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 ba1a164ddbf..7aa0d99ead7 100644 --- a/rs/moq-hls/src/export/mod.rs +++ b/rs/moq-hls/src/export/mod.rs @@ -28,7 +28,7 @@ //! storage. #[cfg(test)] -#[allow(clippy::disallowed_methods, clippy::disallowed_types)] +#[expect(clippy::disallowed_methods, reason = "tests read the host clock directly")] mod archive_tests; mod history; pub mod master; @@ -129,9 +129,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, @@ -200,7 +204,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; } @@ -349,7 +356,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 { @@ -362,7 +372,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; @@ -370,7 +383,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() } @@ -603,7 +619,11 @@ async fn watch( } #[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 { /// A millisecond track: the frames written here carry timestamps. fn timed() -> moq_net::track::Info { @@ -625,7 +645,10 @@ mod tests { use super::*; - #[allow(clippy::large_enum_variant)] + #[allow( + clippy::large_enum_variant, + reason = "a test fixture built once per case; only large when extra features grow the video config" + )] enum TestConfig { Video(hang::catalog::VideoConfig), Audio(hang::catalog::AudioConfig), diff --git a/rs/moq-hls/src/export/rendition.rs b/rs/moq-hls/src/export/rendition.rs index 8775f36748f..d4d1a797fbc 100644 --- a/rs/moq-hls/src/export/rendition.rs +++ b/rs/moq-hls/src/export/rendition.rs @@ -103,8 +103,10 @@ struct Run { } /// The rendition's catalog config, kept whole so a [`Muxer`] can be built per request. -// One per rendition, so the variant sizes never add up to an allocation's worth. -#[allow(clippy::large_enum_variant)] +#[allow( + clippy::large_enum_variant, + reason = "one per rendition, so the variant sizes never add up to an allocation's worth; only large when extra features grow the video config" +)] enum Config { Video(VideoConfig), Audio(AudioConfig), @@ -508,7 +510,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 } @@ -947,7 +952,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 { @@ -1031,7 +1039,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 31693476378..3b61cbb6531 100644 --- a/rs/moq-hls/src/export/renditions.rs +++ b/rs/moq-hls/src/export/renditions.rs @@ -198,7 +198,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() } @@ -484,7 +487,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 73f3642a62c..cd6dd3ec744 100644 --- a/rs/moq-hls/src/export/segments.rs +++ b/rs/moq-hls/src/export/segments.rs @@ -179,7 +179,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. @@ -206,7 +209,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, @@ -353,7 +359,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() } @@ -373,7 +382,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 @@ -398,7 +410,10 @@ 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() @@ -406,7 +421,10 @@ impl Producer { /// Poll until [`is_playable`](Self::is_playable) or the reference timeline failed, 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.failed.is_some() || !state.rows.is_empty() { diff --git a/rs/moq-hls/src/import.rs b/rs/moq-hls/src/import.rs index 56a7389389d..c98c82f988a 100644 --- a/rs/moq-hls/src/import.rs +++ b/rs/moq-hls/src/import.rs @@ -1083,7 +1083,7 @@ fn moq_sequence(discontinuity_sequence: u64, media_sequence: u64) -> Result } #[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::path::{Path, PathBuf}; diff --git a/rs/moq-hls/src/server/routes.rs b/rs/moq-hls/src/server/routes.rs index 19ac4c6e9d7..65db4df98f0 100644 --- a/rs/moq-hls/src/server/routes.rs +++ b/rs/moq-hls/src/server/routes.rs @@ -427,7 +427,11 @@ fn server_error(err: crate::Error) -> Response { } #[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::*; diff --git a/rs/moq-ice/Cargo.toml b/rs/moq-ice/Cargo.toml index 4fd94b25fcd..58956326500 100644 --- a/rs/moq-ice/Cargo.toml +++ b/rs/moq-ice/Cargo.toml @@ -22,3 +22,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 e94730a0626..4e5521ac930 100644 --- a/rs/moq-ice/src/agent.rs +++ b/rs/moq-ice/src/agent.rs @@ -62,8 +62,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 3f4a42437ec..9a9ba9092c0 100644 --- a/rs/moq-json/benches/window.rs +++ b/rs/moq-json/benches/window.rs @@ -4,7 +4,11 @@ //! frames are built outside the measured section. //! //! Run `cargo bench -p moq-json --bench window` and compare the table across revisions. -#![allow(clippy::disallowed_methods, clippy::disallowed_types)] +#![expect( + clippy::disallowed_methods, + clippy::disallowed_types, + reason = "host time measures benchmark throughput" +)] use std::alloc::{GlobalAlloc, Layout, System}; use std::hint::black_box; @@ -50,7 +54,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, @@ -60,7 +64,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 fbc9d179b4f..a6fd497526e 100644 --- a/rs/moq-json/src/snapshot/decoder.rs +++ b/rs/moq-json/src/snapshot/decoder.rs @@ -415,12 +415,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 00e3b2fa8d0..be769971266 100644 --- a/rs/moq-json/src/snapshot/mod.rs +++ b/rs/moq-json/src/snapshot/mod.rs @@ -1255,12 +1255,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 ac2f09511c8..667768b6edd 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/jitter.rs b/rs/moq-mux/benches/jitter.rs index f2b69d46272..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 diff --git a/rs/moq-mux/benches/ts_schedule.rs b/rs/moq-mux/benches/ts_schedule.rs index 565ebd33eed..132cf0b8619 100644 --- a/rs/moq-mux/benches/ts_schedule.rs +++ b/rs/moq-mux/benches/ts_schedule.rs @@ -11,10 +11,16 @@ mod export { use std::time::Duration; } #[path = "../src/container/ts/lane.rs"] -#[allow(dead_code)] +#[expect( + dead_code, + reason = "the bench compiles the private module from source and uses only part of it" +)] mod lane; #[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 db428a26401..a21ca7b35e2 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/fmp4/export.rs b/rs/moq-mux/src/container/fmp4/export.rs index 0279346be1c..27a4b6b7144 100644 --- a/rs/moq-mux/src/container/fmp4/export.rs +++ b/rs/moq-mux/src/container/fmp4/export.rs @@ -153,8 +153,10 @@ pub struct Fragment { } /// A rendition's latest catalog entry. -// One per rendition, so the variant sizes never add up to an allocation's worth. -#[allow(clippy::large_enum_variant)] +#[allow( + clippy::large_enum_variant, + reason = "one per rendition, so the variant sizes never add up to an allocation's worth; only large when extra features grow the video config" +)] enum Rendition { Video(VideoConfig), Audio(AudioConfig), diff --git a/rs/moq-mux/src/container/fmp4/muxer.rs b/rs/moq-mux/src/container/fmp4/muxer.rs index 1251cdea6d8..e107c9c0aab 100644 --- a/rs/moq-mux/src/container/fmp4/muxer.rs +++ b/rs/moq-mux/src/container/fmp4/muxer.rs @@ -21,8 +21,10 @@ use super::{Error, Fragmenter, fragment, synthesize_audio_trak, synthesize_video const TRACK_ID: u32 = 1; /// Whether the muxer serves a video or an audio rendition, with its catalog config. -// One per muxer, so the variant sizes never add up to an allocation's worth. -#[allow(clippy::large_enum_variant)] +#[allow( + clippy::large_enum_variant, + reason = "one per muxer, so the variant sizes never add up to an allocation's worth; only large when extra features grow the video config" +)] enum Kind { Video(VideoConfig), Audio(AudioConfig), diff --git a/rs/moq-mux/src/container/ts/import.rs b/rs/moq-mux/src/container/ts/import.rs index 1308354e8ac..595f3d990e5 100644 --- a/rs/moq-mux/src/container/ts/import.rs +++ b/rs/moq-mux/src/container/ts/import.rs @@ -8302,7 +8302,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 e76649e1859..d23d7cff67c 100644 --- a/rs/moq-mux/src/lib.rs +++ b/rs/moq-mux/src/lib.rs @@ -1,5 +1,8 @@ #![warn(missing_docs)] -#![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 4b4721195eb..f87dd494636 100644 --- a/rs/moq-mux/src/timeline.rs +++ b/rs/moq-mux/src/timeline.rs @@ -598,9 +598,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, @@ -644,7 +641,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 3be1efaaaae..0d298174b73 100644 --- a/rs/moq-net/Cargo.toml +++ b/rs/moq-net/Cargo.toml @@ -72,9 +72,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]] @@ -204,3 +201,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/group.rs b/rs/moq-net/benches/group.rs index a8208ace8a2..47968f7bf55 100644 --- a/rs/moq-net/benches/group.rs +++ b/rs/moq-net/benches/group.rs @@ -14,8 +14,10 @@ //! //! Run with `cargo bench -p moq-net`. -// `iter_custom` timings measure the host clock on purpose. -#![allow(clippy::disallowed_methods)] +#![expect( + clippy::disallowed_methods, + reason = "`iter_custom` timings measure the host clock on purpose" +)] use std::{ hint::black_box, 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 1c7e0a4669c..815701a21ea 100644 --- a/rs/moq-net/benches/origin.rs +++ b/rs/moq-net/benches/origin.rs @@ -28,8 +28,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 176f356bd3b..464b07a1138 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 d049f4729f6..d52c73f6e29 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 c8baa670ceb..f450b0975f1 100644 --- a/rs/moq-net/benches/session.rs +++ b/rs/moq-net/benches/session.rs @@ -47,8 +47,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 ea21b5d851f..c06140385a7 100644 --- a/rs/moq-net/benches/track.rs +++ b/rs/moq-net/benches/track.rs @@ -75,8 +75,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 3433e0b642e..df59399d116 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(_) @@ -108,7 +108,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| { @@ -142,7 +142,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, @@ -159,7 +159,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. @@ -172,17 +172,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, @@ -197,10 +197,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, } @@ -236,7 +236,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. @@ -253,7 +253,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 { @@ -263,7 +263,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)) @@ -274,7 +274,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, @@ -282,7 +282,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) } @@ -294,14 +294,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, @@ -322,7 +322,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 { @@ -334,7 +334,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 { @@ -347,7 +347,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 } @@ -378,7 +378,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 { @@ -417,7 +417,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; @@ -471,7 +471,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 }; @@ -490,7 +490,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 { @@ -504,7 +504,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() { @@ -531,7 +531,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, @@ -541,7 +541,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. @@ -564,7 +564,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) { @@ -574,7 +574,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 { @@ -594,7 +594,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()) { @@ -606,7 +606,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); @@ -668,7 +668,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; @@ -677,7 +677,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; @@ -685,14 +685,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(()), @@ -703,7 +703,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) } @@ -714,7 +714,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); @@ -723,7 +723,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); @@ -732,7 +732,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); @@ -743,7 +743,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; @@ -763,7 +763,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() { @@ -838,7 +838,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) { @@ -1023,7 +1023,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. @@ -1067,9 +1067,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 }, } @@ -1122,7 +1122,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, @@ -1130,7 +1130,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(); @@ -1148,7 +1148,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); @@ -1178,7 +1178,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, @@ -1244,7 +1244,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, @@ -1257,7 +1257,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), @@ -1279,7 +1279,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, @@ -1301,7 +1301,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)] @@ -1386,10 +1386,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, @@ -1404,7 +1404,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 @@ -1546,7 +1546,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, @@ -1563,13 +1563,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(_))) @@ -1627,7 +1627,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, @@ -1641,7 +1641,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, @@ -1667,7 +1667,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, @@ -1678,7 +1678,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 { @@ -1694,7 +1694,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 @@ -1702,7 +1702,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, @@ -1716,7 +1716,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) @@ -1728,31 +1728,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(()); @@ -1794,7 +1794,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(); @@ -1816,7 +1816,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, @@ -1827,7 +1827,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 { @@ -1840,7 +1840,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; @@ -1859,7 +1859,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}") } @@ -1874,7 +1874,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, @@ -1889,7 +1889,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 2a8443c2851..2d050ee3b72 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, @@ -150,7 +150,7 @@ 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, @@ -165,7 +165,7 @@ impl<'a> Decoder<'a> { /// After a [`DecodeError::Short`], how many bytes from the start the failed read /// needed: at least one more than the buffer when it can't tell, and 0 if no read of /// this decoder ran short. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn need(&self) -> usize { self.need } @@ -178,7 +178,7 @@ impl<'a> Decoder<'a> { } /// 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 } @@ -190,19 +190,19 @@ impl<'a> Decoder<'a> { } /// 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(self.short(len)); @@ -212,32 +212,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), @@ -249,7 +249,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 { match varint::read(self.buf, self.form) { Ok((value, rest)) => { @@ -263,13 +263,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)?; @@ -277,7 +277,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 90cb6a590a1..b84d437e2ba 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>; @@ -73,7 +73,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 } @@ -84,19 +84,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); } @@ -109,7 +109,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)?, @@ -119,7 +119,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); @@ -127,7 +127,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()) } @@ -135,7 +135,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 { @@ -145,7 +145,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 { @@ -155,13 +155,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, @@ -171,7 +171,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(); @@ -206,7 +206,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, @@ -214,7 +214,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 2c752971a7f..8ca7c1a2d70 100644 --- a/rs/moq-net/src/fuzz.rs +++ b/rs/moq-net/src/fuzz.rs @@ -305,7 +305,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 55a22ce3221..2f9778c51cf 100644 --- a/rs/moq-net/src/goaway.rs +++ b/rs/moq-net/src/goaway.rs @@ -181,7 +181,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, @@ -189,13 +189,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) } @@ -205,7 +205,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 @@ -240,7 +240,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>, @@ -259,7 +259,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); @@ -274,7 +274,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()), @@ -293,7 +293,7 @@ impl Protocol { /// send wakes. The queue's instant at the send itself is the driver's last poll, /// as stale as the session has been idle, so arming from it would cut the peer's /// window short. -#[cfg_attr(not(feature = "async"), allow(dead_code))] +#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) struct Deadline { runtime: crate::time::Deadlines, trigger: Option>>, @@ -302,7 +302,7 @@ pub(crate) struct Deadline { impl Deadline { /// Ready with the timeout once it expires, or without one if nothing is to enforce. - #[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> { if let Some(trigger) = &self.trigger { let timeout = match std::task::ready!(trigger.poll(waiter, |state| match &**state { @@ -324,7 +324,7 @@ impl Deadline { } /// 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>, @@ -338,7 +338,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); @@ -367,7 +367,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(), @@ -376,7 +376,7 @@ impl Handle { } /// Watch the local deadline on the driver's `runtime` without holding up the protocol's writes. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn deadline(&self, runtime: &crate::time::Deadlines) -> Deadline { Deadline { runtime: runtime.clone(), @@ -386,7 +386,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/adapter.rs b/rs/moq-net/src/ietf/adapter.rs index bbab81b152e..1aa8e76df05 100644 --- a/rs/moq-net/src/ietf/adapter.rs +++ b/rs/moq-net/src/ietf/adapter.rs @@ -503,7 +503,13 @@ impl crate::transport::poll::SendStream for } } -#[allow(clippy::large_enum_variant)] +#[cfg_attr( + target_pointer_width = "64", + expect( + clippy::large_enum_variant, + reason = "one per stream, so boxing a variant would add an allocation per stream to save bytes nothing holds in bulk" + ) +)] pub enum AdapterRecv { Real(S::RecvStream), Virtual(crate::transport::poll::Buffered), diff --git a/rs/moq-net/src/ietf/auth.rs b/rs/moq-net/src/ietf/auth.rs index 1ef662f10a5..93cd1f14607 100644 --- a/rs/moq-net/src/ietf/auth.rs +++ b/rs/moq-net/src/ietf/auth.rs @@ -253,7 +253,10 @@ pub(super) fn peer_grant( /// says it negotiated the extension. Never returns: a session without it just fails /// the tokens as unsupported. #[cfg(feature = "async")] -#[allow(clippy::too_many_arguments)] +#[expect( + clippy::too_many_arguments, + reason = "the presenting task owns each piece of session state it drives" +)] pub(super) async fn run_present( runtime: crate::time::Deadlines, session: S, diff --git a/rs/moq-net/src/ietf/mod.rs b/rs/moq-net/src/ietf/mod.rs index 993e83b075f..0cd1c5ca53a 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 b0301456d83..33adb807efc 100644 --- a/rs/moq-net/src/ietf/parameters.rs +++ b/rs/moq-net/src/ietf/parameters.rs @@ -503,7 +503,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; @@ -515,14 +515,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) { @@ -564,7 +564,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; @@ -575,7 +575,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; @@ -584,7 +584,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()?; @@ -617,7 +617,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 904e11179e1..f006c14391d 100644 --- a/rs/moq-net/src/ietf/publisher.rs +++ b/rs/moq-net/src/ietf/publisher.rs @@ -98,8 +98,13 @@ fn rendezvous_error(error: Error, requested: bool, resolved: bool) -> Error { if requested && missing { Error::Timeout } else { error } } -// Returned from one poll and matched at once, so its size never sits in a task. -#[allow(clippy::large_enum_variant)] +#[cfg_attr( + target_pointer_width = "64", + expect( + clippy::large_enum_variant, + reason = "returned from one poll and matched at once, so its size never sits in a task" + ) +)] enum FillStep { Batch, Partial(frame::Consumer), @@ -5162,9 +5167,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/publisher/tracks.rs b/rs/moq-net/src/ietf/publisher/tracks.rs index 1401014785a..af77c1be166 100644 --- a/rs/moq-net/src/ietf/publisher/tracks.rs +++ b/rs/moq-net/src/ietf/publisher/tracks.rs @@ -1033,7 +1033,10 @@ where /// with them would be served, until it pauses again or ends. Answers the resuming update /// with where the subscription now joins, when `answer` says one asked. `Err(())` when the /// subscriber cancelled. - #[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 resume_publish( &self, stream: &mut Stream, diff --git a/rs/moq-net/src/ietf/session.rs b/rs/moq-net/src/ietf/session.rs index 8e99324e2a1..28ddcf64e96 100644 --- a/rs/moq-net/src/ietf/session.rs +++ b/rs/moq-net/src/ietf/session.rs @@ -800,7 +800,10 @@ fn peer_from_params(params: &ietf::Parameters, version: Version) -> Result( mut session: S, version: Version, diff --git a/rs/moq-net/src/ietf/subscriber.rs b/rs/moq-net/src/ietf/subscriber.rs index 62031a0342b..0bf925e1e88 100644 --- a/rs/moq-net/src/ietf/subscriber.rs +++ b/rs/moq-net/src/ietf/subscriber.rs @@ -865,7 +865,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, @@ -1299,7 +1302,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, 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/ledger.rs b/rs/moq-net/src/ledger.rs index 7c71fde293e..8229c9d8df0 100644 --- a/rs/moq-net/src/ledger.rs +++ b/rs/moq-net/src/ledger.rs @@ -166,7 +166,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/lib.rs b/rs/moq-net/src/lib.rs index 61865593607..47924dd0418 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 @@ -77,10 +75,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 6be258bd2ec..04b514cf239 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 dafbe367716..adf132437f6 100644 --- a/rs/moq-net/src/lite/publisher.rs +++ b/rs/moq-net/src/lite/publisher.rs @@ -292,9 +292,10 @@ 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)] +#[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 ControlState { /// Reading the stream's type. Start { @@ -844,9 +845,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, @@ -2218,9 +2220,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)] +#[allow( + 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; an allow, since the size gap varies by target" +)] enum FetchServe { /// Waiting for the fetched group. Fetch { @@ -3421,10 +3424,6 @@ 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)] enum Recv { Group(group::Consumer), Datagram(crate::model::datagram::Stored), @@ -4297,9 +4296,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 ec758f7286c..0d9758df523 100644 --- a/rs/moq-net/src/lite/subscriber.rs +++ b/rs/moq-net/src/lite/subscriber.rs @@ -268,7 +268,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, @@ -784,9 +787,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 { @@ -940,9 +944,10 @@ impl Drop for SetupWait { } } -// 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, @@ -1423,9 +1428,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 @@ -2597,7 +2603,7 @@ mod tests { } let (track, _callers, tail, sub, scan, fetches) = &mut fixtures[0]; moq_clock::sim::yield_now().await; - #[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); @@ -5906,9 +5912,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), @@ -6482,9 +6492,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. @@ -6635,9 +6646,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 @@ -6990,9 +7002,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/lite/version.rs b/rs/moq-net/src/lite/version.rs index df4d9307b0a..5694bbab7cf 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,115 +45,78 @@ 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 either endpoint may open a Padding Stream (0x2). Added in lite-07. - #[allow(clippy::match_like_matches_macro)] pub(crate) fn has_padding(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 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 @@ -178,35 +141,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 @@ -229,163 +186,137 @@ 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 TRACK_INFO carries the compression flag, and a compressed Track's FRAME /// and datagram its inflated size. Added in lite-07; an earlier peer receives the /// frames inflated. - #[allow(clippy::match_like_matches_macro)] pub(crate) fn has_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 SUBSCRIBE_DROP's Error Code is a stream error code, ending a dropped group's /// reader as a reset keeping its header would. Added in lite-07; earlier versions carry /// an application-specific code there. - #[allow(clippy::match_like_matches_macro)] #[cfg(feature = "async")] pub(crate) fn has_drop_code(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 received frame timestamps are the publisher's media time. Lite05/06 stamp an /// untimed track's payloads with their send time, which a receiver cannot tell from it, /// so it drops every timestamp received on them and the track arrives untimed. - #[allow(clippy::match_like_matches_macro)] pub(crate) fn has_media_time(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 diff --git a/rs/moq-net/src/model/bandwidth.rs b/rs/moq-net/src/model/bandwidth.rs index aec786c6174..df3d781ec5b 100644 --- a/rs/moq-net/src/model/bandwidth.rs +++ b/rs/moq-net/src/model/bandwidth.rs @@ -109,7 +109,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()) } @@ -176,12 +176,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 f4b0af63950..06af68791cf 100644 --- a/rs/moq-net/src/model/broadcast.rs +++ b/rs/moq-net/src/model/broadcast.rs @@ -719,7 +719,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] @@ -731,13 +731,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 @@ -747,7 +747,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 { @@ -756,7 +756,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 { @@ -774,7 +774,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, @@ -791,12 +791,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) } @@ -959,7 +959,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)) @@ -1313,7 +1313,7 @@ impl Consumer { } #[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/datagram.rs b/rs/moq-net/src/model/datagram.rs index 75fbee36e10..7f1637b94f2 100644 --- a/rs/moq-net/src/model/datagram.rs +++ b/rs/moq-net/src/model/datagram.rs @@ -66,7 +66,7 @@ pub(crate) struct Stored { impl Stored { /// The payload a session sends, with its inflated size when that is the DEFLATE slice: /// only a session that carries `compression` takes a compressed track's stored form. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub fn sent(&self, compression: bool) -> (&Bytes, Option) { match &self.deflated { Some(deflated) if compression => (deflated, Some(self.datagram.payload.len() as u64)), diff --git a/rs/moq-net/src/model/frame.rs b/rs/moq-net/src/model/frame.rs index 6bdfdfd9dff..c93bc1dbf96 100644 --- a/rs/moq-net/src/model/frame.rs +++ b/rs/moq-net/src/model/frame.rs @@ -530,7 +530,7 @@ impl Producer { } /// 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 // A dropped receive handler cannot name its error; a public driver aborts explicitly. pub(crate) fn cancel_on_drop(mut self) -> Self { @@ -565,7 +565,7 @@ impl Producer { /// 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_deferred(&mut self, chunk: B) -> Result<()> { let len = chunk.as_ref().len(); @@ -592,7 +592,7 @@ impl Producer { } /// 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.group().frame_notify(); @@ -704,12 +704,12 @@ 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>, /// The inflated size of a compressed frame read in its stored form (see /// [`group::Consumer::compressed`]), whose payload is then the DEFLATE slice. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // private: passthrough pub(crate) inflated: Option, source: Source, diff --git a/rs/moq-net/src/model/group.rs b/rs/moq-net/src/model/group.rs index 953d2b3016b..1d59be2aef0 100644 --- a/rs/moq-net/src/model/group.rs +++ b/rs/moq-net/src/model/group.rs @@ -501,7 +501,7 @@ enum Source { } /// 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 { @@ -1153,7 +1153,7 @@ impl Producer { /// Whether the parent track compresses, so a received frame arrives as a stored slice /// with its inflated size ([`frame::Header::inflated`]). - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // private: passthrough pub(crate) fn compressed(&self) -> bool { self.handle.track.compress @@ -1403,7 +1403,7 @@ impl Producer { } /// [`Self::create_frame`] with the moq-transport object fields a relay forwards. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // private: passthrough pub(crate) fn create_object(mut self, frame: frame::Header) -> Result { let meter = self.chunk_meter(frame.inflated); @@ -1672,8 +1672,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) @@ -1708,8 +1710,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) @@ -1843,7 +1847,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() { @@ -1959,7 +1963,7 @@ 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) } @@ -2164,7 +2168,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(|_| ()) @@ -2805,7 +2809,7 @@ impl Consumer { /// The timescale a moq-lite hop serves the parent track at (see /// [`track::Info::lite_timescale`]). - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // private: passthrough pub(crate) fn lite_timescale(&self, ietf: bool) -> Option { self.track.lite_timescale(ietf) diff --git a/rs/moq-net/src/model/listing.rs b/rs/moq-net/src/model/listing.rs index 35ff4c7384a..e3824238eb4 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 128800ae229..e1e2f926920 100644 --- a/rs/moq-net/src/model/origin.rs +++ b/rs/moq-net/src/model/origin.rs @@ -79,7 +79,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 { @@ -387,12 +387,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; @@ -630,7 +630,10 @@ fn fnv_key(name: &str, origins: impl IntoIterator) -> u64 { /// it, so convergence does not need the hash, and a restarted publisher announces /// under a new first hop, so a hash would keep its dead session winning half the /// time until the transport times out. -#[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, @@ -717,7 +720,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, } @@ -751,7 +754,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(); @@ -1711,7 +1714,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(), @@ -1968,7 +1971,7 @@ impl Producer { /// Give this handle a frame budget of its own, so what one session allocates up front /// never crowds out another's. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // private: tuning pub(crate) fn with_own_frames(mut self) -> Self { self.frames = Default::default(); @@ -1976,7 +1979,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 @@ -2050,7 +2053,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 @@ -2181,7 +2184,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(); @@ -2222,7 +2225,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(); @@ -2232,7 +2235,7 @@ impl Producer { /// Hear what this handle's session should ask its peer about: the broadest /// prefixes readers of the origin want discovered, mapped onto this handle's /// scope, starting with the current ones. - #[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 interests(&self) -> Interests { let queue = kio::Queue::new(); @@ -2272,7 +2275,7 @@ impl Producer { /// Whether routes arrive here on a link between relays ([`Self::peer`] or /// [`Self::upstream`]), whose sessions discover everything they may. - #[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 relays(&self) -> bool { self.link != Link::Local @@ -4036,7 +4039,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), } @@ -4103,7 +4106,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>, @@ -4113,7 +4116,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() @@ -4125,7 +4128,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), @@ -4205,7 +4208,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 { @@ -4301,7 +4304,7 @@ pub(crate) struct Interests { impl Interests { /// The next change, or `None` once the origin 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/answer.md pub(crate) fn poll_next(&self, waiter: &kio::Waiter) -> Poll> { Poll::Ready(ready!(self.queue.poll_pop(waiter)).ok()) @@ -5324,7 +5327,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(); @@ -5388,7 +5391,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); @@ -6012,7 +6015,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); @@ -6032,7 +6035,7 @@ impl Consumer { /// A clone for a session serving its peer: its reads are the peer's, not a /// local reader's, so they never make a session ask its own peer about them. - #[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 serving(mut self) -> Self { self.interested = false; @@ -6050,7 +6053,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( @@ -6065,7 +6068,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; @@ -6074,14 +6077,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 @@ -6109,7 +6112,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 { @@ -7017,7 +7020,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 d1633035ec7..29f8853fdd8 100644 --- a/rs/moq-net/src/model/resume.rs +++ b/rs/moq-net/src/model/resume.rs @@ -649,7 +649,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)); @@ -671,7 +671,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<(std::ops::Range, StreamError)> { let mut reader = self.reader(); let sub = ready!(reader.poll_serving(waiter)); @@ -688,7 +688,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) } @@ -707,7 +707,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() } @@ -746,7 +746,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)); @@ -1536,7 +1536,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); @@ -1573,7 +1573,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; @@ -1594,7 +1594,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/time.rs b/rs/moq-net/src/model/time.rs index 86f49c0290b..a91d5955e3e 100644 --- a/rs/moq-net/src/model/time.rs +++ b/rs/moq-net/src/model/time.rs @@ -332,16 +332,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) diff --git a/rs/moq-net/src/model/track.rs b/rs/moq-net/src/model/track.rs index d45ab47a735..490db2d819d 100644 --- a/rs/moq-net/src/model/track.rs +++ b/rs/moq-net/src/model/track.rs @@ -166,7 +166,7 @@ pub struct Info { /// /// Relay-only: moq-lite carries them only between relays, with the `ietf` extension. /// 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>, } @@ -221,7 +221,7 @@ impl Info { /// The timescale served on a moq-lite hop, preserving moq-transport timestamps only /// when the hop negotiated the `ietf` extension. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // private: passthrough pub(crate) fn lite_timescale(&self, ietf: bool) -> Option { self.timescale.filter(|_| self.ietf().is_none() || ietf) @@ -295,11 +295,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 }, } @@ -466,7 +466,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 @@ -2307,7 +2307,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 @@ -2340,7 +2340,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, start: Option) { if self.feed != Feed::Idle { return; @@ -2370,14 +2370,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 @@ -2389,7 +2389,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, @@ -2423,7 +2423,7 @@ impl TrackState { } /// Abort shared track state without extending its publisher lifetime. - #[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 abort(producer: &kio::Producer, err: Error) -> Result<()> { commit_abort(Self::modify(producer)?, err).abort(); @@ -2852,7 +2852,7 @@ impl Producer { /// Insert a received datagram of a compressed track, whose payload is its own DEFLATE /// stream that must inflate to exactly `size` bytes. Kept as it arrived, beside the /// inflated payload. - #[cfg_attr(not(feature = "async"), allow(dead_code))] + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] // private: passthrough pub(crate) fn insert_deflated_datagram(&mut self, mut datagram: super::datagram::Stored, size: u64) -> Result<()> { if !self.info.compress { @@ -3040,7 +3040,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() { @@ -3051,7 +3051,7 @@ impl Producer { /// The route answered with its largest position, `None` for nothing yet, and the first /// group its feed serves when the answer names it; see [`Self::set_idle`]. Readers /// resume once the cache shows the largest 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, start: Option) { if let Ok(mut state) = self.modify() { @@ -3061,14 +3061,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 @@ -3076,7 +3076,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(); @@ -3085,7 +3085,7 @@ impl Producer { /// [`Request::request_start`] for a copy already accepted, which a held copy's next /// subscription asks for again. - #[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 request_start(&mut self, sequence: Option) -> Result<()> { self.modify()?.set_start(sequence, true); @@ -3182,7 +3182,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 @@ -3196,7 +3196,7 @@ impl Producer { /// Ready once the track holds content past `sequence`, or is closed: a later group whose /// first frame opened or that finished, or a later datagram. A frameless group header /// does not count, since nothing says the copy reached it yet. - #[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 Some(next) = sequence.checked_add(1) else { @@ -4020,7 +4020,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. @@ -4050,7 +4050,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. @@ -4236,7 +4236,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, @@ -4251,7 +4251,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() { @@ -4264,7 +4264,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() { @@ -4286,7 +4286,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() { @@ -4304,7 +4304,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() })) @@ -4468,7 +4468,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(); @@ -4482,7 +4482,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() { @@ -4661,7 +4661,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() { @@ -4892,7 +4892,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) @@ -5232,7 +5232,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, ), } @@ -5539,21 +5539,21 @@ 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, with why: stale skips, cuts, and upstream /// drops. pending: RangeMap, /// 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. @@ -5711,7 +5711,7 @@ impl 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<(ops::Range, StreamError)> { self.sync(); let within = Within { @@ -6765,7 +6765,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 { @@ -6831,7 +6831,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<(ops::Range, StreamError)> { match &mut self.inner { @@ -6843,7 +6843,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 { @@ -6902,7 +6902,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 { @@ -7049,7 +7049,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; @@ -7062,7 +7062,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 { @@ -7073,7 +7073,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 { @@ -7382,7 +7382,7 @@ impl Request { /// Accept the track idle, as a copy that no live feed fills yet: readers get nothing /// from it until the feed goes live. Applied atomically with [`Self::accept`]. - #[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(mut self) -> Self { self.idle = true; @@ -7447,7 +7447,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() { @@ -7563,7 +7563,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 0b0f565379c..7b74707f8f0 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 97ca1f1317e..ade3d99e35f 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) @@ -119,7 +119,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, @@ -130,7 +130,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, @@ -149,7 +149,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, @@ -159,7 +159,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 => { @@ -214,7 +214,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, @@ -231,7 +231,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()), @@ -241,7 +241,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); @@ -252,7 +252,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, @@ -262,7 +262,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 1f8d048b79e..09ab8df7f93 100644 --- a/rs/moq-net/src/stats.rs +++ b/rs/moq-net/src/stats.rs @@ -1612,9 +1612,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, } @@ -1767,7 +1767,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); @@ -1778,7 +1778,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 20aea505200..d7634a56d64 100644 --- a/rs/moq-net/src/util.rs +++ b/rs/moq-net/src/util.rs @@ -99,7 +99,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 { @@ -190,7 +190,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 c46b388f920..3b638acaa03 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 2d64028b74f..1f3f505eb50 100644 --- a/rs/moq-net/tests/integration/support/mock.rs +++ b/rs/moq-net/tests/integration/support/mock.rs @@ -642,8 +642,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 0c3a8a7f83c..d5079a17d8f 100644 --- a/rs/moq-quic/Cargo.toml +++ b/rs/moq-quic/Cargo.toml @@ -133,7 +133,8 @@ name = "wire" harness = false required-features = ["fuzz"] -# quinn's workspace lints, kept so upstream code stays clean against them. +# quinn's workspace lints, kept so upstream code stays clean against them. Cargo +# can't extend the workspace table per crate, so its suppression rule is repeated. [lints.rust] elided_lifetimes_in_paths = "warn" unnameable_types = "warn" @@ -141,6 +142,7 @@ unreachable_pub = "warn" unused_qualifications = "warn" [lints.clippy] +allow_attributes_without_reason = "warn" manual_let_else = "warn" or_fun_call = "warn" use_self = "warn" diff --git a/rs/moq-quic/benches/common/mod.rs b/rs/moq-quic/benches/common/mod.rs index 85f72bc6ead..0ec0eacacdf 100644 --- a/rs/moq-quic/benches/common/mod.rs +++ b/rs/moq-quic/benches/common/mod.rs @@ -233,8 +233,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 7dfbc686f11..f60e5dfbaab 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 d47c008639b..bb0f7bacf5e 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 99b4f3e357e..e21b7202104 100644 --- a/rs/moq-quic/benches/streams.rs +++ b/rs/moq-quic/benches/streams.rs @@ -8,7 +8,10 @@ use criterion::{BatchSize, 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/bloom_token_log.rs b/rs/moq-quic/src/bloom_token_log.rs index 9150faa4c51..a02110397e6 100644 --- a/rs/moq-quic/src/bloom_token_log.rs +++ b/rs/moq-quic/src/bloom_token_log.rs @@ -253,7 +253,10 @@ const DEFAULT_MAX_BYTES: usize = 10 << 20; const DEFAULT_EXPECTED_HITS: u64 = 1_000_000; #[cfg(test)] -#[allow(clippy::disallowed_methods, clippy::disallowed_types)] +#[expect( + clippy::disallowed_methods, + reason = "tests read the host clock directly" +)] mod test { use super::*; use rand::prelude::*; diff --git a/rs/moq-quic/src/config/mod.rs b/rs/moq-quic/src/config/mod.rs index 0409b2ffeb0..0698325f9fe 100644 --- a/rs/moq-quic/src/config/mod.rs +++ b/rs/moq-quic/src/config/mod.rs @@ -538,7 +538,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 7e872dd77cd..ebdaf6053a4 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 5e79d64f60b..573ba98dff4 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 85bed8692df..166628bb9a3 100644 --- a/rs/moq-quic/src/connection/streams/mod.rs +++ b/rs/moq-quic/src/connection/streams/mod.rs @@ -36,7 +36,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"))] @@ -230,7 +229,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/connection/streams/state.rs b/rs/moq-quic/src/connection/streams/state.rs index 17d53f5281a..1e67cde89a9 100644 --- a/rs/moq-quic/src/connection/streams/state.rs +++ b/rs/moq-quic/src/connection/streams/state.rs @@ -1266,7 +1266,11 @@ pub(super) fn get_or_insert_recv(opt: &mut Option, initial_max_data: } #[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 crate::{ 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 4b2c55ca98b..165d2e9c8ed 100644 --- a/rs/moq-quic/src/lib.rs +++ b/rs/moq-quic/src/lib.rs @@ -13,12 +13,10 @@ //! 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") +)] use std::{ fmt, @@ -40,7 +38,10 @@ mod entropy; pub mod fuzz; mod range_set; #[cfg(all(test, any(feature = "rustls-aws-lc-rs", feature = "rustls-ring")))] -#[allow(clippy::disallowed_methods, clippy::disallowed_types)] +#[expect( + clippy::disallowed_methods, + reason = "tests read the host clock directly" +)] mod tests; pub mod transport_parameters; mod varint; 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 bda7d2fd838..37a45caa6c3 100644 --- a/rs/moq-relay/Cargo.toml +++ b/rs/moq-relay/Cargo.toml @@ -142,3 +142,6 @@ harness = false [[bench]] name = "http_auth" harness = false + +[lints] +workspace = true diff --git a/rs/moq-relay/benches/auth.rs b/rs/moq-relay/benches/auth.rs index adb43093382..10de51d7652 100644 --- a/rs/moq-relay/benches/auth.rs +++ b/rs/moq-relay/benches/auth.rs @@ -1,7 +1,7 @@ //! Revalidate one token while sweeping unrelated sessions and held credentials, and //! cycle one verification slot while sweeping the waiting tokens and the slot count. //! The real relay/controller runs over loopback TCP; timings include one AUTH round trip. -#![allow(clippy::disallowed_methods, clippy::disallowed_types)] +#![expect(clippy::disallowed_methods, reason = "host time measures benchmark throughput")] use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main}; use moq_auth::{Grant, lease}; diff --git a/rs/moq-relay/benches/http_auth.rs b/rs/moq-relay/benches/http_auth.rs index 68b82da30e4..cc3c4429086 100644 --- a/rs/moq-relay/benches/http_auth.rs +++ b/rs/moq-relay/benches/http_auth.rs @@ -2,7 +2,7 @@ //! holds waiting on the decider. A slope means admitting one request costs more as others //! wait, rather than what the request itself touches. //! The real web listener runs over loopback TCP; timings include one request round trip. -#![allow(clippy::disallowed_methods, clippy::disallowed_types)] +#![expect(clippy::disallowed_methods, reason = "host time measures benchmark throughput")] use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main}; use moq_auth::{Grant, lease}; diff --git a/rs/moq-relay/src/acme.rs b/rs/moq-relay/src/acme.rs index 46a4be65aab..e8de655797a 100644 --- a/rs/moq-relay/src/acme.rs +++ b/rs/moq-relay/src/acme.rs @@ -467,5 +467,9 @@ impl rustls_acme::AccountCache for Cache { } #[cfg(all(test, unix))] -#[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-relay/src/auth.rs b/rs/moq-relay/src/auth.rs index 81b7e1eb25f..b974ff92ab2 100644 --- a/rs/moq-relay/src/auth.rs +++ b/rs/moq-relay/src/auth.rs @@ -1119,7 +1119,7 @@ pub(crate) fn peer(identity: &moq_tokio::tls::PeerIdentity) -> Option, token: &str) -> String { } #[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 futures::FutureExt; diff --git a/rs/moq-relay/src/cluster.rs b/rs/moq-relay/src/cluster.rs index a67cf48f4e9..2f82c2a5cdc 100644 --- a/rs/moq-relay/src/cluster.rs +++ b/rs/moq-relay/src/cluster.rs @@ -2331,7 +2331,7 @@ fn remote_status( } #[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::Config as RelayConfig; @@ -3001,7 +3001,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 e9c44913af2..7e4265abf19 100644 --- a/rs/moq-relay/src/connection.rs +++ b/rs/moq-relay/src/connection.rs @@ -507,7 +507,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 2761d7c70e0..6b6fe853b51 100644 --- a/rs/moq-relay/src/incoming.rs +++ b/rs/moq-relay/src/incoming.rs @@ -32,7 +32,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/internal.rs b/rs/moq-relay/src/internal.rs index d61ec6ffb6e..ed8c9fdc9c8 100644 --- a/rs/moq-relay/src/internal.rs +++ b/rs/moq-relay/src/internal.rs @@ -864,7 +864,7 @@ fn render_uring(out: &mut String, workers: &[UringWorker]) { fn render_uring(_out: &mut String, _workers: &[UringWorker]) {} #[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-relay/src/listener/idle.rs b/rs/moq-relay/src/listener/idle.rs index 7f673d80f78..49483094657 100644 --- a/rs/moq-relay/src/listener/idle.rs +++ b/rs/moq-relay/src/listener/idle.rs @@ -229,7 +229,10 @@ impl AsyncWrite for Io { unused_imports, reason = "The benchmark includes this private module without a test harness" )] -#[allow(clippy::disallowed_methods, clippy::disallowed_types)] +#[allow( + clippy::disallowed_methods, + reason = "tests read the host clock directly; an allow because the benchmark compiles them out" +)] mod tests { use super::*; use tokio::io::{AsyncReadExt, AsyncWriteExt}; diff --git a/rs/moq-relay/src/relay.rs b/rs/moq-relay/src/relay.rs index 41f0ca1af36..40a0263d2ca 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; @@ -840,7 +839,11 @@ async fn serve_listening( } #[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 { #[tokio::test] async fn stun_listener_runs_with_the_relay_and_stops_with_it() { diff --git a/rs/moq-relay/src/session.rs b/rs/moq-relay/src/session.rs index b32a2fcc6e8..a2aa1f72326 100644 --- a/rs/moq-relay/src/session.rs +++ b/rs/moq-relay/src/session.rs @@ -476,7 +476,7 @@ pub struct Nudged { } #[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::time::Duration; 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/shutdown.rs b/rs/moq-relay/src/shutdown.rs index 865e8454f24..8ac3919aaba 100644 --- a/rs/moq-relay/src/shutdown.rs +++ b/rs/moq-relay/src/shutdown.rs @@ -385,7 +385,7 @@ pub(crate) async fn raise(signal: libc::c_int) { } #[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-relay/src/stun.rs b/rs/moq-relay/src/stun.rs index b5bd971935a..62c6856f83c 100644 --- a/rs/moq-relay/src/stun.rs +++ b/rs/moq-relay/src/stun.rs @@ -274,7 +274,11 @@ impl Server { } #[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 stun_types::message::{MessageType, MessageWriteVec}; diff --git a/rs/moq-relay/src/uring.rs b/rs/moq-relay/src/uring.rs index c786539d3d4..5a13338c730 100644 --- a/rs/moq-relay/src/uring.rs +++ b/rs/moq-relay/src/uring.rs @@ -889,7 +889,7 @@ async fn serve_request( } #[cfg(test)] -#[allow(clippy::disallowed_methods, clippy::disallowed_types)] +#[expect(clippy::disallowed_methods, reason = "tests read the host clock directly")] mod tests { use super::*; @@ -899,7 +899,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(128 << 20); @@ -914,7 +913,6 @@ mod tests { /// Incomplete messages hold connection credit, so the window has to fit the largest. #[test] - #[allow(clippy::field_reassign_with_default)] fn a_receive_window_below_the_largest_message_is_refused() { let min = moq_net::transport::MIN_RECEIVE_WINDOW; let mut quic = moq_tokio::quic::Config::default(); @@ -933,7 +931,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(256 << 20); @@ -965,7 +962,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() { if !test_env::Env::without(&["SSLKEYLOGFILE"]).isolate() { return; diff --git a/rs/moq-relay/src/web.rs b/rs/moq-relay/src/web.rs index 46d09410080..1a02fe8a273 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 @@ -1183,7 +1189,11 @@ impl IntoResponse for ServeGroup { } #[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 rcgen::{CertificateParams, KeyPair}; diff --git a/rs/moq-relay/src/websocket.rs b/rs/moq-relay/src/websocket.rs index 8aea0ebd82e..5ede1c1e264 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( @@ -255,7 +257,11 @@ fn tungstenite_text_to_axum(text: tungstenite::Utf8Bytes) -> axum::extract::ws:: } #[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 axum::{Router, extract::WebSocketUpgrade, routing::any}; diff --git a/rs/moq-relay/tests/drills.rs b/rs/moq-relay/tests/drills.rs index f872f32bcef..768d7312981 100644 --- a/rs/moq-relay/tests/drills.rs +++ b/rs/moq-relay/tests/drills.rs @@ -25,7 +25,11 @@ //! drill fails when its recovery behavior is removed, and the loom/fuzz cases //! covering the primitives underneath. #![cfg(all(feature = "quic", feature = "websocket"))] -#![allow(clippy::disallowed_methods, clippy::disallowed_types)] +#![expect( + clippy::disallowed_methods, + clippy::disallowed_types, + reason = "tests read the host clock directly" +)] use std::time::Duration; diff --git a/rs/moq-relay/tests/integration/cluster_unknown.rs b/rs/moq-relay/tests/integration/cluster_unknown.rs index 581ec2260a2..e21fc10ffd7 100644 --- a/rs/moq-relay/tests/integration/cluster_unknown.rs +++ b/rs/moq-relay/tests/integration/cluster_unknown.rs @@ -37,10 +37,7 @@ async fn spawn_relay(id: u64, connect: Vec, cluster_version: Option Opti } /// A catalog rendition a media line can serve. -// One per media line, so the variant sizes never add up to an allocation's worth. -#[allow(clippy::large_enum_variant)] +#[allow( + clippy::large_enum_variant, + reason = "one per media line, so the variant sizes never add up to an allocation's worth; only large when extra features grow the video config" +)] enum Rendition { Audio(String, hang::catalog::AudioConfig), Video(String, hang::catalog::VideoConfig), @@ -558,7 +560,7 @@ pub fn dispatch(rtc: &mut str0m::Rtc, request: WriteRequest, wallclock: Instant) } #[cfg(test)] -#[allow(clippy::disallowed_methods, clippy::disallowed_types)] +#[expect(clippy::disallowed_methods, reason = "tests read the host clock directly")] mod tests { /// Build an origin producer, spawning its driver on the ambient runtime. fn produce_origin() -> moq_net::origin::Producer { diff --git a/rs/moq-rtc/src/lib.rs b/rs/moq-rtc/src/lib.rs index 402e6950300..df6ba0dde5b 100644 --- a/rs/moq-rtc/src/lib.rs +++ b/rs/moq-rtc/src/lib.rs @@ -76,7 +76,7 @@ pub use error::*; pub use server::{Response, Server, whep, whip}; #[cfg(all(test, feature = "server"))] -#[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-rtc/src/server/mux.rs b/rs/moq-rtc/src/server/mux.rs index cf7147a0525..59ed2d236a0 100644 --- a/rs/moq-rtc/src/server/mux.rs +++ b/rs/moq-rtc/src/server/mux.rs @@ -208,7 +208,11 @@ fn local_ufrag(data: &[u8]) -> Option { } #[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 std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; use std::time::Duration; diff --git a/rs/moq-rtc/src/server/whip.rs b/rs/moq-rtc/src/server/whip.rs index c4265eddab9..e480d07fdb1 100644 --- a/rs/moq-rtc/src/server/whip.rs +++ b/rs/moq-rtc/src/server/whip.rs @@ -201,7 +201,7 @@ fn status_for(err: &Error) -> StatusCode { } #[cfg(test)] -#[allow(clippy::disallowed_methods, clippy::disallowed_types)] +#[expect(clippy::disallowed_methods, reason = "tests read the host clock directly")] mod tests { use str0m::{ format::Codec, diff --git a/rs/moq-rtmp/Cargo.toml b/rs/moq-rtmp/Cargo.toml index a6ab526196b..9dc64a44eb4 100644 --- a/rs/moq-rtmp/Cargo.toml +++ b/rs/moq-rtmp/Cargo.toml @@ -66,3 +66,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 14b744da8fb..722d4f2d0ad 100644 --- a/rs/moq-rtmp/src/dial.rs +++ b/rs/moq-rtmp/src/dial.rs @@ -609,7 +609,11 @@ impl Publisher { } #[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 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 922fc34c0ca..6458a6ee976 100644 --- a/rs/moq-rtmp/src/server.rs +++ b/rs/moq-rtmp/src/server.rs @@ -1547,7 +1547,11 @@ impl Publisher { } #[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::*; #[tokio::test(start_paused = true)] diff --git a/rs/moq-rtsp/Cargo.toml b/rs/moq-rtsp/Cargo.toml index 5d6f54337d4..4bf40ab5530 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-rtsp/src/client.rs b/rs/moq-rtsp/src/client.rs index 76e505d7940..b6d61705174 100644 --- a/rs/moq-rtsp/src/client.rs +++ b/rs/moq-rtsp/src/client.rs @@ -543,7 +543,11 @@ impl Ingest { } #[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 std::time::Duration; diff --git a/rs/moq-shaper/Cargo.toml b/rs/moq-shaper/Cargo.toml index 3bbc9af171d..54184d88d4a 100644 --- a/rs/moq-shaper/Cargo.toml +++ b/rs/moq-shaper/Cargo.toml @@ -34,3 +34,6 @@ toml = { workspace = true } [dev-dependencies] tokio = { workspace = true, features = ["test-util"] } + +[lints] +workspace = true diff --git a/rs/moq-shaper/src/lib.rs b/rs/moq-shaper/src/lib.rs index 8a7eb2a0812..1a7980b6498 100644 --- a/rs/moq-shaper/src/lib.rs +++ b/rs/moq-shaper/src/lib.rs @@ -1238,7 +1238,7 @@ fn gaussian(rng: &mut Xoshiro256PlusPlus) -> f64 { } #[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-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/shard.rs b/rs/moq-sock/src/shard.rs index 1996199819f..a03c6ad046d 100644 --- a/rs/moq-sock/src/shard.rs +++ b/rs/moq-sock/src/shard.rs @@ -593,7 +593,7 @@ fn program(count: u16) -> [libc::sock_filter; 18] { } #[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-sock/src/udp/apple_fast.rs b/rs/moq-sock/src/udp/apple_fast.rs index eb556b27729..fdedf6177c0 100644 --- a/rs/moq-sock/src/udp/apple_fast.rs +++ b/rs/moq-sock/src/udp/apple_fast.rs @@ -83,7 +83,11 @@ 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 +227,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..a731abe3247 100644 --- a/rs/moq-sock/src/udp/mod.rs +++ b/rs/moq-sock/src/udp/mod.rs @@ -69,9 +69,10 @@ 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 +166,13 @@ 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..8283b3193af 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,11 @@ impl UdpSocketState { #[cfg(not(any(apple, target_os = "openbsd", target_os = "netbsd")))] fn send( - #[allow(unused_variables)] // only used on Linux - state: &UdpSocketState, + #[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 +598,10 @@ 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 +678,10 @@ 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,15 +703,17 @@ 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 - encode_src_ip: bool, + #[allow(unused_variables, reason = "only used on FreeBSD & macOS")] encode_src_ip: bool, sendmsg_einval: bool, ) { iov.iov_base = transmit.contents.as_ptr() as *const _ as *mut _; @@ -793,7 +800,10 @@ 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 +880,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 +909,13 @@ 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 +985,10 @@ 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-sock/tests/udp/main.rs b/rs/moq-sock/tests/udp/main.rs index 30900ccbc32..d7f4704ad1d 100644 --- a/rs/moq-sock/tests/udp/main.rs +++ b/rs/moq-sock/tests/udp/main.rs @@ -1,4 +1,7 @@ -#![allow(clippy::disallowed_methods, clippy::disallowed_types)] +#![expect( + clippy::disallowed_methods, + reason = "tests read the host clock directly" +)] #[cfg(apple)] use std::io::{self, IoSlice}; #[cfg(not(any( diff --git a/rs/moq-srt/Cargo.toml b/rs/moq-srt/Cargo.toml index 5e60c681bdc..265cef7bf79 100644 --- a/rs/moq-srt/Cargo.toml +++ b/rs/moq-srt/Cargo.toml @@ -30,3 +30,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-srt/src/dial.rs b/rs/moq-srt/src/dial.rs index bc567f2b778..c109ae5f655 100644 --- a/rs/moq-srt/src/dial.rs +++ b/rs/moq-srt/src/dial.rs @@ -196,7 +196,7 @@ impl Mode { } #[cfg(test)] -#[allow(clippy::disallowed_methods, clippy::disallowed_types)] +#[expect(clippy::disallowed_methods, reason = "tests read the host clock directly")] mod tests { /// Build an origin producer, spawning its driver on the ambient runtime. fn produce_origin() -> moq_net::origin::Producer { diff --git a/rs/moq-srt/src/server.rs b/rs/moq-srt/src/server.rs index 0ae2b2b3a22..bd4fd8e83d9 100644 --- a/rs/moq-srt/src/server.rs +++ b/rs/moq-srt/src/server.rs @@ -669,7 +669,11 @@ fn parse_stream_id(stream_id: Option<&StreamId>) -> Option<(String, ConnectionMo } #[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 std::time::Instant as StdInstant; diff --git a/rs/moq-srt/src/ts.rs b/rs/moq-srt/src/ts.rs index cbee735bb79..1fca204821b 100644 --- a/rs/moq-srt/src/ts.rs +++ b/rs/moq-srt/src/ts.rs @@ -250,7 +250,11 @@ impl Subscriber { } #[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 moq_mux::catalog::hang::Container; use moq_mux::catalog::{CatalogFormat, Stream}; 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 b96a78bf363..e62c8f55007 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 611311a20e9..3aafa67de4f 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 1e234c37147..ed08a100d1c 100644 --- a/rs/moq-stats/src/aggregate.rs +++ b/rs/moq-stats/src/aggregate.rs @@ -1019,7 +1019,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, @@ -1099,7 +1099,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 4f8d113c3c2..9f99b72942d 100644 --- a/rs/moq-stats/src/produce.rs +++ b/rs/moq-stats/src/produce.rs @@ -1953,7 +1953,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 0c631250e2f..4bb15157b61 100644 --- a/rs/moq-tokio/Cargo.toml +++ b/rs/moq-tokio/Cargo.toml @@ -180,3 +180,5 @@ required-features = ["net"] name = "integration" path = "tests/integration/main.rs" required-features = ["net"] +[lints] +workspace = true diff --git a/rs/moq-tokio/src/client.rs b/rs/moq-tokio/src/client.rs index fb3c30fd3d6..87f188bc319 100644 --- a/rs/moq-tokio/src/client.rs +++ b/rs/moq-tokio/src/client.rs @@ -421,7 +421,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, @@ -661,7 +661,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 } @@ -787,7 +787,7 @@ async fn connect_session( } #[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-tokio/src/connection.rs b/rs/moq-tokio/src/connection.rs index 4066d193234..f1cf2afe0e4 100644 --- a/rs/moq-tokio/src/connection.rs +++ b/rs/moq-tokio/src/connection.rs @@ -1686,7 +1686,11 @@ fn terminal(state: &State) -> Error { } #[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::*; diff --git a/rs/moq-tokio/src/connection/auth.rs b/rs/moq-tokio/src/connection/auth.rs index 761a4bd23aa..65659d843cf 100644 --- a/rs/moq-tokio/src/connection/auth.rs +++ b/rs/moq-tokio/src/connection/auth.rs @@ -401,7 +401,11 @@ async fn present( } #[cfg(all(test, feature = "tcp"))] -#[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::*; 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 708300a393d..00d63dc10e2 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/failover.rs b/rs/moq-tokio/src/failover.rs index da290786ad9..09e1fd0686c 100644 --- a/rs/moq-tokio/src/failover.rs +++ b/rs/moq-tokio/src/failover.rs @@ -190,7 +190,11 @@ fn collapse(mut failures: Vec>) -> E { } #[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 crate::connect::DEFAULT_RACE; diff --git a/rs/moq-tokio/src/iroh.rs b/rs/moq-tokio/src/iroh.rs index e049c09fc3d..5151e74e780 100644 --- a/rs/moq-tokio/src/iroh.rs +++ b/rs/moq-tokio/src/iroh.rs @@ -33,8 +33,10 @@ fn congestion_factory(family: CongestionControl) -> Arc, _: std::time::Instant, _: u16) -> Box { Box::new(*self) @@ -495,7 +500,11 @@ fn url_set_scheme(url: Url, scheme: &str) -> Result { } #[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::*; diff --git a/rs/moq-tokio/src/jemalloc.rs b/rs/moq-tokio/src/jemalloc.rs index 604590e744f..3c1d48ab0e7 100644 --- a/rs/moq-tokio/src/jemalloc.rs +++ b/rs/moq-tokio/src/jemalloc.rs @@ -98,7 +98,7 @@ pub async fn run() -> crate::Result<()> { } #[cfg(test)] -#[allow(clippy::disallowed_methods, clippy::disallowed_types)] +#[expect(clippy::disallowed_methods, reason = "tests read the host clock directly")] mod tests { const USR1_CHILD: &str = "MOQ_NATIVE_USR1_CHILD"; diff --git a/rs/moq-tokio/src/mdns.rs b/rs/moq-tokio/src/mdns.rs index fffe6b57751..4abb47b7c36 100644 --- a/rs/moq-tokio/src/mdns.rs +++ b/rs/moq-tokio/src/mdns.rs @@ -771,7 +771,7 @@ fn instance_id(fullname: &str) -> Option<&str> { } #[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-tokio/src/quic.rs b/rs/moq-tokio/src/quic.rs index 0e8676fa145..7673e37ec47 100644 --- a/rs/moq-tokio/src/quic.rs +++ b/rs/moq-tokio/src/quic.rs @@ -46,7 +46,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() } @@ -755,7 +755,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) } @@ -764,7 +767,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() } @@ -773,7 +776,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/backend.rs b/rs/moq-tokio/src/quic/backend.rs index 23dbf457c16..a01e6c704db 100644 --- a/rs/moq-tokio/src/quic/backend.rs +++ b/rs/moq-tokio/src/quic/backend.rs @@ -1063,7 +1063,7 @@ impl driver::ConnectionIdGenerator for ServerIdGenerator { } #[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 url::Url; diff --git a/rs/moq-tokio/src/quic/driver/connection.rs b/rs/moq-tokio/src/quic/driver/connection.rs index 3570f9b3b04..b76bdd3b392 100644 --- a/rs/moq-tokio/src/quic/driver/connection.rs +++ b/rs/moq-tokio/src/quic/driver/connection.rs @@ -1116,7 +1116,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/driver/mod.rs b/rs/moq-tokio/src/quic/driver/mod.rs index 3956b9c1629..813f87801dd 100644 --- a/rs/moq-tokio/src/quic/driver/mod.rs +++ b/rs/moq-tokio/src/quic/driver/mod.rs @@ -89,7 +89,11 @@ pub use crate::quic::driver::send_group::{SendGroup, SendOptions}; pub use crate::quic::driver::send_stream::{SendStream, StoppedError, WriteError}; #[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; #[derive(Debug)] 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 b1780c70a95..f49d57ee0b6 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. @@ -1037,14 +1039,17 @@ 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) } } #[cfg(all(test, any(feature = "aws-lc-rs", feature = "ring")))] -#[allow(clippy::disallowed_methods, clippy::disallowed_types)] +#[expect(clippy::disallowed_methods, reason = "tests read the host clock directly")] mod tests { use std::{ io::{self, IoSliceMut}, diff --git a/rs/moq-tokio/src/quic/web/settings.rs b/rs/moq-tokio/src/quic/web/settings.rs index 05d938e1bab..d4885e92621 100644 --- a/rs/moq-tokio/src/quic/web/settings.rs +++ b/rs/moq-tokio/src/quic/web/settings.rs @@ -31,11 +31,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, /// The peer's other unidirectional streams that arrived before its control stream, their diff --git a/rs/moq-tokio/src/resolve.rs b/rs/moq-tokio/src/resolve.rs index 26844fd0f8d..5f65c6254b7 100644 --- a/rs/moq-tokio/src/resolve.rs +++ b/rs/moq-tokio/src/resolve.rs @@ -560,7 +560,6 @@ impl Candidates { /// afresh needs a name whose answer changes between dials. Entries carry the /// port too, so two servers on one loopback address can stand in for two hosts. #[cfg(test)] -#[allow(clippy::disallowed_methods, clippy::disallowed_types)] pub(crate) mod hosts { use std::collections::HashMap; use std::net::SocketAddr; @@ -598,7 +597,11 @@ impl Query { } #[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::*; diff --git a/rs/moq-tokio/src/server.rs b/rs/moq-tokio/src/server.rs index 575c612ba55..b226b913905 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")] @@ -339,7 +339,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")] { @@ -554,7 +554,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()); @@ -576,8 +576,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?; @@ -678,13 +680,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 @@ -1873,7 +1875,11 @@ impl Request { } #[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::*; diff --git a/rs/moq-tokio/src/settings.rs b/rs/moq-tokio/src/settings.rs index 017b6c0b1b9..efd8521bd33 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/tcp.rs b/rs/moq-tokio/src/tcp.rs index 0f700f629fa..5725f059bec 100644 --- a/rs/moq-tokio/src/tcp.rs +++ b/rs/moq-tokio/src/tcp.rs @@ -345,7 +345,7 @@ impl Listener { } #[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 moq_net::transport::poll::Session as _; diff --git a/rs/moq-tokio/src/transport.rs b/rs/moq-tokio/src/transport.rs index f9b35154f4c..fe01e0d9f7f 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 { @@ -955,7 +957,7 @@ impl GroupedSend for web_transport_iroh::SendStream { } #[cfg(test)] -#[allow(clippy::disallowed_methods, clippy::disallowed_types)] +#[expect(clippy::disallowed_methods, reason = "tests read the host clock directly")] mod tests { use std::sync::{ Arc, Mutex, diff --git a/rs/moq-tokio/src/webrtc.rs b/rs/moq-tokio/src/webrtc.rs index 01c86875102..82dfb178f42 100644 --- a/rs/moq-tokio/src/webrtc.rs +++ b/rs/moq-tokio/src/webrtc.rs @@ -959,5 +959,9 @@ async fn mdns(host: &str) -> Result { } #[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-tokio/src/websocket.rs b/rs/moq-tokio/src/websocket.rs index 59dd2b1d850..694d17696b9 100644 --- a/rs/moq-tokio/src/websocket.rs +++ b/rs/moq-tokio/src/websocket.rs @@ -694,7 +694,10 @@ impl Listener { let accepted = Arc::new(Mutex::new(None::<(String, 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> { @@ -916,7 +919,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-tokio/tests/integration/main.rs b/rs/moq-tokio/tests/integration/main.rs index 60d4b2ceec1..e23e62e0fd2 100644 --- a/rs/moq-tokio/tests/integration/main.rs +++ b/rs/moq-tokio/tests/integration/main.rs @@ -2,7 +2,11 @@ //! //! Each `tests/*.rs` file is its own crate that links this package and its //! dependencies again, so add new integration tests here as a module. -#![allow(clippy::disallowed_methods, clippy::disallowed_types)] +#![expect( + clippy::disallowed_methods, + clippy::disallowed_types, + reason = "tests read the host clock directly" +)] mod backend; mod broadcast; 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-transcode/src/active.rs b/rs/moq-transcode/src/active.rs index e380cf2d79c..00ac9692941 100644 --- a/rs/moq-transcode/src/active.rs +++ b/rs/moq-transcode/src/active.rs @@ -358,7 +358,7 @@ fn next_update(state: &State, seen: &BTreeMap) -> Option { } #[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-transcode/src/catalog.rs b/rs/moq-transcode/src/catalog.rs index f21c0f5d6e9..ce7a0084f1f 100644 --- a/rs/moq-transcode/src/catalog.rs +++ b/rs/moq-transcode/src/catalog.rs @@ -410,7 +410,11 @@ pub(crate) fn populate( } #[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 hang::catalog::H264; diff --git a/rs/moq-transcode/src/lib.rs b/rs/moq-transcode/src/lib.rs index 6456a4a0b80..7ab0b48c9ea 100644 --- a/rs/moq-transcode/src/lib.rs +++ b/rs/moq-transcode/src/lib.rs @@ -210,7 +210,7 @@ impl Transcoder { } #[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-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 005a71fd3ab..6688fba0d31 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 b4a3f96065d..122dc073ac7 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 9079c8ad8a6..206030dc08b 100644 --- a/rs/moq-uring/src/udp.rs +++ b/rs/moq-uring/src/udp.rs @@ -451,7 +451,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`. @@ -748,13 +748,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 } @@ -793,7 +793,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(); } @@ -802,7 +802,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 a547e782b60..9c98a35f8d3 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 a58e13ab733..efac4b5f07c 100644 --- a/rs/moq-uring/tests/integration/web.rs +++ b/rs/moq-uring/tests/integration/web.rs @@ -379,8 +379,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(); @@ -742,7 +744,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 50a8bf04cab..3bd2df7c898 100644 --- a/rs/moq-video/Cargo.toml +++ b/rs/moq-video/Cargo.toml @@ -282,3 +282,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/examples/encode-presets.rs b/rs/moq-video/examples/encode-presets.rs index 5be2de5a5d1..976d5d5300d 100644 --- a/rs/moq-video/examples/encode-presets.rs +++ b/rs/moq-video/examples/encode-presets.rs @@ -19,7 +19,11 @@ //! times the input's size on disk. //! //! Hardware on another machine needs its own run; nothing here extrapolates. -#![allow(clippy::disallowed_methods, clippy::disallowed_types)] +#![expect( + clippy::disallowed_methods, + clippy::disallowed_types, + reason = "the example reads the host clock" +)] use std::time::{Duration, Instant}; diff --git a/rs/moq-video/src/capture/avfoundation.rs b/rs/moq-video/src/capture/avfoundation.rs index 436fe31f54c..0e853ce1637 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/capture/x11.rs b/rs/moq-video/src/capture/x11.rs index 75cf0437614..ce849ab9a98 100644 --- a/rs/moq-video/src/capture/x11.rs +++ b/rs/moq-video/src/capture/x11.rs @@ -327,8 +327,10 @@ impl Capture { fn read(&mut self) -> Result { let now = Instant::now(); if self.next > now { - // The capture thread runs outside any runtime, so it blocks on the host clock. - #[allow(clippy::disallowed_methods)] + #[expect( + clippy::disallowed_methods, + reason = "the capture thread runs outside any runtime, so it blocks on the host clock" + )] std::thread::sleep(self.next - now); } self.next = Instant::now() + self.interval; 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 1892a5b337a..5271f428efb 100644 --- a/rs/moq-video/src/decode/consumer.rs +++ b/rs/moq-video/src/decode/consumer.rs @@ -371,8 +371,15 @@ impl Reader { #[cfg(test)] mod tests { - #![cfg_attr(not(feature = "openh264"), allow(dead_code, unused_imports))] - #![allow(clippy::disallowed_methods, clippy::disallowed_types)] + #![cfg_attr( + not(feature = "openh264"), + allow(dead_code, unused_imports, reason = "only the `openh264` feature uses it") + )] + #![expect( + clippy::disallowed_methods, + clippy::disallowed_types, + reason = "tests read the host clock directly" + )] 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 05bd8187743..025831f4980 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 44e0c423eb2..aab4a4461a2 100644 --- a/rs/moq-video/src/encode/producer.rs +++ b/rs/moq-video/src/encode/producer.rs @@ -94,7 +94,10 @@ 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, _ext: std::marker::PhantomData E>, } @@ -531,7 +534,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, @@ -823,8 +826,18 @@ fn map_capture_timestamp(epoch_micros: u64, timestamp: Timestamp) -> Result