2 #![allow(stable_features)]
3 #![allow(type_alias_bounds)]
5 // As dst-tuple.rs, but the unsized field is the only field in the tuple.
8 #![feature(unsized_tuple_coercion)]
10 type Fat<T: ?Sized> = (T,);
13 fn foo(x: &Fat<[isize]>) {
15 assert_eq!(x.0.len(), 3);
17 assert_eq!(x.0[1], 2);
20 fn foo2<T:ToBar>(x: &Fat<[T]>) {
23 assert_eq!(x.0.len(), 3);
24 assert_eq!(y[0].to_bar(), bar);
25 assert_eq!(x.0[1].to_bar(), bar);
28 #[derive(Copy, Clone, PartialEq, Eq, Debug)]
32 fn to_bar(&self) -> Bar;
36 fn to_bar(&self) -> Bar {
42 // With a vec of ints.
43 let f1 = ([1, 2, 3],);
47 let f3: &Fat<[isize]> = f2;
49 let f4: &Fat<[isize]> = &f1;
51 let f5: &Fat<[isize]> = &([1, 2, 3],);
54 // With a vec of Bars.
56 let f1 = ([bar, bar, bar],);
60 let f3: &Fat<[Bar]> = f2;
62 let f4: &Fat<[Bar]> = &f1;
64 let f5: &Fat<[Bar]> = &([bar, bar, bar],);
68 let f5: &mut Fat<[isize]> = &mut ([1, 2, 3],);
70 assert_eq!(f5.0[0], 1);
71 assert_eq!(f5.0[1], 34);
72 assert_eq!(f5.0[2], 3);
75 let f5: &Fat<[isize]> = &([],);
76 assert!(f5.0.is_empty());
77 let f5: &Fat<[Bar]> = &([],);
78 assert!(f5.0.is_empty());