rust/compiler/rustc_trait_selection/src
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
..
error_reporting Support ?Trait bounds in supertraits and dyn Trait under a feature gate 2024-07-25 20:53:33 +03:00
errors Move all error reporting into rustc_trait_selection 2024-07-21 22:34:35 -04:00
solve Move all error reporting into rustc_trait_selection 2024-07-21 22:34:35 -04:00
traits Make coroutine-closures possible to be cloned 2024-07-26 12:53:53 -04:00
errors.rs Move all error reporting into rustc_trait_selection 2024-07-21 22:34:35 -04:00
infer.rs Actually just make can_eq process obligations (almost) everywhere 2024-07-05 11:59:54 -04:00
lib.rs Move all error reporting into rustc_trait_selection 2024-07-21 22:34:35 -04:00
regions.rs Add cycle errors to ScrubbedTraitError to remove a couple more calls to new_with_diagnostics 2024-06-03 09:27:52 -04:00
solve.rs Rename a bunch of things 2024-06-21 12:32:05 -04:00