]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/issue-29663.rs
Do not show `::constructor` on tuple struct diagnostics
[rust.git] / src / test / run-pass / issue-29663.rs
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 // write_volatile causes an LLVM assert with composite types
12
13 #![feature(volatile)]
14 use std::ptr::{read_volatile, write_volatile};
15
16 #[derive(Debug, Eq, PartialEq)]
17 struct A(u32);
18 #[derive(Debug, Eq, PartialEq)]
19 struct B(u64);
20 #[derive(Debug, Eq, PartialEq)]
21 struct C(u32, u32);
22 #[derive(Debug, Eq, PartialEq)]
23 struct D(u64, u64);
24 #[derive(Debug, Eq, PartialEq)]
25 struct E([u64; 32]);
26
27 fn main() {
28     unsafe {
29         let mut x: u32 = 0;
30         write_volatile(&mut x, 1);
31         assert_eq!(read_volatile(&x), 1);
32         assert_eq!(x, 1);
33
34         let mut x: u64 = 0;
35         write_volatile(&mut x, 1);
36         assert_eq!(read_volatile(&x), 1);
37         assert_eq!(x, 1);
38
39         let mut x = A(0);
40         write_volatile(&mut x, A(1));
41         assert_eq!(read_volatile(&x), A(1));
42         assert_eq!(x, A(1));
43
44         let mut x = B(0);
45         write_volatile(&mut x, B(1));
46         assert_eq!(read_volatile(&x), B(1));
47         assert_eq!(x, B(1));
48
49         let mut x = C(0, 0);
50         write_volatile(&mut x, C(1, 1));
51         assert_eq!(read_volatile(&x), C(1, 1));
52         assert_eq!(x, C(1, 1));
53
54         let mut x = D(0, 0);
55         write_volatile(&mut x, D(1, 1));
56         assert_eq!(read_volatile(&x), D(1, 1));
57         assert_eq!(x, D(1, 1));
58
59         let mut x = E([0; 32]);
60         write_volatile(&mut x, E([1; 32]));
61         assert_eq!(read_volatile(&x), E([1; 32]));
62         assert_eq!(x, E([1; 32]));
63     }
64 }