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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

102 lines
1.4 KiB
Rust
Raw Normal View History

#![feature(rustdoc_missing_doc_code_examples)]
2019-05-16 18:31:53 +02:00
#![deny(missing_docs)]
#![deny(rustdoc::missing_doc_code_examples)]
2019-05-16 18:31:53 +02:00
//! crate level doc
//! ```
//! println!("hello"):
//! ```
/// doc
///
/// ```
/// println!("hello");
/// ```
2021-02-13 21:45:15 +01:00
pub fn test() {
2019-05-16 18:31:53 +02:00
}
#[allow(missing_docs)]
2021-02-13 21:45:15 +01:00
pub mod module1 { //~ ERROR
2019-05-16 18:31:53 +02:00
}
#[allow(rustdoc::missing_doc_code_examples)]
2019-05-16 18:31:53 +02:00
/// doc
2021-02-13 21:45:15 +01:00
pub mod module2 {
2019-05-16 18:31:53 +02:00
/// doc
pub fn test() {}
}
/// doc
///
/// ```
/// println!("hello");
/// ```
pub mod module3 {
/// doc
2019-05-17 13:39:20 +02:00
//~^ ERROR
2019-05-16 18:31:53 +02: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 21:45:15 +01: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 21:45:15 +01:00
// no code example and it's fine!
impl Clone for Struct {
fn clone(&self) -> Self {
Self { field: self.field }
}
}
2021-02-13 21:45:15 +01:00
/// doc
///
/// ```
/// println!("hello");
/// ```
#[derive(Clone)]
pub struct NiceStruct;
2021-02-13 21:45:15 +01:00
#[doc(hidden)]
pub mod foo {
pub fn bar() {}
}
fn babar() {}
mod fofoo {
pub fn tadam() {}
}