]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/item-attributes.rs
Auto merge of #54265 - arielb1:civilize-proc-macros, r=alexcrichton
[rust.git] / src / test / run-pass / item-attributes.rs
1 // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 #![allow(non_camel_case_types)]
12 #![allow(non_upper_case_globals)]
13 #![allow(unused_attributes)]
14 #![allow(dead_code)]
15 #![allow(unknown_lints)]
16 // These are attributes of the implicit crate. Really this just needs to parse
17 // for completeness since .rs files linked from .rc files support this
18 // notation to specify their module's attributes
19
20 #![feature(custom_attribute)]
21 #![allow(unused_attribute)]
22 #![attr1 = "val"]
23 #![attr2 = "val"]
24 #![attr3]
25 #![attr4(attr5)]
26
27 #![crate_id="foobar#0.1"]
28
29 // These are attributes of the following mod
30 #[attr1 = "val"]
31 #[attr2 = "val"]
32 mod test_first_item_in_file_mod {}
33
34 mod test_single_attr_outer {
35     #[attr = "val"]
36     pub static x: isize = 10;
37
38     #[attr = "val"]
39     pub fn f() { }
40
41     #[attr = "val"]
42     pub mod mod1 {}
43
44     pub mod rustrt {
45         #[attr = "val"]
46         extern {}
47     }
48 }
49
50 mod test_multi_attr_outer {
51     #[attr1 = "val"]
52     #[attr2 = "val"]
53     pub static x: isize = 10;
54
55     #[attr1 = "val"]
56     #[attr2 = "val"]
57     pub fn f() { }
58
59     #[attr1 = "val"]
60     #[attr2 = "val"]
61     pub mod mod1 {}
62
63     pub mod rustrt {
64         #[attr1 = "val"]
65         #[attr2 = "val"]
66         extern {}
67     }
68
69     #[attr1 = "val"]
70     #[attr2 = "val"]
71     struct t {x: isize}
72 }
73
74 mod test_stmt_single_attr_outer {
75     pub fn f() {
76         #[attr = "val"]
77         static x: isize = 10;
78
79         #[attr = "val"]
80         fn f() { }
81
82         #[attr = "val"]
83         mod mod1 {
84         }
85
86         mod rustrt {
87             #[attr = "val"]
88             extern {
89             }
90         }
91     }
92 }
93
94 mod test_stmt_multi_attr_outer {
95     pub fn f() {
96
97         #[attr1 = "val"]
98         #[attr2 = "val"]
99         static x: isize = 10;
100
101         #[attr1 = "val"]
102         #[attr2 = "val"]
103         fn f() { }
104
105         #[attr1 = "val"]
106         #[attr2 = "val"]
107         mod mod1 {
108         }
109
110         mod rustrt {
111             #[attr1 = "val"]
112             #[attr2 = "val"]
113             extern {
114             }
115         }
116     }
117 }
118
119 mod test_attr_inner {
120     pub mod m {
121         // This is an attribute of mod m
122         #![attr = "val"]
123     }
124 }
125
126 mod test_attr_inner_then_outer {
127     pub mod m {
128         // This is an attribute of mod m
129         #![attr = "val"]
130         // This is an attribute of fn f
131         #[attr = "val"]
132         fn f() { }
133     }
134 }
135
136 mod test_attr_inner_then_outer_multi {
137     pub mod m {
138         // This is an attribute of mod m
139         #![attr1 = "val"]
140         #![attr2 = "val"]
141         // This is an attribute of fn f
142         #[attr1 = "val"]
143         #[attr2 = "val"]
144         fn f() { }
145     }
146 }
147
148 mod test_distinguish_syntax_ext {
149     pub fn f() {
150         format!("test{}", "s");
151         #[attr = "val"]
152         fn g() { }
153     }
154 }
155
156 mod test_other_forms {
157     #[attr]
158     #[attr(word)]
159     #[attr(attr(word))]
160     #[attr(key1 = "val", key2 = "val", attr)]
161     pub fn f() { }
162 }
163
164 mod test_foreign_items {
165     pub mod rustrt {
166         extern {
167             #![attr]
168
169             #[attr]
170             fn rust_get_test_int() -> u32;
171         }
172     }
173 }
174
175
176 // FIXME #623 - these aren't supported yet
177 /*mod test_literals {
178     #![str = "s"]
179     #![char = 'c']
180     #![isize = 100]
181     #![usize = 100_usize]
182     #![mach_int = 100u32]
183     #![float = 1.0]
184     #![mach_float = 1.0f32]
185     #![nil = ()]
186     #![bool = true]
187     mod m {}
188 }*/
189
190 fn test_fn_inner() {
191     #![inner_fn_attr]
192 }
193
194 pub fn main() { }