Skip to content

1.59 accidentally stabilized dropping Box<T>s in const fns #94804

Closed
@steffahn

Description

@steffahn
const fn f<T>(_: Box<T>) {}

(playground)

Note that this works even if T implements Drop in a non-const way. This seems hightly problematic, especially provided we eventually want to support constructing Box at compile time.

Relevant PR: #91884

Of course that impl claims to be unstable, but as we all know trait implementations are never unstable, unless the trait is unstable. (For ordinary traits, implementations of const Trait are thus unstable merely due to the fact that no user can use any such implementations in stable code yet.)

@rustbot label regression-from-stable-to-stable

I don’t know what team to tag.

The fix should be straightforward: Remove the const Drop for Box<T, A> implementation (i.e. revert it to be non-const), and add a test.

Metadata

Metadata

Assignees

Labels

P-highHigh priorityT-libsRelevant to the library team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions