Followup work from making `ValTree` recurse through `ty::Const`
Open
@BoxyUwU is already working on this.
Since Jan 2, 2026.
A-const-generics
E-needs-design
F-min_generic_const_args
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
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.
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.
Assessment
This issue has not been assessed yet.