]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/item-attributes.rs
Remove the in-tree `flate` crate
[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 // These are attributes of the implicit crate. Really this just needs to parse
12 // for completeness since .rs files linked from .rc files support this
13 // notation to specify their module's attributes
14
15
16 #![feature(custom_attribute, libc)]
17 #![allow(unused_attribute)]
18 #![attr1 = "val"]
19 #![attr2 = "val"]
20 #![attr3]
21 #![attr4(attr5)]
22
23 #![crate_id="foobar#0.1"]
24
25 // These are attributes of the following mod
26 #[attr1 = "val"]
27 #[attr2 = "val"]
28 mod test_first_item_in_file_mod {}
29
30 mod test_single_attr_outer {
31     #[attr = "val"]
32     pub static x: isize = 10;
33
34     #[attr = "val"]
35     pub fn f() { }
36
37     #[attr = "val"]
38     pub mod mod1 {}
39
40     pub mod rustrt {
41         #[attr = "val"]
42         extern {}
43     }
44 }
45
46 mod test_multi_attr_outer {
47     #[attr1 = "val"]
48     #[attr2 = "val"]
49     pub static x: isize = 10;
50
51     #[attr1 = "val"]
52     #[attr2 = "val"]
53     pub fn f() { }
54
55     #[attr1 = "val"]
56     #[attr2 = "val"]
57     pub mod mod1 {}
58
59     pub mod rustrt {
60         #[attr1 = "val"]
61         #[attr2 = "val"]
62         extern {}
63     }
64
65     #[attr1 = "val"]
66     #[attr2 = "val"]
67     struct t {x: isize}
68 }
69
70 mod test_stmt_single_attr_outer {
71     pub fn f() {
72         #[attr = "val"]
73         static x: isize = 10;
74
75         #[attr = "val"]
76         fn f() { }
77
78         #[attr = "val"]
79         mod mod1 {
80         }
81
82         mod rustrt {
83             #[attr = "val"]
84             extern {
85             }
86         }
87     }
88 }
89
90 mod test_stmt_multi_attr_outer {
91     pub fn f() {
92
93         #[attr1 = "val"]
94         #[attr2 = "val"]
95         static x: isize = 10;
96
97         #[attr1 = "val"]
98         #[attr2 = "val"]
99         fn f() { }
100
101         #[attr1 = "val"]
102         #[attr2 = "val"]
103         mod mod1 {
104         }
105
106         mod rustrt {
107             #[attr1 = "val"]
108             #[attr2 = "val"]
109             extern {
110             }
111         }
112     }
113 }
114
115 mod test_attr_inner {
116     pub mod m {
117         // This is an attribute of mod m
118         #![attr = "val"]
119     }
120 }
121
122 mod test_attr_inner_then_outer {
123     pub mod m {
124         // This is an attribute of mod m
125         #![attr = "val"]
126         // This is an attribute of fn f
127         #[attr = "val"]
128         fn f() { }
129     }
130 }
131
132 mod test_attr_inner_then_outer_multi {
133     pub mod m {
134         // This is an attribute of mod m
135         #![attr1 = "val"]
136         #![attr2 = "val"]
137         // This is an attribute of fn f
138         #[attr1 = "val"]
139         #[attr2 = "val"]
140         fn f() { }
141     }
142 }
143
144 mod test_distinguish_syntax_ext {
145     pub fn f() {
146         format!("test{}", "s");
147         #[attr = "val"]
148         fn g() { }
149     }
150 }
151
152 mod test_other_forms {
153     #[attr]
154     #[attr(word)]
155     #[attr(attr(word))]
156     #[attr(key1 = "val", key2 = "val", attr)]
157     pub fn f() { }
158 }
159
160 mod test_foreign_items {
161     pub mod rustrt {
162         extern crate libc;
163
164         extern {
165             #![attr]
166
167             #[attr]
168             fn rust_get_test_int() -> libc::intptr_t;
169         }
170     }
171 }
172
173
174 // FIXME #623 - these aren't supported yet
175 /*mod test_literals {
176     #![str = "s"]
177     #![char = 'c']
178     #![isize = 100]
179     #![usize = 100_usize]
180     #![mach_int = 100u32]
181     #![float = 1.0]
182     #![mach_float = 1.0f32]
183     #![nil = ()]
184     #![bool = true]
185     mod m {}
186 }*/
187
188 fn test_fn_inner() {
189     #![inner_fn_attr]
190 }
191
192 pub fn main() { }