]> git.lizzy.rs Git - rust.git/blob - src/test/ui/borrowck/borrowck-loan-in-overloaded-op.rs
Auto merge of #101768 - sunfishcode:sunfishcode/wasi-stdio-lock-asfd, r=joshtriplett
[rust.git] / src / test / ui / borrowck / borrowck-loan-in-overloaded-op.rs
1 #![feature(box_patterns)]
2
3
4 use std::ops::Add;
5
6 #[derive(Clone)]
7 struct Foo(Box<usize>);
8
9 impl Add for Foo {
10     type Output = Foo;
11
12     fn add(self, f: Foo) -> Foo {
13         let Foo(box i) = self;
14         let Foo(box j) = f;
15         Foo(Box::new(i + j))
16     }
17 }
18
19 fn main() {
20     let x = Foo(Box::new(3));
21     let _y = {x} + x.clone(); // the `{x}` forces a move to occur
22     //~^ ERROR borrow of moved value: `x`
23 }