-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Open
Labels
A-const-genericsArea: const generics (parameters and arguments)Area: const generics (parameters and arguments)E-needs-designThis issue needs exploration and design to see how and if we can fix/implement itThis issue needs exploration and design to see how and if we can fix/implement itF-min_generic_const_args`#![feature(min_generic_const_args)]``#![feature(min_generic_const_args)]`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.
Description
After #149114 ValTree's Branches variant stores a list of ty::Const instead of a list of ValTrees. See the PR description and associated zulip thread (#project-const-generics > Valtrees that can contain generic params) for a motivation for this.
This has left us with two problems:
- The name
Valueis kinda confusing :) These are in some sense not full values. It may be desirable to renameConstKind::Value,ty::Value,ty::ValTreeandty::ValTreeKindto something different now that they don't represent full values. - There are now a bunch of extra
Tyin a fully evaluateValTree. This is likely bad for performance. Though more importantly it means that when CTFE evaluates something to aValTreeit has to pick types for all the nested nodes in aValTree. This is effectively impossible for CTFE to do correctly as it doesn't have lifetime information so we wind up with a bunch of erased lifetimes entering the type system.
The second point can be observed by looking at debug logs for this code example:
#![feature(adt_const_params, unsized_const_params)]
#![expect(incomplete_features)]
#![crate_type = "lib"]
struct Foo<'a> {
r: &'a u32,
}
fn bar<const N: Foo<'static>>() { }
fn qux() {
bar::<{ Foo { r: &1 } }>();
}
0ms DEBUG rustc_trait_selection::traits ct=UnevaluatedConst { def: DefId(0:9 ~ foo[cae9]::qux::{constant#0}), args: [] }
0ms DEBUG rustc_trait_selection::traits return=Ok(ValTree(Branch([ValTree(Leaf(0x00000001): &'{erased} u32)]): Foo::<'static>))Assigning myself as I'm partially through fixing this second point.
Metadata
Metadata
Assignees
Labels
A-const-genericsArea: const generics (parameters and arguments)Area: const generics (parameters and arguments)E-needs-designThis issue needs exploration and design to see how and if we can fix/implement itThis issue needs exploration and design to see how and if we can fix/implement itF-min_generic_const_args`#![feature(min_generic_const_args)]``#![feature(min_generic_const_args)]`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.