Add built-in const impls for Clone and Copy#147866
Conversation
|
rustbot has assigned @petrochenkov. Use |
|
r? @lcnr for review or further reassignment |
|
|
||
| pub fn to_host_effect_clause(self, cx: I, constness: BoundConstness) -> I::Clause { | ||
| self.map_bound(|trait_ref| { | ||
| self.map_bound(|trait_ref: TraitRef<I>| { |
There was a problem hiding this comment.
It was a misclick with rust-analyzer
|
|
||
| // only when `coroutine_clone` is enabled and the coroutine is movable | ||
| // impl Copy/Clone for Coroutine where T: Copy/Clone forall T in (upvars, witnesses) | ||
| ty::Coroutine(def_id, args) => match tcx.coroutine_movability(def_id) { |
There was a problem hiding this comment.
need to check should_stall_coroutine? 🤔
rn checking const Clone for a coroutine should cause a query cycle
| } | ||
| } | ||
|
|
||
| fn evaluate_host_effect_for_copy_clone_goal<'tcx>( |
There was a problem hiding this comment.
use SelectionContext::copy_clone_conditions instead of duplicating the match here?
We do the same in the new solver, so I'd expect either duplicating this match in both solvers or in none of them.
I guess the issue is that copy_clone_conditions only expects self types for which assembly succeeded?
There was a problem hiding this comment.
Yeah, the built in Copy/Clone for non-const stuff is following the "assemble if looks okay, check nested predicates during confirmation", but the const stuff is not, so there is some divide here that prevents us from deduplicating without doing some refactor on how BuiltinCandidate works...
7d4ea10 to
042018d
Compare
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
@bors r+ rollup |
Rollup of 4 pull requests Successful merges: - #145939 (const `select_unpredictable`) - #147478 (More intuitive error when using self to instantiate tuple struct with private field) - #147866 (Add built-in `const` impls for `Clone` and `Copy`) - #148153 (Fix duplicate 'the the' typos in comments) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of #147866 - fee1-dead-contrib:constclonebuiltin, r=lcnr Add built-in `const` impls for `Clone` and `Copy` cc `@compiler-errors`
cc @compiler-errors