Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracking Issue for const_destruct #133214

Open
1 of 3 tasks
compiler-errors opened this issue Nov 19, 2024 · 1 comment
Open
1 of 3 tasks

Tracking Issue for const_destruct #133214

compiler-errors opened this issue Nov 19, 2024 · 1 comment
Labels
C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. F-const_trait_impl `#![feature(const_trait_impl)]` PG-const-traits Project group: Const traits T-lang Relevant to the language team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. T-types Relevant to the types team, which will review and decide on the PR/issue.

Comments

@compiler-errors
Copy link
Member

compiler-errors commented Nov 19, 2024

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

@compiler-errors compiler-errors added C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue. F-const_trait_impl `#![feature(const_trait_impl)]` PG-const-traits Project group: Const traits labels Nov 19, 2024
@compiler-errors compiler-errors changed the title Tracking Issue for XXX Tracking Issue for const_drop Nov 19, 2024
@compiler-errors compiler-errors changed the title Tracking Issue for const_drop Tracking Issue for const_destruct Nov 19, 2024
@compiler-errors compiler-errors added the T-types Relevant to the types team, which will review and decide on the PR/issue. label Nov 19, 2024
@RalfJung
Copy link
Member

Cc @rust-lang/wg-const-eval

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. F-const_trait_impl `#![feature(const_trait_impl)]` PG-const-traits Project group: Const traits T-lang Relevant to the language team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. T-types Relevant to the types team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants