-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Open
Labels
C-bugCategory: This is a bug.Category: This is a bug.F-generic_const_exprs`#![feature(generic_const_exprs)]``#![feature(generic_const_exprs)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.This issue may need triage. Remove it if it has been sufficiently triaged.
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
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.F-generic_const_exprs`#![feature(generic_const_exprs)]``#![feature(generic_const_exprs)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.This issue may need triage. Remove it if it has been sufficiently triaged.