FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust
Never crash: deny the panicking lints in the already-clean crates and apps
Brandon Thomasb16e0889f3f1
diff --git a/apps/filmcraft-web/src/fs.rs b/apps/filmcraft-web/src/fs.rsindex 123c3d916..b959bdcb7 100644--- a/apps/filmcraft-web/src/fs.rs+++ b/apps/filmcraft-web/src/fs.rs@@ -289,20 +289,25 @@ impl ByteReader for BlobReader {}return Err(filmcraft_media::pending::would_block());}- FS.with(|fs| {+ let complete = FS.with(|fs| {let mut fs = fs.borrow_mut();fs.clock += 1;let t = fs.clock;let mut pos = 0usize;for c in c0..=c1 {- let (d, used) = fs.chunks.get_mut(&(self.id, c)).expect("checked above");+ // Present (checked above); evicted in between would be a bug, reported as an error.+ let Some((d, used)) = fs.chunks.get_mut(&(self.id, c)) else { return false };*used = t;let a = if c == c0 { (offset - c * CHUNK) as usize } else { 0 };let n = (d.len() - a).min(buf.len() - pos);buf[pos..pos + n].copy_from_slice(&d[a..a + n]);pos += n;}+ true});+ if !complete {+ return Err(filmcraft_media::pending::would_block());+ }// read-ahead for sequential accessfor c in c1 + 1..=(c1 + READ_AHEAD).min(last) {request(self.id, c);diff --git a/apps/filmcraft-web/src/lib.rs b/apps/filmcraft-web/src/lib.rsindex 67b83f92e..469d2107a 100644--- a/apps/filmcraft-web/src/lib.rs+++ b/apps/filmcraft-web/src/lib.rs@@ -16,6 +16,7 @@//!//! Everything here is `wasm32`-only; on other targets the crate is empty.#![cfg(target_arch = "wasm32")]+#![cfg_attr(not(test), deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable))]pub mod api;pub mod audio;diff --git a/apps/filmcraft-web/src/webcodecs.rs b/apps/filmcraft-web/src/webcodecs.rsindex fae3e2f24..650999733 100644--- a/apps/filmcraft-web/src/webcodecs.rs+++ b/apps/filmcraft-web/src/webcodecs.rs@@ -463,7 +463,7 @@ impl WcSource {c.frames.insert(pts, Arc::new(f));}while c.frames.len() > CACHE_FRAMES {- let far = c.frames.keys().copied().max_by_key(|p| (p - want).abs()).expect("non-empty");+ let Some(far) = c.frames.keys().copied().max_by_key(|p| (p - want).abs()) else { break };c.frames.remove(&far);}// the session's own frame came out: other requests may restart it nowdiff --git a/apps/filmcraft/src/main.rs b/apps/filmcraft/src/main.rsindex 4a37fe831..93f27d934 100644--- a/apps/filmcraft/src/main.rs+++ b/apps/filmcraft/src/main.rs@@ -15,6 +15,8 @@//! asking, `--no-recover` starts without asking (the changes stay available via File ▸ Recover//! Unsaved Changes…).+#![cfg_attr(not(test), deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable))]+mod app_nap;mod audio;mod audio_in;diff --git a/crates/aac/src/lib.rs b/crates/aac/src/lib.rsindex d576e9e32..6b650224d 100644--- a/crates/aac/src/lib.rs+++ b/crates/aac/src/lib.rs@@ -31,6 +31,8 @@//! # Ok::<(), filmcraft_aac::Error>(())//! ```+#![cfg_attr(not(test), deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable))]+mod config;mod decoder;mod encoder;diff --git a/crates/bitstream/src/lib.rs b/crates/bitstream/src/lib.rsindex 779970f18..8b708f9dd 100644--- a/crates/bitstream/src/lib.rs+++ b/crates/bitstream/src/lib.rs@@ -5,6 +5,8 @@//! - [`unescape_rbsp`] / [`escape_rbsp`]: remove/insert H.264/HEVC emulation-prevention bytes.//! - [`annexb_nals`] / [`length_prefixed_nals`]: split Annex-B byte streams and AVCC/HVCC samples into NAL units.+#![cfg_attr(not(test), deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable))]+use std::fmt;#[derive(Debug, Clone, Copy, PartialEq, Eq)]diff --git a/crates/cfb/src/lib.rs b/crates/cfb/src/lib.rsindex f54a2f105..12e376c20 100644--- a/crates/cfb/src/lib.rs+++ b/crates/cfb/src/lib.rs@@ -15,6 +15,8 @@//!//! Layer L0: no dependencies beyond `std`, no `unsafe`, builds for `wasm32-unknown-unknown`.+#![cfg_attr(not(test), deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable))]+mod read;mod write;diff --git a/crates/color/src/lib.rs b/crates/color/src/lib.rsindex 95f19006a..2ad1fa5f2 100644--- a/crates/color/src/lib.rs+++ b/crates/color/src/lib.rs@@ -5,6 +5,8 @@//! The compositor works in **linear-light, premultiplied RGBA f32** in the sequence working space//! (Rec.709 primaries by default). Decoded frames carry [`ColorInfo`] so conversions are explicit.+#![cfg_attr(not(test), deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable))]+use serde::{Deserialize, Serialize};use std::sync::OnceLock;diff --git a/crates/format/src/lib.rs b/crates/format/src/lib.rsindex cceb390e8..220bd8545 100644--- a/crates/format/src/lib.rs+++ b/crates/format/src/lib.rs@@ -34,6 +34,8 @@//! per-character text styles (`TrackItem::graphic`, `EffectInstance::layer`) and source graphics//! (`Project::source_graphics`). No-op step; older builds would drop these fields when saving.+#![cfg_attr(not(test), deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable))]+pub mod atomic;pub mod autosave;diff --git a/crates/frame/src/lib.rs b/crates/frame/src/lib.rsindex 51c3dcbb4..d62d1dbfb 100644--- a/crates/frame/src/lib.rs+++ b/crates/frame/src/lib.rs@@ -5,6 +5,8 @@//! compositor. Pixel data is `Arc`-shared so caches, monitors and export share frames for free.//! - [`AudioBuffer`]: planar f32 samples.+#![cfg_attr(not(test), deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable))]+use std::sync::Arc;use filmcraft_color::{ColorInfo, DecodeTable, Matrix, Range, linear_to_srgb_u8, normalize_c, normalize_y, srgb_u8_to_linear_table, to_linear, ycbcr_to_rgb};diff --git a/crates/geom/src/lib.rs b/crates/geom/src/lib.rsindex ca4ce6bcf..60a6ab6d3 100644--- a/crates/geom/src/lib.rs+++ b/crates/geom/src/lib.rs@@ -1,5 +1,7 @@//! 2D geometry for FilmCraft: vectors, rectangles and affine transforms (Motion effect math).+#![cfg_attr(not(test), deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable))]+use serde::{Deserialize, Serialize};use std::ops::{Add, Mul, Sub};diff --git a/crates/isobmff/src/lib.rs b/crates/isobmff/src/lib.rsindex bfb8a51b5..b34a158b3 100644--- a/crates/isobmff/src/lib.rs+++ b/crates/isobmff/src/lib.rs@@ -8,6 +8,8 @@//!//! See the crate README for supported boxes and limitations.+#![cfg_attr(not(test), deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable))]+mod bytes;mod codec;mod demux;diff --git a/crates/media/src/lib.rs b/crates/media/src/lib.rsindex 610495c84..c30d002f8 100644--- a/crates/media/src/lib.rs+++ b/crates/media/src/lib.rs@@ -7,6 +7,8 @@//!//! Time passed to a source is **media time** (0 = first frame of the media), in ticks.+#![cfg_attr(not(test), deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable))]+pub mod cache;pub mod cancel;pub mod digits;diff --git a/crates/scopes/src/lib.rs b/crates/scopes/src/lib.rsindex 7928945b1..ae56e5e1a 100644--- a/crates/scopes/src/lib.rs+++ b/crates/scopes/src/lib.rs@@ -20,6 +20,8 @@//! `[-0.1, 1.1]` without (values outside are dropped). With 256 rows over `[0, 1]`, an 8-bit code//! value `c` lands exactly on row `c`.+#![cfg_attr(not(test), deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable))]+pub mod paint;pub mod summary;#[cfg(test)]diff --git a/crates/speech/src/lib.rs b/crates/speech/src/lib.rsindex 68922daeb..c510454cf 100644--- a/crates/speech/src/lib.rs+++ b/crates/speech/src/lib.rs@@ -14,6 +14,8 @@//!//! See `docs/transcripts.md` for the user-facing behaviour and accuracy numbers.+#![cfg_attr(not(test), deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable))]+pub mod diarize;pub mod mel;pub mod models;