Validate HIR ty lowering's produced generic parameters
@camelid is already working on this.
Since Jan 2, 2026.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
In #150519 we added some checks to HIR ty lowering that when lowering to a generic parameter, we aren't inside of an anon const for const generics which shouldn't be able to use generic parameters.
There are a two main bits of follow up work here:
- The current impl is fairly brittle, it requires special casing all places that we're aware of as potentially introducing uses of generic parameters that shouldn't be allowed. We've previously got this wrong (#150519). I don't know how likely it is that we've correctly checked all positions
- It only applies to anon consts from const generics. In theory it would be nice if we checked all generic parameters we find against the
generics_ofof the item we're inside of and asserted they are actually supposed to be nameable
I expect things to be quite perf sensitive here, and also it seems hard to get a good API here. cc @camelid
I've tagged this as F-min_generic_const_args as we rely quite heavily on this check for mGCA as we don't do any validation at name resolution time. But this logic is used on stable and it would be good to have these assertions on stable too
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.