]> git.lizzy.rs Git - rust.git/blob - src/test/ui/unsized-locals/borrow-after-move.stderr
Rollup merge of #105694 - ouz-a:issue_105689, r=estebank
[rust.git] / src / test / ui / unsized-locals / borrow-after-move.stderr
1 warning: the feature `unsized_locals` is incomplete and may not be safe to use and/or cause compiler crashes
2   --> $DIR/borrow-after-move.rs:1:12
3    |
4 LL | #![feature(unsized_locals, unsized_fn_params)]
5    |            ^^^^^^^^^^^^^^
6    |
7    = note: see issue #48055 <https://github.com/rust-lang/rust/issues/48055> for more information
8    = note: `#[warn(incomplete_features)]` on by default
9
10 error[E0382]: borrow of moved value: `x`
11   --> $DIR/borrow-after-move.rs:21:24
12    |
13 LL |         let y = *x;
14    |                 -- value moved here
15 LL |         drop_unsized(y);
16 LL |         println!("{}", &x);
17    |                        ^^ value borrowed here after move
18    |
19    = note: move occurs because `*x` has type `str`, which does not implement the `Copy` trait
20
21 error[E0382]: borrow of moved value: `y`
22   --> $DIR/borrow-after-move.rs:23:24
23    |
24 LL |         let y = *x;
25    |             - move occurs because `y` has type `str`, which does not implement the `Copy` trait
26 LL |         drop_unsized(y);
27    |                      - value moved here
28 ...
29 LL |         println!("{}", &y);
30    |                        ^^ value borrowed here after move
31    |
32 note: consider changing this parameter type in function `drop_unsized` to borrow instead if owning the value isn't necessary
33   --> $DIR/borrow-after-move.rs:14:31
34    |
35 LL | fn drop_unsized<T: ?Sized>(_: T) {}
36    |    ------------               ^ this parameter takes ownership of the value
37    |    |
38    |    in this function
39
40 error[E0382]: borrow of moved value: `x`
41   --> $DIR/borrow-after-move.rs:31:24
42    |
43 LL |         let y = *x;
44    |                 -- value moved here
45 LL |         y.foo();
46 LL |         println!("{}", &x);
47    |                        ^^ value borrowed here after move
48    |
49    = note: move occurs because `*x` has type `str`, which does not implement the `Copy` trait
50
51 error[E0382]: borrow of moved value: `y`
52   --> $DIR/borrow-after-move.rs:33:24
53    |
54 LL |         let y = *x;
55    |             - move occurs because `y` has type `str`, which does not implement the `Copy` trait
56 LL |         y.foo();
57    |           ----- `y` moved due to this method call
58 ...
59 LL |         println!("{}", &y);
60    |                        ^^ value borrowed here after move
61    |
62 note: `Foo::foo` takes ownership of the receiver `self`, which moves `y`
63   --> $DIR/borrow-after-move.rs:5:12
64    |
65 LL |     fn foo(self) -> String;
66    |            ^^^^
67
68 error[E0382]: borrow of moved value: `x`
69   --> $DIR/borrow-after-move.rs:40:24
70    |
71 LL |         let x = "hello".to_owned().into_boxed_str();
72    |             - move occurs because `x` has type `Box<str>`, which does not implement the `Copy` trait
73 LL |         x.foo();
74    |         - value moved here
75 LL |         println!("{}", &x);
76    |                        ^^ value borrowed here after move
77    |
78 help: consider cloning the value if the performance cost is acceptable
79    |
80 LL |         x.clone().foo();
81    |          ++++++++
82
83 error: aborting due to 5 previous errors; 1 warning emitted
84
85 For more information about this error, try `rustc --explain E0382`.