generic_const_exprs: the type `[(); N]` does not fulfill the required lifetime
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I tried this code:
#![feature(generic_const_exprs)]
const N: usize = 32;
pub trait IoType: 'static {
type PointerType;
}
impl<const SIZE: usize> IoType for [(); SIZE] {
type PointerType = ();
}
struct InternalArgs<'a> {
ptr: <[(); N] as IoType>::PointerType,
_phantom: core::marker::PhantomData<&'a ()>,
}
I expected to see this happen: Must compile successfully
Instead, this happened:
error[E0477]: the type `[(); N]` does not fulfill the required lifetime
--> src/main.rs:14:10
|
14 | ptr: <[(); N] as IoType>::PointerType,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: type must satisfy the static lifetime
The same code compiles with any one of the following changes:
- Remove
generic_const_exprsfeature - Remove
'staticfrom trait bounds - Remove
'alifetime from a struct - Replace
Nwith the value itself
Simply enabling and not even taking advantage of generic_const_exprs feature is sufficient to confuse the compiler. Without it code compiles even on stable Rust.
Meta
rustc --version --verbose:
rustc 1.94.0-nightly (8d670b93d 2025-12-31)
binary: rustc
commit-hash: 8d670b93d40737e1b320fd892c6f169ffa35e49e
commit-date: 2025-12-31
host: x86_64-unknown-linux-gnu
release: 1.94.0-nightly
LLVM version: 21.1.8
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
Reproduce the example from src/main.rs on the reported nightly compiler and compare it with the listed minimal changes. Investigate how the compiler handles the static lifetime requirement for the associated type projection involving [(); N] and generic_const_exprs; done means the original example compiles without those workarounds.
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
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100