Cargo Warning Conventions
Loquent targets zero warnings on cargo check. This guide covers the patterns used across the codebase and what to follow when adding new code.
ReadSignal over ReadOnlySignal
Section titled “ReadSignal over ReadOnlySignal”Dioxus deprecated ReadOnlySignal in favor of ReadSignal. All component props use ReadSignal:
use dioxus::prelude::*;
#[component]pub fn AgentDetails(agent_id: ReadSignal<i32>) -> Element { let id = agent_id(); // ...}Do not use ReadOnlySignal — it will be removed in Dioxus 0.8.
Unused handler parameters
Section titled “Unused handler parameters”Server functions and API handlers often receive parameters like session that aren’t used in every handler. Prefix them with _ to silence warnings while preserving the function signature:
#[server]pub async fn delete_agent( _session: Session, agent_id: i32,) -> Result<(), ServerFnError> { // session not needed here but required by the router signature delete_agent_by_id(agent_id).await}Auto-generated schema files
Section titled “Auto-generated schema files”SeaORM generates entity files in src/bases/db/schemas/. These files trigger dead-code and unused-import warnings because not every generated field is consumed. The module declaration suppresses them:
#[allow(dead_code, unused_imports)]pub mod schemas;Never edit files inside schemas/ directly — they get overwritten by sea-orm-cli generate entity.
False-positive dead code in module roots
Section titled “False-positive dead code in module roots”Rust’s dead-code analysis cannot trace usage through:
- Axum router registrations —
.route("/path", get(handler))doesn’t count as a “call” to the linter #[cfg]compilation splits — server-only code appears dead when analyzing the WASM target, and vice versa- Cross-target type usage — types like
AppErrorused only on the server side look unused to the client build
The top-level module declarations suppress these false positives:
#[allow(dead_code, unused_imports)]mod bases;#[allow(dead_code, unused_imports)]mod mods;#[allow(dead_code, unused_imports)]mod ui;The same pattern applies in src/mods/mod.rs and src/bases/mod.rs for their submodule declarations.
Pub use re-exports
Section titled “Pub use re-exports”When running cargo fix, it may incorrectly remove pub use re-exports whose consumers aren’t visible to the binary’s dead-code analysis. Always verify that re-exports in mod.rs files are preserved, especially for:
- Route handler registrations (
pub use serve_recording_api::*) - Job scheduler entrypoints (
pub use app_jobs::*) - Twilio route handlers (
pub use twilio_stream_route::*)
If cargo fix removes a pub use and the build still passes but runtime routes 404, the re-export was needed.
Verification
Section titled “Verification”After any refactor, confirm zero warnings:
cargo check 2>&1 | grep "^warning:" | wc -l# Expected: 0Then verify both targets build:
dx build# Server build completed successfully# Client build completed successfully