summaryrefslogtreecommitdiffstats
path: root/src/test/ui/attributes/item-attributes.rs
blob: c6bf6c656027753a7ccf88907ed7623904aef6bb (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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
// These are attributes of the implicit crate. Really this just needs to parse
// for completeness since .rs files linked from .rc files support this
// notation to specify their module's attributes

// check-pass

#![feature(rustc_attrs)]
#![rustc_dummy = "val"]
#![rustc_dummy = "val"]
#![rustc_dummy]
#![rustc_dummy(attr5)]

// These are attributes of the following mod
#[rustc_dummy = "val"]
#[rustc_dummy = "val"]
mod test_first_item_in_file_mod {}

mod test_single_attr_outer {
    #[rustc_dummy = "val"]
    pub static X: isize = 10;

    #[rustc_dummy = "val"]
    pub fn f() {}

    #[rustc_dummy = "val"]
    pub mod mod1 {}

    pub mod rustrt {
        #[rustc_dummy = "val"]
        extern "C" {}
    }
}

mod test_multi_attr_outer {
    #[rustc_dummy = "val"]
    #[rustc_dummy = "val"]
    pub static X: isize = 10;

    #[rustc_dummy = "val"]
    #[rustc_dummy = "val"]
    pub fn f() {}

    #[rustc_dummy = "val"]
    #[rustc_dummy = "val"]
    pub mod mod1 {}

    pub mod rustrt {
        #[rustc_dummy = "val"]
        #[rustc_dummy = "val"]
        extern "C" {}
    }

    #[rustc_dummy = "val"]
    #[rustc_dummy = "val"]
    struct T {
        x: isize,
    }
}

mod test_stmt_single_attr_outer {
    pub fn f() {
        #[rustc_dummy = "val"]
        static X: isize = 10;

        #[rustc_dummy = "val"]
        fn f() {}

        #[rustc_dummy = "val"]
        mod mod1 {}

        mod rustrt {
            #[rustc_dummy = "val"]
            extern "C" {}
        }
    }
}

mod test_stmt_multi_attr_outer {
    pub fn f() {
        #[rustc_dummy = "val"]
        #[rustc_dummy = "val"]
        static X: isize = 10;

        #[rustc_dummy = "val"]
        #[rustc_dummy = "val"]
        fn f() {}

        #[rustc_dummy = "val"]
        #[rustc_dummy = "val"]
        mod mod1 {}

        mod rustrt {
            #[rustc_dummy = "val"]
            #[rustc_dummy = "val"]
            extern "C" {}
        }
    }
}

mod test_attr_inner {
    pub mod m {
        // This is an attribute of mod m
        #![rustc_dummy = "val"]
    }
}

mod test_attr_inner_then_outer {
    pub mod m {
        // This is an attribute of mod m
        #![rustc_dummy = "val"]
        // This is an attribute of fn f
        #[rustc_dummy = "val"]
        fn f() {}
    }
}

mod test_attr_inner_then_outer_multi {
    pub mod m {
        // This is an attribute of mod m
        #![rustc_dummy = "val"]
        #![rustc_dummy = "val"]
        // This is an attribute of fn f
        #[rustc_dummy = "val"]
        #[rustc_dummy = "val"]
        fn f() {}
    }
}

mod test_distinguish_syntax_ext {
    pub fn f() {
        format!("test{}", "s");
        #[rustc_dummy = "val"]
        fn g() {}
    }
}

mod test_other_forms {
    #[rustc_dummy]
    #[rustc_dummy(word)]
    #[rustc_dummy(attr(word))]
    #[rustc_dummy(key1 = "val", key2 = "val", attr)]
    pub fn f() {}
}

mod test_foreign_items {
    pub mod rustrt {
        extern "C" {
            #![rustc_dummy]

            #[rustc_dummy]
            fn rust_get_test_int() -> u32;
        }
    }
}

// FIXME(#623): - these aren't supported yet
/*mod test_literals {
    #![str = "s"]
    #![char = 'c']
    #![isize = 100]
    #![usize = 100_usize]
    #![mach_int = 100u32]
    #![float = 1.0]
    #![mach_float = 1.0f32]
    #![nil = ()]
    #![bool = true]
    mod m {}
}*/

fn test_fn_inner() {
    #![rustc_dummy]
}

fn main() {}