Skip to content

unclear behaviour of missing_doc_code_examples #60664

Closed
@Geal

Description

@Geal

Hello,
consider this code example:

#![deny(missing_docs)]
#![deny(missing_doc_code_examples)]
//! crate level doc
//! ```
//! println!("hello"):
//! ```


/// doc
///
/// ```
/// println!("hello");
/// ```
fn test() {
}

// the allow() here works as expected, but missing_doc_code_examples still complains
#[allow(missing_docs)]
mod module1 {

  fn test() {}
}

// here we want some docs but no code examples, but missing_doc_code_examples still complains
#[allow(missing_doc_code_examples)]
/// doc
mod module2 {

  /// doc
  fn test() {}
}

/// doc
///
/// ```
/// println!("hello");
/// ```
mod module3 {

  // here we want some code examples but missing_doc_code_examples does not complain
  /// doc
  fn test() {}
}

Here I would expect the following behaviour when running cargo doc:

  • module1 has allow(missing_docs) so missing_doc_code_examples should be silent
  • module2 has allow(missing_doc_code_examples) yet we still get errors for missing docs on module2, I think we should not
  • module3 has a code example, but module3::test does not, we should get an error for the missing example on module3::test

cc @GuillaumeGomez

Metadata

Metadata

Labels

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