Skip to content

missing_errors_doc and missing_panics_doc for private functions #11742

@Kriskras99

Description

@Kriskras99

What it does

Applies missing_errors_doc and missing_panics_doc to private functions.
This could be done in three ways:

  1. Add a configuration option on missing_errors_doc and missing_panics_doc
  2. Add a configuration option on missing_docs_in_private_items
  3. Create two new lints missing_errors_doc_in_private_fn and missing_panics_doc_in_private_fn

Advantage

  • Documentation is good, especially in large complicated applications

Drawbacks

  • Noise if enabled for an existing application
  • Can cause useless documentation like Will error if something goes wrong

Example

/// Does complicated calculation x
fn something_complicated(n: usize) -> Result<usize, String> {
    if (n % 2) == 0 {
        Ok(n*5)
    } else {
        Err(format!("{n} is not divisible by 2!"))
    }
}

Could be written as:

/// Does complicated calculation x
/// 
/// # Errors
/// Will error if n is not divisible by 2
fn something_complicated(n: usize) -> Result<usize, String> {
    if (n % 2) == 0 {
        Ok(n*5)
    } else {
        Err(format!("{n} is not divisible by 2!"))
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintArea: New lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions