about summary refs log tree commit diff
path: root/src/tools/clippy/tests/ui/mixed_attributes_style.rs
blob: 93ab9392cf8bd52de7f01d00bb78a0a9cd3d41b8 (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
//@aux-build:proc_macro_attr.rs
//@compile-flags: --test --cfg dummy_cfg
#![feature(custom_inner_attributes)]
#![warn(clippy::mixed_attributes_style)]
#![allow(clippy::duplicated_attributes)]

#[macro_use]
extern crate proc_macro_attr;

#[allow(unused)] //~ ERROR: item has both inner and outer attributes
fn foo1() {
    #![allow(unused)]
}

#[allow(unused)]
#[allow(unused)]
fn foo2() {}

fn foo3() {
    #![allow(unused)]
    #![allow(unused)]
}

/// linux
//~^ ERROR: item has both inner and outer attributes
fn foo4() {
    //! windows
}

/// linux
/// windows
fn foo5() {}

fn foo6() {
    //! linux
    //! windows
}

#[allow(unused)] //~ ERROR: item has both inner and outer attributes
mod bar {
    #![allow(unused)]
}

fn main() {
    // test code goes here
}

// issue #12435
#[cfg(test)]
mod tests {
    //! Module doc, don't lint
}
#[allow(unused)]
mod baz {
    //! Module doc, don't lint
    const FOO: u8 = 0;
}
/// Module doc, don't lint
mod quz {
    #![allow(unused)]
}

mod issue_12530 {
    // don't lint different attributes entirely
    #[cfg(test)]
    mod tests {
        #![allow(clippy::unreadable_literal)]

        #[allow(dead_code)] //~ ERROR: item has both inner and outer attributes
        mod inner_mod {
            #![allow(dead_code)]
        }
    }
    #[cfg(dummy_cfg)]
    mod another_mod {
        #![allow(clippy::question_mark)]
    }
    /// Nested mod
    mod nested_mod {
        #[allow(dead_code)] //~ ERROR: item has both inner and outer attributes
        mod inner_mod {
            #![allow(dead_code)]
        }
    }
    /// Nested mod
    //~^ ERROR: item has both inner and outer attributes
    #[allow(unused)]
    mod nest_mod_2 {
        #![allow(unused)]

        #[allow(dead_code)] //~ ERROR: item has both inner and outer attributes
        mod inner_mod {
            #![allow(dead_code)]
        }
    }
    // Different path symbols - Known FN
    #[dummy]
    fn use_dummy() {
        #![proc_macro_attr::dummy]
    }
}