]> git.lizzy.rs Git - rust.git/blob - src/test/ui/use/use-after-move-implicity-coerced-object.rs
Auto merge of #87284 - Aaron1011:remove-paren-special, r=petrochenkov
[rust.git] / src / test / ui / use / use-after-move-implicity-coerced-object.rs
1 #![feature(box_syntax)]
2
3 use std::fmt;
4
5 struct Number {
6     n: i64
7 }
8
9 impl fmt::Display for Number {
10     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
11         write!(f, "{}", self.n)
12     }
13 }
14
15 struct List {
16     list: Vec<Box<dyn ToString + 'static>> }
17
18 impl List {
19     fn push(&mut self, n: Box<dyn ToString + 'static>) {
20         self.list.push(n);
21     }
22 }
23
24 fn main() {
25     let n: Box<_> = box Number { n: 42 };
26     let mut l: Box<_> = box List { list: Vec::new() };
27     l.push(n);
28     let x = n.to_string();
29     //~^ ERROR: borrow of moved value: `n`
30 }