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