1 // Copyright 2014 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.
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.
11 // pretty-expanded FIXME #23616
13 #![allow(unknown_features)]
14 #![feature(box_syntax)]
16 struct Fat<T: ?Sized> {
22 #[derive(Copy, PartialEq, Eq)]
25 #[derive(Copy, PartialEq, Eq)]
31 fn to_bar(&self) -> Bar;
32 fn to_val(&self) -> int;
36 fn to_bar(&self) -> Bar {
39 fn to_val(&self) -> int {
44 fn to_bar(&self) -> Bar {
47 fn to_val(&self) -> int {
53 fn foo(x: &Fat<ToBar>) {
55 assert!(x.f2 == "some str");
56 assert!(x.ptr.to_bar() == Bar);
57 assert!(x.ptr.to_val() == 42);
60 assert!(y.to_bar() == Bar);
61 assert!(y.to_val() == 42);
65 assert!(x.to_bar() == Bar);
66 assert!(x.to_val() == 42);
69 fn baz(x: &Fat<Fat<ToBar>>) {
71 assert!(x.f2 == "some str");
72 assert!(x.ptr.f1 == 8);
73 assert!(x.ptr.f2 == "deep str");
74 assert!(x.ptr.ptr.to_bar() == Bar);
75 assert!(x.ptr.ptr.to_val() == 42);
78 assert!(y.to_bar() == Bar);
79 assert!(y.to_val() == 42);
84 let f1 = Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} };
88 let f3: &Fat<ToBar> = f2;
90 let f4: &Fat<ToBar> = &f1;
92 let f5: &Fat<ToBar> = &Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} };
96 let f6: &Fat<ToBar> = &Fat { f1: 5, f2: "some str", ptr: Bar };
97 assert!(f6.ptr.to_bar() == Bar);
101 // FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
102 let f7: Box<ToBar> = Box::new(Bar1 {f :42});
107 Fat { f1: 5, f2: "some str", ptr: Fat { f1: 8, f2: "deep str", ptr: Bar1 {f :42}} };
111 let f3: &Fat<Fat<ToBar>> = f2;
113 let f4: &Fat<Fat<ToBar>> = &f1;
115 let f5: &Fat<Fat<ToBar>> =
116 &Fat { f1: 5, f2: "some str", ptr: Fat { f1: 8, f2: "deep str", ptr: Bar1 {f :42}} };