clippy: clear the workspace errors and apply the machine fixes

- Mark the raw-pointer interop entry points unsafe with # Safety docs
  (oak-core upload/download/frame-from-pixels, oak-audio convert) and
  satisfy the existing callers (tests).
- mut_from_ref: allow with the ABI contract documented (the handle
  get_mut helpers in oak-timeline/oak-render/oak-task take the shared
  reference the C ABI passes; exclusivity is the caller's unsafe
  contract).
- Fix the eq_op in the white-balance normalization (green / green).
- Apply cargo clippy --fix across the workspace (redundant closures and
  field names, field reassignment, items after test modules, ...).
- Revert the replace_box fix in image_effect's clip_define: a
  redefinition must allocate a new box, otherwise the old clip handle
  stays valid and the HS-map replace contract (clip != clip2) breaks.
- 283 warnings remain; they are all non-machine-applicable
  (chunks_exact -> as_chunks needs a manual iter_mut, too_many_arguments,
  complex types, missing Safety docs, ...) and are tracked as the
  follow-up.
This commit is contained in:
2026-09-15 19:29:32 +08:00
parent 7e87ec135e
commit ee7ea18d94
146 changed files with 5235 additions and 4046 deletions
+1 -1
View File
@@ -144,7 +144,7 @@ impl UndoStack {
&& !self
.commands
.back()
.map_or(true, |entry| entry.command.is_empty())
.is_none_or(|entry| entry.command.is_empty())
}
/// Whether a redo is possible.
+9 -3
View File
@@ -20,7 +20,10 @@
//! (the former handle-level/refcount tests were removed together with
//! the `CHandle` layer they exercised).
use oak_undo::error::{Error, OAKUNDO_E_FAILED, OAKUNDO_E_INVALID, OAKUNDO_E_NOMEM, OAKUNDO_E_NOT_FOUND, OAKUNDO_E_STATE};
use oak_undo::error::{
Error, OAKUNDO_E_FAILED, OAKUNDO_E_INVALID, OAKUNDO_E_NOMEM, OAKUNDO_E_NOT_FOUND,
OAKUNDO_E_STATE,
};
use oak_undo::undocommand::{MultiUndoCommand, UndoCommand};
use oak_undo::undostack::{EmptyCommand, UndoStack, K_MAX_UNDO_COMMANDS};
@@ -37,7 +40,7 @@ fn error_code_mapping_is_complete() {
/// `Default` impls mirror `new()`.
#[test]
fn default_impls_match_new() {
let _empty = EmptyCommand::default();
let _empty = EmptyCommand;
let stack = UndoStack::default();
assert_eq!(
stack.done_count(),
@@ -71,7 +74,10 @@ fn push_pre_executed_clears_redo_tail_and_caps() {
}
stack.undo().unwrap();
stack.push_pre_executed(UndoCommand::from_closures(|| {}, || {}), name);
assert!(!stack.can_redo(), "push_pre_executed drops the redoable tail");
assert!(
!stack.can_redo(),
"push_pre_executed drops the redoable tail"
);
// Fill past the cap with pre-executed commands: the oldest rows are
// evicted and the count stays at K_MAX_UNDO_COMMANDS.
+16 -10
View File
@@ -55,7 +55,10 @@ struct FreeProbe {
impl Drop for FreeProbe {
fn drop(&mut self) {
self.trace.lock().unwrap().push(format!("free:{}", self.name));
self.trace
.lock()
.unwrap()
.push(format!("free:{}", self.name));
}
}
@@ -106,11 +109,14 @@ fn command_drop_frees_exactly_once() {
name: "a",
trace: trace.clone(),
};
let cmd = UndoCommand::from_closures(move || {}, move || {
// `probe` must be captured by value so that dropping the command
// frees it; dropping a reference (the previous body) did nothing.
let _ = &probe;
});
let cmd = UndoCommand::from_closures(
move || {},
move || {
// `probe` must be captured by value so that dropping the command
// frees it; dropping a reference (the previous body) did nothing.
let _ = &probe;
},
);
drop(cmd);
assert_eq!(events(&trace), vec!["free:a"]);
@@ -141,8 +147,8 @@ fn multi_redo_undo_ordering() {
assert_eq!(multi.multi_child_count(), 3);
// Children are reachable and named.
assert_eq!(multi.multi_child(0).unwrap().is_done(), false);
assert_eq!(multi.multi_child(2).unwrap().is_done(), false);
assert!(!multi.multi_child(0).unwrap().is_done());
assert!(!multi.multi_child(2).unwrap().is_done());
assert!(matches!(multi.multi_child(3), Err(Error::NotFound)));
// Redo in insertion order; undo in reverse.
@@ -182,7 +188,7 @@ fn stack_new_has_empty_bottom() {
assert!(!s.can_undo());
assert!(!s.can_redo());
assert_eq!(s.command_name(0).unwrap(), "New/Open Project");
assert_eq!(s.command_is_done(0).unwrap(), true);
assert!(s.command_is_done(0).unwrap());
}
#[test]
@@ -203,7 +209,7 @@ fn stack_push_undo_redo_branch() {
assert!(s.can_redo());
assert_eq!(s.done_count(), 2);
assert_eq!(s.command_name(2).unwrap(), "B"); // undone row is still labeled
assert_eq!(s.command_is_done(2).unwrap(), false);
assert!(!s.command_is_done(2).unwrap());
// Redo restores.
s.redo().unwrap();