about summary refs log tree commit diff
path: root/src/test/rustdoc-ui/lint-missing-doc-code-example.rs
blob: ebe7a242211bf50aa9dbbba4e00709068516a0b7 (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
#![deny(missing_docs)]
#![deny(missing_doc_code_examples)]

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


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

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

#[allow(missing_doc_code_examples)]
/// doc
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)]
union Union {
    /// Doc, but no code example and it's fine!
    a: i32,
    /// Doc, but no code example and it's fine!
    b: f32,
}