-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Cannot borrow from generic Copy types in a const context #120119
Copy link
Copy link
Closed
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team
Metadata
Metadata
Assignees
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team
Type
Fields
Give feedbackNo fields configured for issues without a type.
I tried this code:
I expected the
Copybounds to be sufficient to allow this to compile.Copyis an imperfect analog for a lack of interior mutability, much like it is an imperfect analog for!Drop.Instead, this happened:
Ideally, stable code would be able to bound on a lack of interior mutability (like a
NoCell/Freezetrait) to allow this sort of generic code to work without needingconst_refs_to_cellstabilized, as it's a useful property to be able to bound on forunsafecode.Meta