]> git.lizzy.rs Git - rust.git/blob - src/test/ui/self/objects-owned-object-owned-method.rs
Rollup merge of #101388 - compiler-errors:issue-101376, r=fee1-dead
[rust.git] / src / test / ui / self / 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 trait FooTrait {
7     fn foo(self: Box<Self>) -> usize;
8 }
9
10 struct BarStruct {
11     x: usize
12 }
13
14 impl FooTrait for BarStruct {
15     fn foo(self: Box<BarStruct>) -> usize {
16         self.x
17     }
18 }
19
20 pub fn main() {
21     let foo = Box::new(BarStruct{ x: 22 }) as Box<dyn FooTrait>;
22     assert_eq!(22, foo.foo());
23 }