1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
|
error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-exprs.rs:12:11
|
LL | let x = "hi".to_string();
| - move occurs because `x` has type `String`, which does not implement the `Copy` trait
LL | let _y = Foo { f:x };
| - value moved here
LL | touch(&x);
| ^^ value borrowed here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | let _y = Foo { f:x.clone() };
| ++++++++
error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-exprs.rs:18:11
|
LL | let x = "hi".to_string();
| - move occurs because `x` has type `String`, which does not implement the `Copy` trait
LL | let _y = (x, 3);
| - value moved here
LL | touch(&x);
| ^^ value borrowed here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | let _y = (x.clone(), 3);
| ++++++++
error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-exprs.rs:35:11
|
LL | let x = "hi".to_string();
| - move occurs because `x` has type `String`, which does not implement the `Copy` trait
...
LL | x
| - value moved here
...
LL | touch(&x);
| ^^ value borrowed here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | x.clone()
| ++++++++
error[E0382]: borrow of moved value: `y`
--> $DIR/moves-based-on-type-exprs.rs:36:11
|
LL | let y = "ho".to_string();
| - move occurs because `y` has type `String`, which does not implement the `Copy` trait
...
LL | y
| - value moved here
...
LL | touch(&y);
| ^^ value borrowed here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | y.clone()
| ++++++++
error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-exprs.rs:46:11
|
LL | let x = "hi".to_string();
| - move occurs because `x` has type `String`, which does not implement the `Copy` trait
...
LL | true => x,
| - value moved here
...
LL | touch(&x);
| ^^ value borrowed here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | true => x.clone(),
| ++++++++
error[E0382]: borrow of moved value: `y`
--> $DIR/moves-based-on-type-exprs.rs:47:11
|
LL | let y = "ho".to_string();
| - move occurs because `y` has type `String`, which does not implement the `Copy` trait
...
LL | false => y
| - value moved here
...
LL | touch(&y);
| ^^ value borrowed here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | false => y.clone()
| ++++++++
error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-exprs.rs:58:11
|
LL | let x = "hi".to_string();
| - move occurs because `x` has type `String`, which does not implement the `Copy` trait
...
LL | _ if guard(x) => 10,
| - value moved here
...
LL | touch(&x);
| ^^ value borrowed here after move
|
note: consider changing this parameter type in function `guard` to borrow instead if owning the value isn't necessary
--> $DIR/moves-based-on-type-exprs.rs:6:14
|
LL | fn guard(_s: String) -> bool {panic!()}
| ----- ^^^^^^ this parameter takes ownership of the value
| |
| in this function
help: consider cloning the value if the performance cost is acceptable
|
LL | _ if guard(x.clone()) => 10,
| ++++++++
error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-exprs.rs:65:11
|
LL | let x = "hi".to_string();
| - move occurs because `x` has type `String`, which does not implement the `Copy` trait
LL | let _y = [x];
| - value moved here
LL | touch(&x);
| ^^ value borrowed here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | let _y = [x.clone()];
| ++++++++
error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-exprs.rs:71:11
|
LL | let x = "hi".to_string();
| - move occurs because `x` has type `String`, which does not implement the `Copy` trait
LL | let _y = vec![x];
| - value moved here
LL | touch(&x);
| ^^ value borrowed here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | let _y = vec![x.clone()];
| ++++++++
error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-exprs.rs:77:11
|
LL | let x = vec!["hi".to_string()];
| - move occurs because `x` has type `Vec<String>`, which does not implement the `Copy` trait
LL | let _y = x.into_iter().next().unwrap();
| ----------- `x` moved due to this method call
LL | touch(&x);
| ^^ value borrowed here after move
|
note: `into_iter` takes ownership of the receiver `self`, which moves `x`
--> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
help: you can `clone` the value and consume it, but this might not be your desired behavior
|
LL | let _y = x.clone().into_iter().next().unwrap();
| ++++++++
error[E0382]: borrow of moved value: `x`
--> $DIR/moves-based-on-type-exprs.rs:83:11
|
LL | let x = vec!["hi".to_string()];
| - move occurs because `x` has type `Vec<String>`, which does not implement the `Copy` trait
LL | let _y = [x.into_iter().next().unwrap(); 1];
| ----------- `x` moved due to this method call
LL | touch(&x);
| ^^ value borrowed here after move
|
note: `into_iter` takes ownership of the receiver `self`, which moves `x`
--> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
help: you can `clone` the value and consume it, but this might not be your desired behavior
|
LL | let _y = [x.clone().into_iter().next().unwrap(); 1];
| ++++++++
error: aborting due to 11 previous errors
For more information about this error, try `rustc --explain E0382`.
|