Skip to content

const Drop can be implemented for structs with non-const-Drop fields #155618

@Lars-Schumann

Description

@Lars-Schumann

I tried this code: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=5108e4d09698e21cbb974237f91ba456

#![feature(const_trait_impl)]
#![feature(const_destruct)]
#![allow(unused)]

struct NotConstDrop;

impl Drop for NotConstDrop {
    fn drop(&mut self) {}
}

struct ConstDrop(NotConstDrop);

impl const Drop for ConstDrop {
    fn drop(&mut self) {}
}

I expected to see this happen: compilation error, apparently this is not supposed to happen.

Instead, this happened: compiles fine.

Meta

rustc --version --verbose: (Playground)

1.97.0-nightly
(2026-04-20 66da6cae1a6f12e95854)

@oli-obk

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)A-destructorsArea: Destructors (`Drop`, …)C-bugCategory: This is a bug.F-const_trait_impl`#![feature(const_trait_impl)]`PG-const-traitsProject group: Const traits

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions