Documentation Lints
Documentation lints ensure public API items have rustdoc comments and valid doc links. Enable missing_docs for libraries consumers depend on.
Search across all documentation pages
Documentation lints ensure public API items have rustdoc comments and valid doc links. Enable missing_docs for libraries consumers depend on.
[lints.rust]
missing_docs = "warn"
broken_intra_doc_links = "deny"/// Returns the user id.
///
/// # Errors
///
/// Fails when the id is not found.
pub fn user_id() -> Result<u64, Error> { todo!() }When to reach for this: Published crates, internal platform libraries, and any pub API surface.
[lints.rust]
missing_docs = "warn"
unsafe_code = "forbid"//! Crate-level documentation for `orders`.
//!
//! # Examples
//!
//! ```
//! use orders::Client;
//! ```
/// HTTP client for the orders API.
pub struct Client;cargo doc --no-deps --document-private-items
RUSTDOCFLAGS="-D warnings" cargo doc --no-depsWhat this demonstrates:
//! documents the crate/module/// documents the following item# Errors, # Panics, # Safety sections expected by API guidelinesRUSTDOCFLAGS="-D warnings" fails on broken links in CI| Lint | Catches |
|---|---|
missing_docs | Undocumented pub items |
broken_intra_doc_links | [WrongType] links |
missing_crate_level_docs | Empty crate root docs |
invalid_html | Bad tags in docs |
no_runResult variantspub unsafe fnmissing_docs targets pub by default policy; allow private modules.RUSTDOCFLAGS="-D warnings" on PRs.cargo test --doc in CI.| Alternative | Use When | Don't Use When |
|---|---|---|
warn vs deny missing_docs | Gradual adoption | Greenfield public crate |
| External mdbook only | Narrative guides | Replacing API reference |
#[doc(hidden)] | Internal re-exports | Hiding public API mistakes |
Often relaxed; focus on library crates in workspace.
List each Error variant behavior under # Errors with when it occurs.
Not required; at least one crate example and doctests on complex APIs.
Use full path [Client](Client) same module or [super::foo] paths rustdoc resolves.
Same rustdoc; CI cargo doc catches issues before publish.
Document enum and each variant if public, especially error enums.
#[doc(inline)] on pub use shows docs at re-export site.
Usually N/A for test modules; public test helpers in integration crates should be documented or kept private.
Shared [lints.rust] missing_docs = "warn" in each lib Cargo.toml or workspace lint inheritance pattern.
# Safety on trait and implementations explaining invariants maintainers must uphold.
Stack versions: This page was written for Rust 1.97.0 (edition 2024), Tokio 1.x, Axum 0.8, serde 1.0, sqlx 0.8, clap 4, and Polars 0.46+.
Reviewed by Chris St. John·Last updated Jul 19, 2026