Skip to content

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.

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.

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
}

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:

src/bases/db/mod.rs
#[allow(dead_code, unused_imports)]
pub mod schemas;

Never edit files inside schemas/ directly — they get overwritten by sea-orm-cli generate entity.

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 AppError used only on the server side look unused to the client build

The top-level module declarations suppress these false positives:

src/main.rs
#[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.

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.

After any refactor, confirm zero warnings:

Terminal window
cargo check 2>&1 | grep "^warning:" | wc -l
# Expected: 0

Then verify both targets build:

Terminal window
dx build
# Server build completed successfully
# Client build completed successfully