Skip to content

Commit 0e22ac3

Browse files
committed
---
yaml --- r: 55187 b: refs/heads/snap-stage3 c: 527f771 h: refs/heads/master i: 55185: d60de76 55183: 447472d v: v3
1 parent ccd8197 commit 0e22ac3

File tree

2 files changed

+32
-34
lines changed

2 files changed

+32
-34
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 5f13e9ccc2e3328d4cd8ca49f84e6840dd998346
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 3a5361aec990ff2b07cabf9d9fbfac67f056d97f
4+
refs/heads/snap-stage3: 527f7716b76cf77f57915c663d88f72037e11af4
55
refs/heads/try: 8eb2bab100b42f0ba751552d8eff00eb2134c55a
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/test/run-pass/tag-align-dyn-variants.rs

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,64 +8,62 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// xfail-test
12-
13-
tag a_tag<A,B> {
14-
varA(A);
15-
varB(B);
11+
enum a_tag<A,B> {
12+
varA(A),
13+
varB(B)
1614
}
1715

18-
type t_rec<A,B> = {
16+
struct t_rec<A,B> {
1917
chA: u8,
2018
tA: a_tag<A,B>,
2119
chB: u8,
2220
tB: a_tag<A,B>
23-
};
21+
}
2422

25-
fn mk_rec<A:copy,B:copy>(a: A, b: B) -> t_rec<A,B> {
26-
return { chA:0u8, tA:varA(a), chB:1u8, tB:varB(b) };
23+
fn mk_rec<A:Copy,B:Copy>(a: A, b: B) -> t_rec<A,B> {
24+
return t_rec{ chA:0u8, tA:varA(a), chB:1u8, tB:varB(b) };
2725
}
2826

29-
fn is_aligned<A>(amnt: uint, &&u: A) -> bool {
27+
fn is_aligned<A>(amnt: uint, u: &A) -> bool {
3028
let p = ptr::to_unsafe_ptr(u) as uint;
3129
return (p & (amnt-1u)) == 0u;
3230
}
3331

34-
fn variant_data_is_aligned<A,B>(amnt: uint, &&u: a_tag<A,B>) -> bool {
32+
fn variant_data_is_aligned<A,B>(amnt: uint, u: &a_tag<A,B>) -> bool {
3533
match u {
36-
varA(a) { is_aligned(amnt, a) }
37-
varB(b) { is_aligned(amnt, b) }
34+
&varA(ref a) => is_aligned(amnt, a),
35+
&varB(ref b) => is_aligned(amnt, b)
3836
}
3937
}
4038

4139
pub fn main() {
4240
let x = mk_rec(22u64, 23u64);
43-
assert!(is_aligned(8u, x.tA));
44-
assert!(variant_data_is_aligned(8u, x.tA));
45-
assert!(is_aligned(8u, x.tB));
46-
assert!(variant_data_is_aligned(8u, x.tB));
41+
assert!(is_aligned(8u, &x.tA));
42+
assert!(variant_data_is_aligned(8u, &x.tA));
43+
assert!(is_aligned(8u, &x.tB));
44+
assert!(variant_data_is_aligned(8u, &x.tB));
4745

4846
let x = mk_rec(22u64, 23u32);
49-
assert!(is_aligned(8u, x.tA));
50-
assert!(variant_data_is_aligned(8u, x.tA));
51-
assert!(is_aligned(8u, x.tB));
52-
assert!(variant_data_is_aligned(4u, x.tB));
47+
assert!(is_aligned(8u, &x.tA));
48+
assert!(variant_data_is_aligned(8u, &x.tA));
49+
assert!(is_aligned(8u, &x.tB));
50+
assert!(variant_data_is_aligned(4u, &x.tB));
5351

5452
let x = mk_rec(22u32, 23u64);
55-
assert!(is_aligned(8u, x.tA));
56-
assert!(variant_data_is_aligned(4u, x.tA));
57-
assert!(is_aligned(8u, x.tB));
58-
assert!(variant_data_is_aligned(8u, x.tB));
53+
assert!(is_aligned(8u, &x.tA));
54+
assert!(variant_data_is_aligned(4u, &x.tA));
55+
assert!(is_aligned(8u, &x.tB));
56+
assert!(variant_data_is_aligned(8u, &x.tB));
5957

6058
let x = mk_rec(22u32, 23u32);
61-
assert!(is_aligned(4u, x.tA));
62-
assert!(variant_data_is_aligned(4u, x.tA));
63-
assert!(is_aligned(4u, x.tB));
64-
assert!(variant_data_is_aligned(4u, x.tB));
59+
assert!(is_aligned(4u, &x.tA));
60+
assert!(variant_data_is_aligned(4u, &x.tA));
61+
assert!(is_aligned(4u, &x.tB));
62+
assert!(variant_data_is_aligned(4u, &x.tB));
6563

6664
let x = mk_rec(22f64, 23f64);
67-
assert!(is_aligned(8u, x.tA));
68-
assert!(variant_data_is_aligned(8u, x.tA));
69-
assert!(is_aligned(8u, x.tB));
70-
assert!(variant_data_is_aligned(8u, x.tB));
65+
assert!(is_aligned(8u, &x.tA));
66+
assert!(variant_data_is_aligned(8u, &x.tA));
67+
assert!(is_aligned(8u, &x.tB));
68+
assert!(variant_data_is_aligned(8u, &x.tB));
7169
}

0 commit comments

Comments
 (0)