`Freeze` check ignores lifetimes
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
This issue is similar to #156694 and #156770.
#![feature(freeze)]
use std::marker::Freeze;
trait Super<'a> {
type Assoc: 'a;
const C: Self::Assoc;
}
trait Sub<'a>: Super<'a> {
const D: &'a Self::Assoc;
}
impl<'a, T: for<'b> Super<'b>> Sub<'a> for T
where
<T as Super<'static>>::Assoc: Freeze,
{
const D: &'a <Self as Super<'a>>::Assoc = &<T as Super<'a>>::C;
}
The above code compiles without errors. Note that a value of type <Self as Super<'a>>::Assoc is constant-promoted and/or lifetime-extended into a static-like thing. This is supposed to require the type to implement Freeze. However, I have only wrote the bound <T as Super<'static>>::Assoc: Freeze, which is for a different lifetime. So, this code probably shouldn't compile.
Meta
Reproducible on the playground with version version: 1.100.0-nightly (2026-08-25 787af2b8c80638c51a4f)
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 reproducing the supplied code on the Rust Playground with the reported nightly version 1.100.0-nightly. Investigate the compiler's Freeze checking and lifetime handling for the associated type; done means the example is rejected because the Freeze bound applies to a different lifetime, with a regression test covering the case.
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
- 45/100