-Zassumptions-on-binders#155887
Open
BoxyUwU wants to merge 9 commits intorust-lang:mainfrom
Open
Conversation
This comment has been minimized.
This comment has been minimized.
8e8c7e5 to
a3098f3
Compare
This comment has been minimized.
This comment has been minimized.
e24ed3d to
c7de204
Compare
This comment has been minimized.
This comment has been minimized.
c7de204 to
642d5dc
Compare
This comment has been minimized.
This comment has been minimized.
642d5dc to
aba599d
Compare
This comment has been minimized.
This comment has been minimized.
aba599d to
19c7f1d
Compare
This comment has been minimized.
This comment has been minimized.
19c7f1d to
02a859d
Compare
This comment has been minimized.
This comment has been minimized.
BoxyUwU
commented
Apr 28, 2026
| pub mod lang_items; | ||
| pub mod lift; | ||
| pub mod outlives; | ||
| pub mod region_constraint; |
Member
Author
There was a problem hiding this comment.
weird module name
| } | ||
|
|
||
| #[derive_where(Clone, Hash, PartialEq, Debug; I: Interner)] | ||
| pub enum RegionConstraint<I: Interner> { |
Member
Author
There was a problem hiding this comment.
Weird type name
lcnr
reviewed
Apr 29, 2026
lcnr
reviewed
Apr 29, 2026
lcnr
reviewed
Apr 29, 2026
lcnr
reviewed
Apr 29, 2026
lcnr
reviewed
Apr 29, 2026
lcnr
reviewed
Apr 29, 2026
lcnr
reviewed
Apr 29, 2026
lcnr
reviewed
Apr 29, 2026
lcnr
reviewed
Apr 29, 2026
lcnr
reviewed
Apr 29, 2026
2b2a9a2 to
23a9728
Compare
Collaborator
|
Some changes occurred to the core trait solver cc @rust-lang/initiative-trait-system-refactor |
BoxyUwU
commented
May 8, 2026
This comment has been minimized.
This comment has been minimized.
deb19c7 to
1c60d77
Compare
BoxyUwU
commented
May 8, 2026
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
38786ea to
27da5f2
Compare
27da5f2 to
c42e7ea
Compare
Collaborator
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
44bca3e to
00502c6
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
f2524ee to
29c1906
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
View all comments
r? lcnr
cc https://rust-lang.github.io/rust-project-goals/2026/assumptions_on_binders.html I would cc a tracking issue but the project goals haven't been finalized yet ^^'
Implements
-Zassumptions-on-binders. This has a few main components:InferCtxtall the region outlives and type outlives mentioning a placeholder from the binder for use when handling constraints involving placeholdersThis is very much a first-draft impl (though it is vaguely functional), there's a lot we need to change going forwards:
How do we actually eagerly handle constraints?
The general idea is that we have some function (
eagerly_handle_placeholders_in_universe) which takes:This function will rewrite all of the region constraints which involve placeholders from the passed in universe to be in terms of variables from smaller universes (or drop the constraints if we know them to be satisfied). For example:
when exiting
for<'a>we want to handle the'!a: 'cconstraint somehow and we can do that by requiring that any of the lifetimes which'!aoutlives, themselves outlive'c. In this case we can requireOr('b: 'c)and instead of'!a: 'cwhich gives us a constraint that makes sense after exiting the forall.some more examples:
The tricky thing here is that we want/need to avoid the trait solver knowing about all type outlives/region outlives assumptions. So this algorithm is implemented with only knowing about the assumptions coming from the binder that is being exited.
We want to avoid passing all outlives assumptions through the trait solver for two main reasons. The first is just perf, augmenting the ParamEnv with significant amounts of outlives assumptions could easily mess up caching.
The second is that it's Not Possible:tm: to implement. During type checking we can be doing trait solving inside of a closure which has an uninferred signature, this means that there are some set of implied bounds that we just don't know about yet because we only know some inference variable is well formed and nothing else.
Long term we should be able to wholly rip out placeholder handling from borrow checking and we won't ever encounter placeholders outside of the binders they were produced from.