Skip to content

Rustdoc shouldn't lint about missing code examples in derived traits #81775

Closed
@toku-sa-n

Description

@toku-sa-n

I tried this code:

#[deny(missing_doc_code_examples)]
/// Foo struct.
///
/// # Examples
///
/// ```
/// let f = Foo;
/// ```
#[derive(Copy, Clone, Debug, Default, Ord, PartialOrd, Eq, PartialEq, Hash)]
pub struct Foo;

I expected to see this happen: cargo doc succeeds.

Instead, this happened:

 Documenting foo v0.1.0 (/tmp/tmp.uwQktSx1yP/foo)
error: missing code example in this documentation
 --> src/lib.rs:9:16
  |
9 | #[derive(Copy, Clone, Debug, Default, Ord, PartialOrd, Eq, PartialEq, Hash)]
  |                ^^^^^
  |
note: the lint level is defined here
 --> src/lib.rs:1:8
  |
1 | #[deny(missing_doc_code_examples)]
  |        ^^^^^^^^^^^^^^^^^^^^^^^^^

error: missing code example in this documentation
 --> src/lib.rs:9:16
  |
9 | #[derive(Copy, Clone, Debug, Default, Ord, PartialOrd, Eq, PartialEq, Hash)]
  |                ^^^^^

error: missing code example in this documentation
 --> src/lib.rs:9:10
  |
9 | #[derive(Copy, Clone, Debug, Default, Ord, PartialOrd, Eq, PartialEq, Hash)]
  |          ^^^^

error: missing code example in this documentation
 --> src/lib.rs:9:30
  |
9 | #[derive(Copy, Clone, Debug, Default, Ord, PartialOrd, Eq, PartialEq, Hash)]
  |                              ^^^^^^^

error: missing code example in this documentation
 --> src/lib.rs:9:56
  |
9 | #[derive(Copy, Clone, Debug, Default, Ord, PartialOrd, Eq, PartialEq, Hash)]
  |                                                        ^^

error: missing code example in this documentation
 --> src/lib.rs:9:39
  |
9 | #[derive(Copy, Clone, Debug, Default, Ord, PartialOrd, Eq, PartialEq, Hash)]
  |                                       ^^^

error: missing code example in this documentation
 --> src/lib.rs:9:60
  |
9 | #[derive(Copy, Clone, Debug, Default, Ord, PartialOrd, Eq, PartialEq, Hash)]
  |                                                            ^^^^^^^^^

error: missing code example in this documentation
 --> src/lib.rs:9:44
  |
9 | #[derive(Copy, Clone, Debug, Default, Ord, PartialOrd, Eq, PartialEq, Hash)]
  |                                            ^^^^^^^^^^

error: missing code example in this documentation
 --> src/lib.rs:9:23
  |
9 | #[derive(Copy, Clone, Debug, Default, Ord, PartialOrd, Eq, PartialEq, Hash)]
  |                       ^^^^^

error: missing code example in this documentation
 --> src/lib.rs:9:71
  |
9 | #[derive(Copy, Clone, Debug, Default, Ord, PartialOrd, Eq, PartialEq, Hash)]
  |                                                                       ^^^^

error: aborting due to 10 previous errors

error: could not document `foo`

Caused by:
  process didn't exit successfully: `rustdoc --edition=2018 --crate-type lib --crate-name foo src/lib.rs -o /tmp/tmp.uwQktSx1yP/foo/target/doc --error-format=json --json=diagnostic-rendered-ansi -L dependency=/tmp/tmp.uwQktSx1yP/foo/target/debug/deps --crate-version 0.1.0` (exit code: 1)

Meta

rustc --version --verbose:

rustc 1.51.0-nightly (04caa632d 2021-01-30)
binary: rustc
commit-hash: 04caa632dd10c2bf64b69524c7f9c4c30a436877
commit-date: 2021-01-30
host: x86_64-unknown-linux-gnu
release: 1.51.0-nightly
LLVM version: 11.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.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