rust-lang / rust-lang/rust

Tracking Issue for Rustc Public: Expose Type and Const Parameter Constraints

Open
#161,892 1 comment 0 reactions 1 assignee View on GitHub

@nanjekyejoannah is already working on this.

Since Sep 10, 2026.

C-tracking-issue S-tracking-unimplemented T-libs
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

This is a tracking issue for Rustc public API.

Feature gate: #![feature(rustc_public_generic_clauses)]

Problem

Currently, the APIs in Rustc public missing some information required for building full fidelity tools on top of it.

(1) Trait bounds:

trait Step {}
  fn advance<T: Step>(value: T) -> T {
      value
  }

Rustc Public exposes that advance has a type parameter named T, but not the constraint T: Step.

(2) Const types:

fn f<const N: usize>()

Rustc Public reveals that N is a const generic but not its type.

Public API

The FnDef type could be extended by two new functions:

impl FnDef {
      pub fn generics_of(&self) -> Generics;

      pub fn clauses_of(&self) -> GenericClauses;
      pub fn explicit_clauses_of(&self) -> GenericClauses;
  }

Alternatively, the trait bound info could be included in Generics

For the const c: usize problem, GenericParamDefKind would be extended for the Const variant to also carry a type.

Steps / History
  • ACP: rust-lang/libs-team#...
  • Implementation: #...
  • Final comment period (FCP)^1
  • Stabilization PR
Unresolved Questions

This seems to be a simple API extension, so no open questions.

  • None yet.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.