Tracking Issue for `const_destruct`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Feature gate: #![feature(const_destruct)]
This is a tracking issue for const_destruct, which enables the naming of the Destruct trait and its use in ~const bounds to allow dropping values in const contexts.
Public API
pub trait Destruct { }
Steps / History
- Implementation: It was already implemented, but it's getting a new feature gate in https://github.com/rust-lang/rust/pull/132329.
- Final comment period (FCP)^1
- Stabilization PR
Unresolved Questions
- Do we want to allow
~constbounds onconst Dropimpls?
I think we do, and sorely need them for const drop to ever be useful. See my justification in https://github.com/rust-lang/rust/pull/132329#discussion_r1838749569. We want to be able to implement a conditional drop impl like:
struct DropAndCall<F: Fn()>(F);
impl<F> const Drop for DropAndCall<F>
where
F: ~const Fn(),
{
fn drop(&mut self) {
(self.0)(); // This should be allowed.
}
}
This is what is implemented on nightly.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the const_destruct feature gate and the implementation described in rust-lang/rust#132329, then read the linked stabilization guide. The implementation is marked complete; remaining work is to resolve whether ~const bounds belong on const Drop impls, complete the final comment period, and prepare a stabilization PR.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100