Files
rust/tests/ui/issues
Stuart Cook 907076c3dd Rollup merge of #144558 - estebank:issue-68119, r=lcnr
Point at the `Fn()` or `FnMut()` bound that coerced a closure, which caused a move error

When encountering a move error involving a closure because the captured value isn't `Copy`, and the obligation comes from a bound on a type parameter that requires `Fn` or `FnMut`, we point at it and explain that an `FnOnce` wouldn't cause the move error.

```
error[E0507]: cannot move out of `foo`, a captured variable in an `Fn` closure
  --> f111.rs:15:25
   |
14 | fn do_stuff(foo: Option<Foo>) {
   |             ---  ----------- move occurs because `foo` has type `Option<Foo>`, which does not implement the `Copy` trait
   |             |
   |             captured outer variable
15 |     require_fn_trait(|| async {
   |                      -- ^^^^^ `foo` is moved here
   |                      |
   |                      captured by this `Fn` closure
16 |         if foo.map_or(false, |f| f.foo()) {
   |            --- variable moved due to use in coroutine
   |
help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but an `FnOnce` consume them only once
  --> f111.rs:12:53
   |
12 | fn require_fn_trait<F: Future<Output = ()>>(_: impl Fn() -> F) {}
   |                                                     ^^^^^^^^^
help: consider cloning the value if the performance cost is acceptable
   |
16 |         if foo.clone().map_or(false, |f| f.foo()) {
   |               ++++++++
```

Fix rust-lang/rust#68119, by pointing at `Fn` and `FnMut` bounds involved in move errors.
2025-08-11 12:21:08 +10:00
..
2024-02-07 10:42:01 +08:00
2024-01-05 10:00:59 +00:00
2025-07-07 08:13:12 +00:00
2024-02-07 10:42:01 +08:00
2024-02-07 10:42:01 +08:00
2025-04-03 21:41:58 +00:00
2025-06-06 20:52:34 +00:00
2025-02-04 10:57:49 +00:00
2025-02-03 19:00:22 +00:00
2024-02-07 10:42:01 +08:00
2024-01-13 12:46:58 -05:00
2024-07-06 14:24:20 +02:00
2023-05-01 16:15:13 +08:00
2024-02-07 10:42:01 +08:00
2023-04-08 21:32:55 +00:00
2024-01-05 10:00:59 +00:00
2024-01-13 12:46:58 -05:00
2023-11-16 17:00:23 +00:00
2024-02-07 10:42:01 +08:00
2024-04-29 14:53:38 +02:00
2023-01-15 19:46:20 +00:00
2023-01-15 19:46:20 +00:00
2024-11-22 02:32:26 +00:00
2023-06-26 08:56:32 +00:00
2023-11-24 21:04:51 +01:00
2024-04-22 18:48:47 +02:00