1
Fork 0
rust/compiler/rustc_trait_selection/src
León Orell Valerian Liehr 44c7a2dbff
Rollup merge of #125259 - compiler-errors:fn-mut-as-a-treat, r=oli-obk
An async closure may implement `FnMut`/`Fn` if it has no self-borrows

There's no reason that async closures may not implement `FnMut` or `Fn` if they don't actually borrow anything with the closure's env lifetime. Specifically, #123660 made it so that we don't always need to borrow captures from the closure's env.

See the doc comment on `should_reborrow_from_env_of_parent_coroutine_closure`:

c00957a3e2/compiler/rustc_hir_typeck/src/upvar.rs (L1777-L1823)

If there are no such borrows, then we are free to implement `FnMut` and `Fn` as permitted by our closure's inferred `ClosureKind`.

As far as I can tell, this change makes `async || {}` work in precisely the set of places they used to work before #120361.
Fixes #125247.

r? oli-obk
2024-05-22 19:04:45 +02:00
..
solve Rollup merge of #125259 - compiler-errors:fn-mut-as-a-treat, r=oli-obk 2024-05-22 19:04:45 +02:00
traits Rollup merge of #125259 - compiler-errors:fn-mut-as-a-treat, r=oli-obk 2024-05-22 19:04:45 +02:00
errors.rs Lift TraitRef into rustc_type_ir 2024-05-10 15:44:03 -04:00
infer.rs Remove trivial Binder::dummy calls 2024-05-16 14:24:23 -04:00
lib.rs Remove extern crate rustc_middle from rustc_trait_selection. 2024-05-13 08:20:18 +10:00
regions.rs Remove extern crate rustc_macros from numerous crates. 2024-04-29 10:21:54 +10:00