]> git.proxmox.com Git - rustc.git/blame - src/test/ui/self/objects-owned-object-owned-method.rs
New upstream version 1.66.0+dfsg1
[rustc.git] / src / test / ui / self / objects-owned-object-owned-method.rs
CommitLineData
416331ca 1// run-pass
1a4d82fc
JJ
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
970d7e83 6trait FooTrait {
c34b1796 7 fn foo(self: Box<Self>) -> usize;
970d7e83
LB
8}
9
10struct BarStruct {
c34b1796 11 x: usize
970d7e83
LB
12}
13
14impl FooTrait for BarStruct {
c34b1796 15 fn foo(self: Box<BarStruct>) -> usize {
970d7e83
LB
16 self.x
17 }
18}
19
223e47cc 20pub fn main() {
c295e0f8 21 let foo = Box::new(BarStruct{ x: 22 }) as Box<dyn FooTrait>;
1a4d82fc 22 assert_eq!(22, foo.foo());
223e47cc 23}