|
| 1 | +error[E0382]: borrow of moved value: `stdout` |
| 2 | + --> $DIR/suggest-borrow-for-generic-arg.rs:14:14 |
| 3 | + | |
| 4 | +LL | let mut stdout = io::stdout(); |
| 5 | + | ---------- move occurs because `stdout` has type `Stdout`, which does not implement the `Copy` trait |
| 6 | +LL | aux::write_stuff(stdout)?; |
| 7 | + | ------ value moved here |
| 8 | +LL | writeln!(stdout, "second line")?; |
| 9 | + | ^^^^^^ value borrowed here after move |
| 10 | + | |
| 11 | +help: consider borrowing `stdout` |
| 12 | + | |
| 13 | +LL | aux::write_stuff(&stdout)?; |
| 14 | + | + |
| 15 | + |
| 16 | +error[E0382]: borrow of moved value: `buf` |
| 17 | + --> $DIR/suggest-borrow-for-generic-arg.rs:19:14 |
| 18 | + | |
| 19 | +LL | let mut buf = Vec::new(); |
| 20 | + | ------- move occurs because `buf` has type `Vec<u8>`, which does not implement the `Copy` trait |
| 21 | +LL | aux::write_stuff(buf)?; |
| 22 | + | --- value moved here |
| 23 | +LL | |
| 24 | +LL | writeln!(buf, "second_line") |
| 25 | + | ^^^ value borrowed here after move |
| 26 | + | |
| 27 | +help: consider mutably borrowing `buf` |
| 28 | + | |
| 29 | +LL | aux::write_stuff(&mut buf)?; |
| 30 | + | ++++ |
| 31 | +help: consider cloning the value if the performance cost is acceptable |
| 32 | + | |
| 33 | +LL | aux::write_stuff(buf.clone())?; |
| 34 | + | ++++++++ |
| 35 | + |
| 36 | +error[E0382]: use of moved value: `stdin` |
| 37 | + --> $DIR/suggest-borrow-for-generic-arg.rs:26:27 |
| 38 | + | |
| 39 | +LL | let stdin = io::stdin(); |
| 40 | + | ----- move occurs because `stdin` has type `Stdin`, which does not implement the `Copy` trait |
| 41 | +LL | aux::read_and_discard(stdin)?; |
| 42 | + | ----- value moved here |
| 43 | +LL | aux::read_and_discard(stdin)?; |
| 44 | + | ^^^^^ value used here after move |
| 45 | + | |
| 46 | +help: consider borrowing `stdin` |
| 47 | + | |
| 48 | +LL | aux::read_and_discard(&stdin)?; |
| 49 | + | + |
| 50 | + |
| 51 | +error[E0382]: use of moved value: `bytes` |
| 52 | + --> $DIR/suggest-borrow-for-generic-arg.rs:31:27 |
| 53 | + | |
| 54 | +LL | let mut bytes = std::collections::VecDeque::from([1, 2, 3, 4, 5, 6]); |
| 55 | + | --------- move occurs because `bytes` has type `VecDeque<u8>`, which does not implement the `Copy` trait |
| 56 | +LL | aux::read_and_discard(bytes)?; |
| 57 | + | ----- value moved here |
| 58 | +LL | |
| 59 | +LL | aux::read_and_discard(bytes) |
| 60 | + | ^^^^^ value used here after move |
| 61 | + | |
| 62 | +help: consider mutably borrowing `bytes` |
| 63 | + | |
| 64 | +LL | aux::read_and_discard(&mut bytes)?; |
| 65 | + | ++++ |
| 66 | +help: consider cloning the value if the performance cost is acceptable |
| 67 | + | |
| 68 | +LL | aux::read_and_discard(bytes.clone())?; |
| 69 | + | ++++++++ |
| 70 | + |
| 71 | +error[E0382]: use of moved value: `iter` |
| 72 | + --> $DIR/suggest-borrow-for-generic-arg.rs:39:42 |
| 73 | + | |
| 74 | +LL | let mut iter = [1, 2, 3, 4, 5, 6].into_iter(); |
| 75 | + | -------- move occurs because `iter` has type `std::array::IntoIter<usize, 6>`, which does not implement the `Copy` trait |
| 76 | +LL | let _six: usize = aux::sum_three(iter); |
| 77 | + | ---- value moved here |
| 78 | +LL | |
| 79 | +LL | let _fifteen: usize = aux::sum_three(iter); |
| 80 | + | ^^^^ value used here after move |
| 81 | + | |
| 82 | +help: consider mutably borrowing `iter` |
| 83 | + | |
| 84 | +LL | let _six: usize = aux::sum_three(&mut iter); |
| 85 | + | ++++ |
| 86 | +help: consider cloning the value if the performance cost is acceptable |
| 87 | + | |
| 88 | +LL | let _six: usize = aux::sum_three(iter.clone()); |
| 89 | + | ++++++++ |
| 90 | + |
| 91 | +error: aborting due to 5 previous errors |
| 92 | + |
| 93 | +For more information about this error, try `rustc --explain E0382`. |
0 commit comments