Recursive types do not implement `const Destruct` even when their drop glue is const
Open
Nobody has claimed this yet.
A-coinduction
A-destructors
A-trait-system
C-bug
F-const_trait_impl
T-types
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I expect this to compile, and if you comment out the B variant, it does:
#![feature(const_trait_impl)]
#![feature(const_destruct)]
use std::marker::Destruct;
const fn require_destruct<T: const Destruct>() {}
enum Foo {
A,
B(Wrapper<Foo>), // compiles if commented out
}
struct Wrapper<T>(*const T);
const impl<T: [const] Destruct> Drop for Wrapper<T> {
fn drop(&mut self) {}
}
fn main() {
require_destruct::<Foo>();
require_destruct::<Wrapper<Foo>>(); // passes if Foo has no B variant
}
This is now more easily encountered than before because Vec is usable in const.
Meta
rustc --version --verbose:
rustc 1.100.0-nightly (2e2b193f8 2026-09-02)
binary: rustc
commit-hash: 2e2b193f8ada105f27608b7be81c293e0d7292cb
commit-date: 2026-09-02
host: aarch64-apple-darwin
release: 1.100.0-nightly
LLVM version: 23.1.1
Compiler error
error[E0275]: overflow evaluating the requirement `Foo: const Destruct`
--> src/lib.rs:20:24
|
20 | require_destruct::<Foo>();
| ^^^
|
note: required by a bound in `require_destruct`
--> src/lib.rs:6:30
|
6 | const fn require_destruct<T: const Destruct>() {}
| ^^^^^^^^^^^^^^ required by this bound in `require_destruct`
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 by compiling the reported src/lib.rs reproducer with the stated nightly toolchain, comparing Foo with and without the recursive B variant. Trace const Destruct evaluation for Foo and Wrapper, then add regression coverage showing that the recursive case compiles without the reported E0275 overflow.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100