Loading...
Loading...
Comprehensive Rust code review across four lenses — source code (ownership, borrowing, lifetimes, errors, trait design, unsafe, common mistakes), tests (unit, integration, async testing, mocking, property-based), tokio async (task management, sync primitives, channels), and FFI (extern blocks,
npx skill4agent add arthrod/conejo-skills rust-review| Lens | Section |
|---|---|
| Source code — ownership, errors, trait design, unsafe | Source review |
| Test code — unit, integration, async, mocking, proptest | Test review |
| tokio async — task mgmt, sync primitives, channels | Tokio async review |
| FFI — extern, repr(C), strings, callbacks, unsafe boundary | FFI review |
rust-authorCargo.toml![FILE:LINE] ISSUE_TITLE
Severity: Critical | Major | Minor | Informational
Description of the issue and why it matters.| Issue Type | Reference |
|---|---|
| Ownership transfers, borrowing, lifetimes, clone traps, iterators | references/ownership-borrowing.md |
| Lifetime variance, covariance/invariance, memory regions | references/lifetime-variance.md |
| Result/Option handling, thiserror, anyhow, error context, Error trait | references/error-handling.md |
| Async pitfalls, Send/Sync bounds, runtime blocking | references/async-concurrency.md |
| Send/Sync semantics, atomics, memory ordering, lock patterns | references/concurrency-primitives.md |
| Type layout, alignment, repr, PhantomData, generics vs dyn Trait | references/types-layout.md |
| Unsafe code, API design, derive patterns, clippy patterns | references/common-mistakes.md |
| Safety contracts, raw pointers, MaybeUninit, soundness, Miri | references/unsafe-deep.md |
For development guidance on performance, pointer types, type state, clippy config, iterators, generics, and documentation, use theskill.beagle-rust:rust-best-practices
.clone().clone().cloned().copied()'static-> impl Trait+ use<'a>&strString&[T]Vec<T>impl AsRef<T>Into<T>CellRefCellMutexCopyCow<'_, T>.collect().sum().fold()_or_elseif letif letBox<[T]>IntoIteratorinto_vec()Result<T, E>panic!unwrapexpect#[error("...")]Display?From.map_err()unwrap()expect()anyhowthiserror_or_elseok_or_elseunwrap_or_elselet-elselet Ok(x) = expr else { return ... }inspect_errmap_errderiveCloneDebugPartialEqstruct UserId(Uuid)UuidFromIntoTryFromSend + Sync#[diagnostic::on_unimplemented]unsafeunsafeunsafeunsafe fnunsafe {}unsafe_op_in_unsafe_fnextern "C" {}unsafe extern "C" {}#[no_mangle]#[export_name]#[unsafe(no_mangle)]#[unsafe(export_name)]PascalCasesnake_caseSCREAMING_SNAKE_CASEsnake_caseis_has_can_self&mut self///#[must_use]#[expect(clippy::...)]#[allow(...)]Detailed guidance:skill (references/performance.md)beagle-rust:rust-best-practices
&strString&[T]Vec<T>collect()Vec::with_capacity().to_string().to_owned().collect().sum().fold()impl Traitdyn TraitDetailed guidance:skill (references/clippy-config.md)beagle-rust:rust-best-practices
Cargo.toml[workspace.lints.clippy][lints.clippy]#[expect(clippy::lint)]#[allow(...)]redundant_clonelarge_enum_variantneedless_collectperfcargo clippy --all-targets --all-features -- -D warningsmissing_docsbroken_intra_doc_linksDetailed guidance:skill (references/type-state-pattern.md)beagle-rust:rust-best-practices
PhantomData<State>selfunsafeunwrap()Arc<Mutex<...>>return err.clone()SendSyncpanic!'staticString&strimpl AsRef<str>Cargo.toml#[must_use]#[non_exhaustive]beagle-rust:rust-best-practices.clone()unwrap()Box<dyn Error>String&str#[allow(dead_code)]todo!()unimplemented!().expect("reason")use super::*#[cfg(test)]type Result<T> = std::result::Result<T, MyError>impl Traitcollect::<Vec<_>>()_#[expect(clippy::...)]Arc::clone(&arc)std::sync::Mutexforasync fnasync-traitdyn TraitLazyCellLazyLockonce_celllazy_static+ use<'a, T>| Issue | Flag ONLY IF |
|---|---|
| Missing error context | Error crosses module boundary without context |
Unnecessary | In hot path or repeated call, not test/setup code |
| Missing doc comments | Item is |
| In production code path, not test/example/provably-safe |
Missing | Type is actually shared across thread/task boundaries |
| Overly broad lifetime | A shorter lifetime would work AND the API is public |
Missing | Function returns a value that callers commonly ignore |
Stale | Should be |
Missing | Type is ≤24 bytes with all-Copy fields and used frequently |
Edition 2024: | Match on |
Edition 2024: | Code uses |
beagle-rust:review-verification-protocolcode-reviewautofixpython-code-reviewrust-testing-code-reviewtokio-async-code-reviewffi-code-reviewdeepagents-code-reviewsqlalchemy-code-reviewCargo.tomlif let#[expect]#[cfg(test)]tests/#[tokio::test]async-traitasync fnif letLazyLocklazy_static!once_cell[FILE:LINE] ISSUE_TITLE
Severity: Critical | Major | Minor | Informational
Description of the issue and why it matters.| Issue Type | Reference |
|---|---|
Unit tests, assertions, naming, snapshots, rstest, doc tests, | references/unit-tests.md |
Integration tests, async testing, fixtures, test databases, native | references/integration-tests.md |
| Fuzzing, property-based testing, Miri, Loom, benchmarking, compile_fail, custom harness, mocking strategies | references/advanced-testing.md |
#[cfg(test)] mod teststests/use super::*test_<function>_<scenario>_<expected>#[tokio::test]#[tokio::test(flavor = "multi_thread")]block_on.awaitasync fnasync-traitassert_eq!assert_ne!assert!matches!matches!if letstd::sync::LazyLocklazy_static!once_cellResult::Err#[should_panic]Result#[expect(lint)]#[allow(lint)]#[expect]#[allow]#[allow]#[expect]test_happy_pathmod<function>_should_<behavior>_when_<condition>cargo instasnapshots/assert_eq!rstest#[rstest]#[case::name]#[fixture]#[case(1)]#[rstest] #[tokio::test]/// # Examples#cargo test --doc#[should_panic]expectedunwrap()if letasync-traitasync fnassert!(x == y)assert_eq!(x, y)#[allow]#[expect]lazy_static!once_cellLazyLockproptestquickcheckunwrap()expect()use super::*#[allow(dead_code)]clone()assert!.is_some().is_empty()unwrap()Result?async-traitdynasync fndyn Traitasync-trait#[expect]LazyLockbeagle-rust:review-verification-protocolcode-reviewautofixpython-code-reviewrust-code-reviewtokio-async-code-reviewffi-code-reviewdeepagents-code-reviewsqlalchemy-code-reviewfullrt-multi-threadmacrossync#[tokio::main]std::fsstd::netstd::thread::sleep[FILE:LINE] ISSUE_TITLE
Severity: Critical | Major | Minor | Informational
Description of the issue and why it matters.| Issue Type | Reference |
|---|---|
| Task spawning, JoinHandle, structured concurrency | references/task-management.md |
| Mutex, RwLock, Semaphore, Notify, Barrier | references/sync-primitives.md |
| mpsc, broadcast, oneshot, watch channel patterns | references/channels.md |
| Pin, cancellation, Future internals, select!, blocking bridge | references/pinning-cancellation.md |
multi_threadcurrent_thread#[tokio::test]spawnJoinHandlespawn_blockingCancellationTokenselect!JoinErrortokio::select!async fnasync-trait-> impl Futuretokio::sync::Mutex.awaitstd::sync::MutexSemaphoreRwLockNotifystd::sync::LazyLockonce_cell::sync::Lazylazy_static!if letSendErrorRecvErrorLaggedtokio::time::sleepstd::thread::sleeptokio::time::timeouttokio::time::interval.tick().awaitstd::fs::readstd::net::TcpStreamspawn_blocking.awaitstd::thread::sleepJoinHandleselect!tokio::spawn#[tokio::main]std::sync::Mutextokio-utilCancellationTokenJoinSetasync-traitasync fnonce_celllazy_staticstd::sync::LazyLock#[expect(lint)]#[allow(lint)]std::sync::Mutex.awaittokio::spawn#[tokio::main(flavor = "current_thread")]clone()Arc<T>spawnasync fnasync-traitdyn+ use<'a>-> impl Future#[expect(clippy::type_complexity)]#[allow]beagle-rust:review-verification-protocolcode-reviewautofixpython-code-reviewrust-code-reviewrust-testing-code-reviewffi-code-reviewdeepagents-code-reviewsqlalchemy-code-reviewbuild-dependenciescrate-typecdylibstaticliblinkscargo:rustc-link-libcargo:rustc-link-search#[repr(C)]extern "C" fnbeagle-rust:review-verification-protocol[FILE:LINE] ISSUE_TITLE
Severity: Critical | Major | Minor | Informational
Description of the issue and why it matters.| Issue Type | Reference |
|---|---|
| C-to-Rust type mapping, repr(C) layout, enums, opaque types | references/type-mapping.md |
| Safe wrappers, ownership transfer, callbacks, build.rs, testing | references/safety-patterns.md |
extern "C"externextern "C" {}unsafe extern "C" {}extern "C" fn"C""system"#[link(name = "...")]#[link(name = "...", kind = "static")]#[no_mangle]#[no_mangle]#[unsafe(no_mangle)]#[export_name = "..."]#[unsafe(export_name = "...")]#[link_name = "..."]pub#[no_mangle]#[repr(C)]std::ffistd::os::rawc_intc_charc_voidi32intc_int__be32[u8; 4]#[repr(C)]#[repr(u8)]#[repr(u32)]bitflags#[non_exhaustive]CStrCString&strStringCString::new()Err\0CString*const c_char.as_ptr()*const c_charCStr::from_ptr()unsafeto_str()ResultOsStrOsStringCStr&strBox::from_rawBox::into_rawBox::from_rawVec::into_raw_partsDropextern "C" fn(...)fn(...)std::panic::catch_unwind*mut c_voidOption<extern "C" fn(...)>-sysbuild.rscargo:rustc-link-libcargo:rustc-link-searchlinksCargo.tomlunsafe// SAFETY:unsafe fnunsafe {}#[repr(C)]&strStringCStrCStringcatch_unwindextern "C" fnunsafe*const T*mut TCString#[link(name = "...")]externunsafe extern#[no_mangle]#[unsafe(...)]i32c_intint#[non_exhaustive]-sys*mut c_voidOption<NonNull<T>>unsafe extern "C" {}#[unsafe(no_mangle)]Option<extern "C" fn(...)>Option<NonNull<T>>*mut c_voidc_voidCStr::from_bytes_with_nul_uncheckedextern "C-unwind"include!(concat!(env!("OUT_DIR"), "/bindings.rs"))Box::into_rawBox::from_rawbeagle-rust:review-verification-protocolcode-reviewautofixpython-code-reviewrust-code-reviewrust-testing-code-reviewtokio-async-code-reviewdeepagents-code-reviewsqlalchemy-code-review