]> git.proxmox.com Git - rustc.git/blob - tests/rustdoc/issue-33302.rs
New upstream version 1.69.0+dfsg1
[rustc.git] / tests / rustdoc / issue-33302.rs
1 // Ensure constant and array length values are not taken from source
2 // code, which wreaks havoc with macros.
3
4 macro_rules! make {
5 ($n:expr) => {
6 pub struct S;
7
8 // @has issue_33302/constant.CST.html \
9 // '//pre[@class="rust item-decl"]' 'pub const CST: i32'
10 pub const CST: i32 = ($n * $n);
11 // @has issue_33302/static.ST.html \
12 // '//pre[@class="rust item-decl"]' 'pub static ST: i32'
13 pub static ST: i32 = ($n * $n);
14
15 pub trait T<X> {
16 fn ignore(_: &X) {}
17 const C: X;
18 // @has issue_33302/trait.T.html \
19 // '//pre[@class="rust item-decl"]' 'const D: i32'
20 // @has - '//*[@id="associatedconstant.D"]' 'const D: i32'
21 const D: i32 = ($n * $n);
22 }
23
24 // @has issue_33302/struct.S.html \
25 // '//*[@class="impl"]' 'impl T<[i32; 16]> for S'
26 // @has - '//*[@id="associatedconstant.C"]' 'const C: [i32; 16]'
27 // @has - '//*[@id="associatedconstant.D"]' 'const D: i32'
28 impl T<[i32; ($n * $n)]> for S {
29 const C: [i32; ($n * $n)] = [0; ($n * $n)];
30 }
31
32 // @has issue_33302/struct.S.html \
33 // '//*[@class="impl"]' 'impl T<[i32; 16]> for S'
34 // @has - '//*[@id="associatedconstant.C-1"]' 'const C: (i32,)'
35 // @has - '//*[@id="associatedconstant.D-1"]' 'const D: i32'
36 impl T<(i32,)> for S {
37 const C: (i32,) = ($n,);
38 }
39
40 // @has issue_33302/struct.S.html \
41 // '//*[@class="impl"]' 'impl T<(i32, i32)> for S'
42 // @has - '//*[@id="associatedconstant.C-2"]' 'const C: (i32, i32)'
43 // @has - '//*[@id="associatedconstant.D-2"]' 'const D: i32'
44 impl T<(i32, i32)> for S {
45 const C: (i32, i32) = ($n, $n);
46 const D: i32 = ($n / $n);
47 }
48 };
49 }
50
51 make!(4);