]>
Commit | Line | Data |
---|---|---|
a7813a04 XL |
1 | // Copyright 2016 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 | // Ensure constant and array length values are not taken from source | |
12 | // code, which wreaks havoc with macros. | |
13 | ||
14 | #![feature(associated_consts)] | |
15 | ||
16 | macro_rules! make { | |
17 | ($n:expr) => { | |
18 | pub struct S; | |
19 | ||
20 | // @has issue_33302/constant.CST.html \ | |
21 | // '//pre[@class="rust const"]' 'pub const CST: i32 = 4 * 4' | |
22 | pub const CST: i32 = ($n * $n); | |
23 | // @has issue_33302/static.ST.html \ | |
24 | // '//pre[@class="rust static"]' 'pub static ST: i32 = 4 * 4' | |
25 | pub static ST: i32 = ($n * $n); | |
26 | ||
27 | pub trait T<X> { | |
28 | fn ignore(_: &X) {} | |
29 | const C: X; | |
30 | // @has issue_33302/trait.T.html \ | |
31 | // '//*[@class="rust trait"]' 'const D: i32 = 4 * 4;' | |
32 | // @has - '//*[@id="associatedconstant.D"]' 'const D: i32 = 4 * 4' | |
33 | const D: i32 = ($n * $n); | |
34 | } | |
35 | ||
36 | // @has issue_33302/struct.S.html \ | |
5bcae85e SL |
37 | // '//h3[@class="impl"]' 'impl T<[i32; 16]> for S' |
38 | // @has - '//*[@id="associatedconstant.C"]' 'const C: [i32; 16] = [0; 4 * 4]' | |
a7813a04 XL |
39 | // @has - '//*[@id="associatedconstant.D"]' 'const D: i32 = 4 * 4' |
40 | impl T<[i32; ($n * $n)]> for S { | |
41 | const C: [i32; ($n * $n)] = [0; ($n * $n)]; | |
42 | } | |
43 | } | |
44 | } | |
45 | ||
46 | make!(4); |