What does the warning "doc comment not used by rustdoc" mean and how do I fix it?

Viewed 1560

The following code produces a warning when compiled:

pub fn add_source_path(request: &mut Request) -> IronResult<Response> {
/// Adds source path to the database.
///
/// This function saves provided absolute path (on the server) to the database
/// and goes over all jpeg files recursively in order to add them to DB.

let params = request.get_ref::<Params>().unwrap();

let path = &params["path"];

This is the warning:

warning: doc comment not used by rustdoc
--> src/crawler.rs:64:2
   |
64 |  /// Adds source path to the database.
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: #[warn(unused_doc_comment)] on by default

What exactly does this warning mean and how to fix it?

1 Answers

Comments starting with /// are used to generate documentation. Those documentation comments go before the function they document. Quoting The Rust Programming Language:

Place documentation comments just before the item they’re documenting.

/// Adds source path to the database.
///
/// This function saves provided absolute path (on the server) to the database
/// and goes over all jpeg files recursively in order to add them to DB.
pub fn add_source_path(request: &mut Request) -> IronResult<Response> {
    // ...
}
Related