summary refs log tree commit diff
path: root/src/test/compile-fail/lint-missing-doc.rs
blob: 2350ca68b9747045693072c6605c2137b91a0b47 (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
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// When denying at the crate level, be sure to not get random warnings from the
// injected intrinsics by the compiler.
#[deny(missing_doc)];

struct Foo {
    a: int,
    priv b: int,
    pub c: int, // doesn't matter, Foo is private
}

pub struct PubFoo { //~ ERROR: missing documentation
    a: int,      //~ ERROR: missing documentation
    priv b: int,
    pub c: int,  //~ ERROR: missing documentation
}

#[allow(missing_doc)]
pub struct PubFoo2 {
    a: int,
    pub c: int,
}

/// dox
pub fn foo() {}
pub fn foo2() {} //~ ERROR: missing documentation
fn foo3() {}
#[allow(missing_doc)] pub fn foo4() {}

/// dox
pub trait A {}
trait B {}
pub trait C {} //~ ERROR: missing documentation
#[allow(missing_doc)] pub trait D {}

trait Bar {
    /// dox
    pub fn foo();
    fn foo2(); //~ ERROR: missing documentation
    pub fn foo3(); //~ ERROR: missing documentation
}

impl Foo {
    pub fn foo() {} //~ ERROR: missing documentation
    /// dox
    pub fn foo1() {}
    fn foo2() {}
    #[allow(missing_doc)] pub fn foo3() {}
}

#[allow(missing_doc)]
trait F {
    pub fn a();
    fn b(&self);
}

// should need to redefine documentation for implementations of traits
impl F for Foo {
    pub fn a() {}
    fn b(&self) {}
}

// It sure is nice if doc(hidden) implies allow(missing_doc), and that it
// applies recursively
#[doc(hidden)]
mod a {
    pub fn baz() {}
    pub mod b {
        pub fn baz() {}
    }
}

#[doc(hidden)]
pub fn baz() {}

fn main() {}