rust/src/test/rustdoc-ui/lint-missing-doc-code-example.rs

85 lines
1.1 KiB
Rust
Raw Normal View History

2019-05-16 11:31:53 -05:00
#![deny(missing_docs)]
#![deny(rustdoc::missing_doc_code_examples)]
2019-05-16 11:31:53 -05:00
//! crate level doc
//! ```
//! println!("hello"):
//! ```
/// doc
///
/// ```
/// println!("hello");
/// ```
2021-02-13 14:45:15 -06:00
pub fn test() {
2019-05-16 11:31:53 -05:00
}
#[allow(missing_docs)]
2021-02-13 14:45:15 -06:00
pub mod module1 { //~ ERROR
2019-05-16 11:31:53 -05:00
}
#[allow(rustdoc::missing_doc_code_examples)]
2019-05-16 11:31:53 -05:00
/// doc
2021-02-13 14:45:15 -06:00
pub mod module2 {
2019-05-16 11:31:53 -05:00
/// doc
pub fn test() {}
}
/// doc
///
/// ```
/// println!("hello");
/// ```
pub mod module3 {
/// doc
2019-05-17 06:39:20 -05:00
//~^ ERROR
2019-05-16 11:31:53 -05:00
pub fn test() {}
}
/// Doc, but no code example and it's fine!
pub const Const: u32 = 0;
/// Doc, but no code example and it's fine!
pub static Static: u32 = 0;
/// Doc, but no code example and it's fine!
pub type Type = u32;
/// Doc
//~^ ERROR
pub struct Struct {
/// Doc, but no code example and it's fine!
pub field: u32,
}
/// Doc
//~^ ERROR
pub enum Enum {
/// Doc, but no code example and it's fine!
X,
}
/// Doc
//~^ ERROR
#[repr(C)]
2021-02-13 14:45:15 -06:00
pub union Union {
/// Doc, but no code example and it's fine!
a: i32,
/// Doc, but no code example and it's fine!
b: f32,
}
2021-02-13 14:45:15 -06:00
#[doc(hidden)]
pub mod foo {
pub fn bar() {}
}
fn babar() {}
mod fofoo {
pub fn tadam() {}
}