]> git.proxmox.com Git - rustc.git/blob - tests/ui/mir/mir_struct_with_assoc_ty.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / ui / mir / mir_struct_with_assoc_ty.rs
1 // run-pass
2 use std::marker::PhantomData;
3
4 pub trait DataBind {
5 type Data;
6 }
7
8 impl<T> DataBind for Global<T> {
9 type Data = T;
10 }
11
12 pub struct Global<T>(PhantomData<T>);
13
14 pub struct Data {
15 pub offsets: <Global<[u32; 2]> as DataBind>::Data,
16 }
17
18 fn create_data() -> Data {
19 let mut d = Data { offsets: [1, 2] };
20 d.offsets[0] = 3;
21 d
22 }
23
24
25 fn main() {
26 let d = create_data();
27 assert_eq!(d.offsets[0], 3);
28 assert_eq!(d.offsets[1], 2);
29 }