fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

master
3.0 KiB85 linesraw
1warning: 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   |
4LL | #![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
10error[E0382]: borrow of moved value: `x`
11  --> $DIR/borrow-after-move.rs:21:24
12   |
13LL |         let y = *x;
14   |                 -- value moved here
15LL |         drop_unsized(y);
16LL |         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
21error[E0382]: borrow of moved value: `y`
22  --> $DIR/borrow-after-move.rs:23:24
23   |
24LL |         let y = *x;
25   |             - move occurs because `y` has type `str`, which does not implement the `Copy` trait
26LL |         drop_unsized(y);
27   |                      - value moved here
28...
29LL |         println!("{}", &y);
30   |                        ^^ value borrowed here after move
31   |
32note: 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   |
35LL | fn drop_unsized<T: ?Sized>(_: T) {}
36   |    ------------               ^ this parameter takes ownership of the value
37   |    |
38   |    in this function
39
40error[E0382]: borrow of moved value: `x`
41  --> $DIR/borrow-after-move.rs:31:24
42   |
43LL |         let y = *x;
44   |                 -- value moved here
45LL |         y.foo();
46LL |         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
51error[E0382]: borrow of moved value: `y`
52  --> $DIR/borrow-after-move.rs:33:24
53   |
54LL |         let y = *x;
55   |             - move occurs because `y` has type `str`, which does not implement the `Copy` trait
56LL |         y.foo();
57   |           ----- `y` moved due to this method call
58...
59LL |         println!("{}", &y);
60   |                        ^^ value borrowed here after move
61   |
62note: `Foo::foo` takes ownership of the receiver `self`, which moves `y`
63  --> $DIR/borrow-after-move.rs:5:12
64   |
65LL |     fn foo(self) -> String;
66   |            ^^^^
67
68error[E0382]: borrow of moved value: `x`
69  --> $DIR/borrow-after-move.rs:40:24
70   |
71LL |         let x = "hello".to_owned().into_boxed_str();
72   |             - move occurs because `x` has type `Box<str>`, which does not implement the `Copy` trait
73LL |         x.foo();
74   |         - value moved here
75LL |         println!("{}", &x);
76   |                        ^^ value borrowed here after move
77   |
78help: consider cloning the value if the performance cost is acceptable
79   |
80LL |         x.clone().foo();
81   |          ++++++++
82
83error: aborting due to 5 previous errors; 1 warning emitted
84
85For more information about this error, try `rustc --explain E0382`.