Skip to content

rustdoc::missing_doc_code_examples inconsistent with Rust API Guidelines #87858

Open

Description

When the rustdoc::missing_doc_code_examples lint is enabled, rustdoc reports that doc comments which reference another example is missing an example. This is inconsistent with the Rust API Guidelines.

A link to an applicable example on another item may be sufficient. For example if exactly one function uses a particular type, it may be appropriate to write a single example on either the function or the type and link to it from the other.

Given the following:

/// Does the thing.
///
/// # Example
///
/// See [`crate::bar`].
pub fn foo() {}

I expected to see no warnings.

Instead, this happened:

warning: missing code example in this documentation
45 | / /// Does the thing.
46 | | ///
47 | | /// # Example
48 | | ///
...  |
54 | | ///
   | |__________________________^

Meta

rustc --version --verbose:

rustc 1.56.0-nightly (a6ece5615 2021-08-03)
binary: rustc
commit-hash: a6ece56152d8eb11e049e9fcce147b2859e12c92
commit-date: 2021-08-03
host: x86_64-unknown-linux-gnu
release: 1.56.0-nightly
LLVM version: 12.0.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-lintArea: Lints (warnings about flaws in source code) such as unused_mut.C-discussionCategory: Discussion or questions that doesn't represent real issues.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions