about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/errors.rs
diff options
context:
space:
mode:
authorTrevor Gross <t.gross35@gmail.com>2025-07-26 01:15:05 -0500
committerGitHub <noreply@github.com>2025-07-26 01:15:05 -0500
commit72e3767380fc42bb3f7cd534fdbc42b2d0390e5c (patch)
tree52a3d2f1efbcb0e640e427e8a983092fd57f6d3f /compiler/rustc_codegen_llvm/src/errors.rs
parent3f7d497c8aba1b415c2b9b6a597eab1faa744416 (diff)
parent11061831f703fdb5d05816860368e4b9ab4edee7 (diff)
downloadrust-72e3767380fc42bb3f7cd534fdbc42b2d0390e5c.tar.gz
rust-72e3767380fc42bb3f7cd534fdbc42b2d0390e5c.zip
Rollup merge of #144201 - estebank:suggest-clone, r=SparrowLii
Mention type that could be `Clone` but isn't in more cases

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
```

CC rust-lang/rust#68119.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/errors.rs')
0 files changed, 0 insertions, 0 deletions