Skip to content

Add dependent binders and explicit trait evidence representation - #162745

Open
enginespot wants to merge 1 commit into
rust-lang:mainfrom
enginespot:e0582/pr-01-dependent-binder
Open

enginespot wants to merge 1 commit into
rust-lang:mainfrom
enginespot:e0582/pr-01-dependent-binder

Conversation

@enginespot

@enginespot enginespot commented Sep 14, 2026

Copy link
Copy Markdown

Introduce the type-level representation needed to carry dependent binder entries and compiler-internal trait evidence through rustc. Evidence is kept separate from ordinary generic arguments so later solver and canonical-query code can preserve the proof identity associated with a projection.

The motivation is the HRTB/GAT behavior tracked in #107572, #86702, and #121437. The current E0582 check conservatively rejects some callable bounds even when the same GAT projection appears on both the input and output sides. This representation gives later stages enough information to distinguish that case from a projection whose normalized output is independent of the bound lifetime.

This change adds:

  • dependent binder entries and explicit evidence states;
  • evidence-indexed aliases;
  • folding, visiting, relation, persistence, diagnostics, and printing support;
  • low-level coverage for the new representation.

Testing:

  • ./x check
  • ./x test --stage 2 tests/ui-fulldeps
  • ./x test src/tools/tidy

Related: #107572, #86702, and #121437.

This design is informed by @RalfJung's explicit trait-evidence discussion in #32330 and by @compiler-errors and @SkiFire13's analysis of projection normalization and lifetime constraints in #107572 and #86702.

@rustbot

rustbot commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

This PR changes MIR

cc @oli-obk, @RalfJung, @JakobDegen, @vakaras

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Sep 14, 2026
@rustbot

rustbot commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project has assigned @khyperia (or someone else) to review your changes, you should hear from them (or someone else) within the next two weeks.

Please see the contribution instructions and our LLM policy for more information.

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler, types
  • compiler, types expanded to 76 candidates
  • Random selection from 18 candidates

@rust-log-analyzer

This comment has been minimized.

@enginespot
enginespot force-pushed the e0582/pr-01-dependent-binder branch from b47fc22 to 7a8b709 Compare September 14, 2026 02:23
@rust-log-analyzer

This comment has been minimized.

@jackh726

Copy link
Copy Markdown
Member

This needs significant discussion with the types team; Zulip is the right place for that.

I'll leave this open for now, but am going to mark this as experimental. It is not going to be reviewed without discussion.

@jackh726 jackh726 added S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 14, 2026
@jackh726 jackh726 added T-types Relevant to the types team, which will review and decide on the PR/issue. and removed T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 14, 2026
@oli-obk oli-obk added the llm-assisted An LLM-assisted PR as defined by the LLM policy. Requires ahead-of-time consent by assignee. label Sep 14, 2026
Represent typed const and evidence declarations in binder telescopes.
Keep proof substitutions separate from ordinary generic arguments and
return dependent clauses and contracts when opening a binder.

Carry evidence-indexed type and const projections through interning,
folding, visiting, structural relation, hashing, and serialization.
Preserve sharing in proof DAGs and validate declaration, projection,
and decoding invariants. Adapt existing consumers and reject unsupported
evidence evaluation.

Add real-TyCtxt tests for substitution, nested binders, structural proof
identity, projection arguments, contract obligations, and shared-DAG
codec behavior.
@enginespot
enginespot force-pushed the e0582/pr-01-dependent-binder branch from 7a8b709 to 8010641 Compare September 14, 2026 14:02
@rustbot

rustbot commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

This PR changes rustc_public

cc @oli-obk, @celinval, @ouz-a, @makai410

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

changes to the core type system

cc @lcnr

clippy is developed in its own repository. If possible, consider making this change to rust-lang/rust-clippy instead.

cc @rust-lang/clippy

changes to the core type system

cc @lcnr

@rustbot rustbot added the T-clippy Relevant to the Clippy team. label Sep 14, 2026
@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job test-x86_64-gnu-gcc failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
failures:

---- [ui] tests/ui-fulldeps/dependent-evidence-codec.rs stdout ----

error: test did not exit with success! code=Some(101) so test would pass with `run-fail`
status: exit status: 101
command: cd "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui-fulldeps/dependent-evidence-codec" && RUSTC="/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" RUST_TEST_THREADS="4" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui-fulldeps/dependent-evidence-codec/a" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "/checkout/tests/ui-fulldeps/auxiliary/dependent-evidence-codec-input.rs"
stdout: none
--- stderr -------------------------------

thread 'rustc' (206617) panicked at /checkout/tests/ui-fulldeps/dependent-evidence-codec.rs:303:5:
assertion failed: decoder.in_progress.is_empty()

Important

For more information how to resolve CI failures of this job, visit this link.

@enginespot

Copy link
Copy Markdown
Author

@jackh726 Thanks for the guidance. I’ve started a discussion in #t-types
(https://rust-lang.zulipchat.com/#narrow/channel/144729-t-types/topic/Early.20design.20feedback.20on.20HRTB.2FGAT.20evidence.20handling.20.28PR.20.23162/with/623947679).
I proposed the core idea and used AI tools extensively in this work. I hope to learn from the team and help
move this issue toward a solution.

@rust-bors

rust-bors Bot commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #162827) made this pull request unmergeable. Please resolve the merge conflicts by rebasing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

llm-assisted An LLM-assisted PR as defined by the LLM policy. Requires ahead-of-time consent by assignee. S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. T-clippy Relevant to the Clippy team. T-types Relevant to the types team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants