Skip to content

Tracking Issue for const_destruct #133214

Open
@compiler-errors

Description

@compiler-errors

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

Unresolved Questions

  • Do we want to allow ~const bounds on const Drop impls?

I think we do, and sorely need them for const drop to ever be useful. See my justification in #132329 (comment). 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.

Footnotes

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCF-const_trait_impl`#![feature(const_trait_impl)]`PG-const-traitsProject group: Const traitsT-langRelevant to the language team, which will review and decide on the PR/issue.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions