summaryrefslogtreecommitdiffstats
path: root/src/test/rustdoc-ui/lint-missing-doc-code-example.rs
blob: 40f35728d79b0ba2f8cc09db394258119f96d54d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#![feature(rustdoc_missing_doc_code_examples)]
#![deny(missing_docs)]
#![deny(rustdoc::missing_doc_code_examples)]

//! crate level doc
//! ```
//! println!("hello"):
//! ```


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

#[allow(missing_docs)]
pub mod module1 { //~ ERROR
}

#[allow(rustdoc::missing_doc_code_examples)]
/// doc
pub mod module2 {

  /// doc
  pub fn test() {}
}

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

  /// doc
  //~^ ERROR
  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)]
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,
}

// no code example and it's fine!
impl Clone for Struct {
    fn clone(&self) -> Self {
        Self { field: self.field }
    }
}



/// doc
///
/// ```
/// println!("hello");
/// ```
#[derive(Clone)]
pub struct NiceStruct;

#[doc(hidden)]
pub mod foo {
    pub fn bar() {}
}

fn babar() {}


mod fofoo {
    pub fn tadam() {}
}