rust-lang / rust-lang/rust

`const Destruct` check ignores lifetimes

Open
#156,694 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-destructors A-lifetimes C-bug F-const_trait_impl T-types
Dominant language
Rust
Stars
119k
Forks
16.2k
PR merge metrics
PR metrics pending

Description

I tried this code:

#![feature(const_trait_impl, const_destruct)]

use std::marker::Destruct;

pub trait Trait {
    type Assoc<'a>;
}

pub const fn foo<'a, 'b, T: Trait<Assoc<'a>: [const] Destruct>>(_x: T::Assoc<'b>) {}

The above code compiles without errors. However, I think it shouldn't compile. We've only specified that T::Assoc<'a> can have its destructor ran in const. We didn't specify the same for T::Assoc<'b>.

Meta

Reproducible on the playground with version 1.97.0-nightly (2026-05-17 507271bc119683008ec7)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the provided Rust reproducer on the Rust Playground using nightly 1.97.0 (2026-05-17). Trace the const Destruct bound handling for the differing 'a and 'b lifetimes; done means the example is rejected because the bound only covers T::Assoc<'a>.

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
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.