Skip to content

-Znext-solver : Abort on the first overflowed obligation in fulfillment - #162223

Open
adwinwhite wants to merge 1 commit into
rust-lang:mainfrom
adwinwhite:abort-on-fulfillment-overflow
Open

-Znext-solver : Abort on the first overflowed obligation in fulfillment#162223
adwinwhite wants to merge 1 commit into
rust-lang:mainfrom
adwinwhite:abort-on-fulfillment-overflow

Conversation

@adwinwhite

@adwinwhite adwinwhite commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Fixes rust-lang/trait-system-refactor-initiative#294 cc https://rust-lang.zulipchat.com/#narrow/channel/618216-t-types.2Fcall-for-participation/topic/handling.20overflow.20in.20fulfill/with/621040305

We used to drop all subsequent obligations when one obligation overflows in fulfillment. It means that we don't really prove all obligations even if fulfillment has no pending obligations and returns no error. We now eagerly abort on the first overflowed obligation.

r? @ShoyuVanilla
cc @lcnr

@rustbot

rustbot commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred to the core trait solver

cc @rust-lang/initiative-trait-system-refactor

@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 3, 2026
// We limit the total count of inference progress to avoid hang so we don't
// try to recover from this.
// It's more complicated to collect all overflows so we stopped doing that.
// This is consistent with the old solver's behavior.

@lcnr lcnr Sep 3, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please also note how it's incredibly rare to actually encounter fulfillment overflow as a single goal would have to result in different inference progress a recursion_depth number of times. This mostly happens in bugs or with Subtype obligations because we no longer use the sub_unification_table in generalize 🤔 also, style question

we currently check depth after incrementing it, which seems odd. Should we flip it around and instead check depth before incrementing it in the else branch?

View changes since the review

@lcnr

lcnr commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

couldn't not look at this 😅

@ShoyuVanilla please still look at this PR as it's useful, but

r? lcnr
r=me after nits

@rustbot rustbot assigned lcnr and unassigned ShoyuVanilla Sep 3, 2026

@ShoyuVanilla ShoyuVanilla left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me as well 😄

View changes since this review

@theemathas

Copy link
Copy Markdown
Contributor

Is this code path reachable from coherence in stable rust?

@adwinwhite

adwinwhite commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Is this code path reachable from coherence in stable rust?

One possibility is that one impl specializes another and their overlapping computing has overflowed obligations in fulfillment. I am having trouble constructing a test for this though.

@adwinwhite

adwinwhite commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Thinking about specialization a little more. I guess we can assume that if one impl specializes another, they can't have overflowed obligations in fulfillment when computing impossible intersection. The feeling is that the parent's predicates must be provable in the child's param env, so their fresh clauses probably wouldn't progress each other alternatively when put in the same fulfillment.

@lcnr

lcnr commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Is this code path reachable from coherence in stable rust?

yes, though given the difficulty of actually triggering fulfillment overflow without uses of opaque types, I don't think this is practically observable, I guess a quick types nomination

@lcnr lcnr added the I-types-nominated Nominated for discussion during a types team meeting. label Sep 3, 2026
@adwinwhite
adwinwhite force-pushed the abort-on-fulfillment-overflow branch from a6c578a to 85c8774 Compare September 3, 2026 10:35
@rust-bors

rust-bors Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #162406) 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

I-types-nominated Nominated for discussion during a types team meeting. 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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

try_evaluate_obligations drops the in-flight obligation

5 participants