]> git.proxmox.com Git - rustc.git/blob - src/test/ui/objects-owned-object-owned-method.rs
New upstream version 1.40.0+dfsg1
[rustc.git] / src / test / ui / objects-owned-object-owned-method.rs
1 // run-pass
2 // Test invoked `&self` methods on owned objects where the values
3 // closed over contain managed values. This implies that the boxes
4 // will have headers that must be skipped over.
5
6 #![feature(box_syntax)]
7
8 trait FooTrait {
9 fn foo(self: Box<Self>) -> usize;
10 }
11
12 struct BarStruct {
13 x: usize
14 }
15
16 impl FooTrait for BarStruct {
17 fn foo(self: Box<BarStruct>) -> usize {
18 self.x
19 }
20 }
21
22 pub fn main() {
23 let foo = box BarStruct{ x: 22 } as Box<dyn FooTrait>;
24 assert_eq!(22, foo.foo());
25 }