rust/compiler/rustc_trait_selection
Trevor Gross bd18f88dab
Rollup merge of #128201 - compiler-errors:closure-clone, r=oli-obk
Implement `Copy`/`Clone` for async closures

We can do so in the same cases that regular closures do.

For the purposes of cloning, coroutine-closures are actually precisely the same as regular closures, specifically in the aspect that `Clone` impls care about which is the upvars. The only difference b/w coroutine-closures and regular closures is the type that they *return*, but this type has not been *created* yet, so we don't really have a problem.

IDK why I didn't add this impl initially -- I went back and forth a bit on the internal representation for coroutine-closures before settling on a design which largely models regular closures. Previous (not published) iterations of coroutine-closures used to be represented as a special (read: cursed) kind of coroutine, which would probably suffer from the pitfalls that coroutines have that oli mentioned below in https://github.com/rust-lang/rust/pull/128201#issuecomment-2251230274.

r? oli-obk
2024-07-26 19:03:05 -04:00
..
src Rollup merge of #128201 - compiler-errors:closure-clone, r=oli-obk 2024-07-26 19:03:05 -04:00
Cargo.toml Remove unused compiler dependencies 2024-06-29 22:09:58 +02:00
messages.ftl Move all error reporting into rustc_trait_selection 2024-07-21 22:34:35 -04:00