mirror of
https://github.com/rust-lang/rust.git
synced 2025-09-28 13:46:03 +00:00

When encountering a moved value of a type that isn't `Clone` because of unmet obligations, but where all the unmet predicates reference crate-local types, mention them and suggest cloning, as we do in other cases already: ``` error[E0507]: cannot move out of `foo`, a captured variable in an `Fn` closure --> f111.rs:14:25 | 13 | fn do_stuff(foo: Option<Foo>) { | --- captured outer variable 14 | require_fn_trait(|| async { | -- ^^^^^ `foo` is moved here | | | captured by this `Fn` closure 15 | if foo.map_or(false, |f| f.foo()) { | --- | | | variable moved due to use in coroutine | move occurs because `foo` has type `Option<Foo>`, which does not implement the `Copy` trait | note: if `Foo` implemented `Clone`, you could clone the value --> f111.rs:4:1 | 4 | struct Foo; | ^^^^^^^^^^ consider implementing `Clone` for this type ... 15 | if foo.map_or(false, |f| f.foo()) { | --- you could clone this value ```
119 lines
3.8 KiB
Plaintext
119 lines
3.8 KiB
Plaintext
error[E0594]: cannot assign to `t.0`, as `t` is not declared as mutable
|
|
--> $DIR/issue-54499-field-mutation-of-moved-out.rs:13:9
|
|
|
|
|
LL | t.0 = S(1);
|
|
| ^^^^^^^^^^ cannot assign
|
|
|
|
|
help: consider changing this to be mutable
|
|
|
|
|
LL | let mut t: Tuple = (S(0), 0);
|
|
| +++
|
|
|
|
error[E0382]: assign to part of moved value: `t`
|
|
--> $DIR/issue-54499-field-mutation-of-moved-out.rs:13:9
|
|
|
|
|
LL | let t: Tuple = (S(0), 0);
|
|
| - move occurs because `t` has type `(S, i32)`, which does not implement the `Copy` trait
|
|
LL | drop(t);
|
|
| - value moved here
|
|
LL | t.0 = S(1);
|
|
| ^^^^^^^^^^ value partially assigned here after move
|
|
|
|
error[E0594]: cannot assign to `t.1`, as `t` is not declared as mutable
|
|
--> $DIR/issue-54499-field-mutation-of-moved-out.rs:16:9
|
|
|
|
|
LL | t.1 = 2;
|
|
| ^^^^^^^ cannot assign
|
|
|
|
|
help: consider changing this to be mutable
|
|
|
|
|
LL | let mut t: Tuple = (S(0), 0);
|
|
| +++
|
|
|
|
error[E0594]: cannot assign to `u.0`, as `u` is not declared as mutable
|
|
--> $DIR/issue-54499-field-mutation-of-moved-out.rs:24:9
|
|
|
|
|
LL | u.0 = S(1);
|
|
| ^^^^^^^^^^ cannot assign
|
|
|
|
|
help: consider changing this to be mutable
|
|
|
|
|
LL | let mut u: Tpair = Tpair(S(0), 0);
|
|
| +++
|
|
|
|
error[E0382]: assign to part of moved value: `u`
|
|
--> $DIR/issue-54499-field-mutation-of-moved-out.rs:24:9
|
|
|
|
|
LL | let u: Tpair = Tpair(S(0), 0);
|
|
| - move occurs because `u` has type `Tpair`, which does not implement the `Copy` trait
|
|
LL | drop(u);
|
|
| - value moved here
|
|
LL | u.0 = S(1);
|
|
| ^^^^^^^^^^ value partially assigned here after move
|
|
|
|
|
note: if `Tpair` implemented `Clone`, you could clone the value
|
|
--> $DIR/issue-54499-field-mutation-of-moved-out.rs:6:1
|
|
|
|
|
LL | struct Tpair(S, i32);
|
|
| ^^^^^^^^^^^^ consider implementing `Clone` for this type
|
|
...
|
|
LL | drop(u);
|
|
| - you could clone this value
|
|
|
|
error[E0594]: cannot assign to `u.1`, as `u` is not declared as mutable
|
|
--> $DIR/issue-54499-field-mutation-of-moved-out.rs:27:9
|
|
|
|
|
LL | u.1 = 2;
|
|
| ^^^^^^^ cannot assign
|
|
|
|
|
help: consider changing this to be mutable
|
|
|
|
|
LL | let mut u: Tpair = Tpair(S(0), 0);
|
|
| +++
|
|
|
|
error[E0594]: cannot assign to `v.x`, as `v` is not declared as mutable
|
|
--> $DIR/issue-54499-field-mutation-of-moved-out.rs:35:9
|
|
|
|
|
LL | v.x = S(1);
|
|
| ^^^^^^^^^^ cannot assign
|
|
|
|
|
help: consider changing this to be mutable
|
|
|
|
|
LL | let mut v: Spair = Spair { x: S(0), y: 0 };
|
|
| +++
|
|
|
|
error[E0382]: assign to part of moved value: `v`
|
|
--> $DIR/issue-54499-field-mutation-of-moved-out.rs:35:9
|
|
|
|
|
LL | let v: Spair = Spair { x: S(0), y: 0 };
|
|
| - move occurs because `v` has type `Spair`, which does not implement the `Copy` trait
|
|
LL | drop(v);
|
|
| - value moved here
|
|
LL | v.x = S(1);
|
|
| ^^^^^^^^^^ value partially assigned here after move
|
|
|
|
|
note: if `Spair` implemented `Clone`, you could clone the value
|
|
--> $DIR/issue-54499-field-mutation-of-moved-out.rs:7:1
|
|
|
|
|
LL | struct Spair { x: S, y: i32 }
|
|
| ^^^^^^^^^^^^ consider implementing `Clone` for this type
|
|
...
|
|
LL | drop(v);
|
|
| - you could clone this value
|
|
|
|
error[E0594]: cannot assign to `v.y`, as `v` is not declared as mutable
|
|
--> $DIR/issue-54499-field-mutation-of-moved-out.rs:38:9
|
|
|
|
|
LL | v.y = 2;
|
|
| ^^^^^^^ cannot assign
|
|
|
|
|
help: consider changing this to be mutable
|
|
|
|
|
LL | let mut v: Spair = Spair { x: S(0), y: 0 };
|
|
| +++
|
|
|
|
error: aborting due to 9 previous errors
|
|
|
|
Some errors have detailed explanations: E0382, E0594.
|
|
For more information about an error, try `rustc --explain E0382`.
|