rust/tests/ui/closures/2229_closure_analysis
Esteban Küber 11061831f7 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
```
2025-07-25 18:34:10 +00:00
..
diagnostics UI tests: add missing diagnostic kinds where possible 2025-04-08 23:06:31 +03:00
match Mention type that could be Clone but isn't in more cases 2025-07-25 18:34:10 +00:00
migrations future-incompat lints: don't link to the nightly edition-guide version 2025-07-16 01:44:02 -07:00
optimization Remove BorrowKind glob, make names longer 2024-11-04 04:45:52 +00:00
run_pass Update tests with Range parameter to BTreeMap::extract_if etc. 2025-05-27 08:31:56 -07:00
array_subslice.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
array_subslice.stderr More accurate mutability suggestion 2024-07-04 05:36:34 +00:00
arrays-completely-captured.rs Remove BorrowKind glob, make names longer 2024-11-04 04:45:52 +00:00
arrays-completely-captured.stderr Filter empty lines, comments and delimiters from previous to last multiline span rendering 2024-12-12 23:36:27 +00:00
bad-pattern.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
bad-pattern.stderr Trim suggestion parts to the subset that is purely additive 2025-02-14 00:44:10 -08:00
by_value.rs UI tests: add missing diagnostic kinds where possible 2025-04-08 23:06:31 +03:00
by_value.stderr Filter empty lines, comments and delimiters from previous to last multiline span rendering 2024-12-12 23:36:27 +00:00
capture-analysis-1.rs UI tests: add missing diagnostic kinds where possible 2025-04-08 23:06:31 +03:00
capture-analysis-1.stderr Filter empty lines, comments and delimiters from previous to last multiline span rendering 2024-12-12 23:36:27 +00:00
capture-analysis-2.rs UI tests: add missing diagnostic kinds where possible 2025-04-08 23:06:31 +03:00
capture-analysis-2.stderr Filter empty lines, comments and delimiters from previous to last multiline span rendering 2024-12-12 23:36:27 +00:00
capture-analysis-3.rs UI tests: add missing diagnostic kinds where possible 2025-04-08 23:06:31 +03:00
capture-analysis-3.stderr Filter empty lines, comments and delimiters from previous to last multiline span rendering 2024-12-12 23:36:27 +00:00
capture-analysis-4.rs UI tests: add missing diagnostic kinds where possible 2025-04-08 23:06:31 +03:00
capture-analysis-4.stderr Filter empty lines, comments and delimiters from previous to last multiline span rendering 2024-12-12 23:36:27 +00:00
capture-disjoint-field-struct.rs UI tests: add missing diagnostic kinds where possible 2025-04-08 23:06:31 +03:00
capture-disjoint-field-struct.stderr Filter empty lines, comments and delimiters from previous to last multiline span rendering 2024-12-12 23:36:27 +00:00
capture-disjoint-field-tuple.rs UI tests: add missing diagnostic kinds where possible 2025-04-08 23:06:31 +03:00
capture-disjoint-field-tuple.stderr Filter empty lines, comments and delimiters from previous to last multiline span rendering 2024-12-12 23:36:27 +00:00
capture-enum-field.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
capture-enums.rs UI tests: add missing diagnostic kinds where possible 2025-04-08 23:06:31 +03:00
capture-enums.stderr Filter empty lines, comments and delimiters from previous to last multiline span rendering 2024-12-12 23:36:27 +00:00
deep-multilevel-struct.rs Remove BorrowKind glob, make names longer 2024-11-04 04:45:52 +00:00
deep-multilevel-struct.stderr Filter empty lines, comments and delimiters from previous to last multiline span rendering 2024-12-12 23:36:27 +00:00
deep-multilevel-tuple.rs Remove BorrowKind glob, make names longer 2024-11-04 04:45:52 +00:00
deep-multilevel-tuple.stderr Filter empty lines, comments and delimiters from previous to last multiline span rendering 2024-12-12 23:36:27 +00:00
destructure_patterns.rs Remove BorrowKind glob, make names longer 2024-11-04 04:45:52 +00:00
destructure_patterns.stderr Remove BorrowKind glob, make names longer 2024-11-04 04:45:52 +00:00
feature-gate-capture_disjoint_fields.rs Remove BorrowKind glob, make names longer 2024-11-04 04:45:52 +00:00
feature-gate-capture_disjoint_fields.stderr Filter empty lines, comments and delimiters from previous to last multiline span rendering 2024-12-12 23:36:27 +00:00
filter-on-struct-member.rs Remove BorrowKind glob, make names longer 2024-11-04 04:45:52 +00:00
filter-on-struct-member.stderr Remove BorrowKind glob, make names longer 2024-11-04 04:45:52 +00:00
issue-87378.rs Remove BorrowKind glob, make names longer 2024-11-04 04:45:52 +00:00
issue-87378.stderr Filter empty lines, comments and delimiters from previous to last multiline span rendering 2024-12-12 23:36:27 +00:00
issue-88118-2.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-88118-2.stderr Remove hir::Guard 2024-01-05 10:56:59 +00:00
issue-88476.rs Remove BorrowKind glob, make names longer 2024-11-04 04:45:52 +00:00
issue-88476.stderr Filter empty lines, comments and delimiters from previous to last multiline span rendering 2024-12-12 23:36:27 +00:00
issue-89606.rs replace //@ compile-flags: --edition with //@ edition 2025-04-10 09:56:37 +02:00
issue-90465.fixed [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-90465.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-90465.stderr future-incompat lints: don't link to the nightly edition-guide version 2025-07-16 01:44:02 -07:00
issue-92724-needsdrop-query-cycle.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-118144.rs chore: fix some typos 2024-12-31 15:11:18 +08:00
issue-118144.stderr Trim suggestion parts to the subset that is purely additive 2025-02-14 00:44:10 -08:00
issue_88118.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
move_closure.rs UI tests: add missing diagnostic kinds where possible 2025-04-08 23:06:31 +03:00
move_closure.stderr Filter empty lines, comments and delimiters from previous to last multiline span rendering 2024-12-12 23:36:27 +00:00
multilevel-path-1.rs Remove BorrowKind glob, make names longer 2024-11-04 04:45:52 +00:00
multilevel-path-1.stderr Remove BorrowKind glob, make names longer 2024-11-04 04:45:52 +00:00
multilevel-path-2.rs Remove BorrowKind glob, make names longer 2024-11-04 04:45:52 +00:00
multilevel-path-2.stderr Filter empty lines, comments and delimiters from previous to last multiline span rendering 2024-12-12 23:36:27 +00:00
nested-closure.rs Remove BorrowKind glob, make names longer 2024-11-04 04:45:52 +00:00
nested-closure.stderr Filter empty lines, comments and delimiters from previous to last multiline span rendering 2024-12-12 23:36:27 +00:00
path-with-array-access.rs Remove BorrowKind glob, make names longer 2024-11-04 04:45:52 +00:00
path-with-array-access.stderr Filter empty lines, comments and delimiters from previous to last multiline span rendering 2024-12-12 23:36:27 +00:00
preserve_field_drop_order.rs Remove BorrowKind glob, make names longer 2024-11-04 04:45:52 +00:00
preserve_field_drop_order.stderr Filter empty lines, comments and delimiters from previous to last multiline span rendering 2024-12-12 23:36:27 +00:00
preserve_field_drop_order2.rs replace //@ compile-flags: --edition with //@ edition 2025-04-10 09:56:37 +02:00
preserve_field_drop_order2.twenty_eighteen.run.stdout Move /src/test to /tests 2023-01-11 09:32:08 +00:00
preserve_field_drop_order2.twenty_twentyone.run.stdout Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr_packed.rs Remove BorrowKind glob, make names longer 2024-11-04 04:45:52 +00:00
repr_packed.stderr Filter empty lines, comments and delimiters from previous to last multiline span rendering 2024-12-12 23:36:27 +00:00
simple-struct-min-capture.rs Remove BorrowKind glob, make names longer 2024-11-04 04:45:52 +00:00
simple-struct-min-capture.stderr Filter empty lines, comments and delimiters from previous to last multiline span rendering 2024-12-12 23:36:27 +00:00
unique-borrows-are-invariant-1.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
unique-borrows-are-invariant-1.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
unique-borrows-are-invariant-2.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
unique-borrows-are-invariant-2.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
unresolvable-upvar-issue-87987.rs Add some notes and test some more pattern variants 2025-01-24 23:49:04 +11:00
unsafe_ptr.rs Remove BorrowKind glob, make names longer 2024-11-04 04:45:52 +00:00
unsafe_ptr.stderr Filter empty lines, comments and delimiters from previous to last multiline span rendering 2024-12-12 23:36:27 +00:00
wild_patterns.rs Remove BorrowKind glob, make names longer 2024-11-04 04:45:52 +00:00
wild_patterns.stderr Filter empty lines, comments and delimiters from previous to last multiline span rendering 2024-12-12 23:36:27 +00:00