Skip to content

trait_selection: Keep type-op region constraints in borrowck - #161423

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
Dnreikronos:trait_selection/preserve_type_op_constraints
Sep 8, 2026
Merged

trait_selection: Keep type-op region constraints in borrowck#161423
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
Dnreikronos:trait_selection/preserve_type_op_constraints

Conversation

@Dnreikronos

@Dnreikronos Dnreikronos commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

View all comments

I ran into this while working on #158588. borrowck_env_fail still had a FIXME because the function body wasn't reporting the outlives error. The next solver creates the region constraint, but the canonical type-op path doesn't put it in QueryResponse. Borrowck never sees it, so the type op looks fine and the error is lost.

With -Zassumptions-on-binders, these type ops now run locally on borrowck's InferCtxt. The fast path still runs first. That leaves the constraint in the same inference context borrowck reads later.

I prefer this over adding more data to the old canonical response. The next solver already caches its work, and teaching the old query path about these constraints felt like extra machinery for something we can avoid. Running locally is pretty boring, but I think that's a good thing here. The old FIXME is now the regression test.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 20, 2026
Dnreikronos added a commit to Dnreikronos/rust that referenced this pull request Aug 20, 2026
Keep rust-lang#158588 focused on reporting solver region constraints. The type-op behavior and its borrowck coverage now live in rust-lang#161423.
@Dnreikronos
Dnreikronos marked this pull request as ready for review August 20, 2026 19:33
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 20, 2026
@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Aug 20, 2026
@rustbot

rustbot commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

r? @davidtwco

rustbot has assigned @davidtwco.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

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

@BoxyUwU

BoxyUwU commented Aug 20, 2026

Copy link
Copy Markdown
Member

r? BoxyUwU

@rustbot rustbot assigned BoxyUwU and unassigned davidtwco Aug 20, 2026
@BoxyUwU

BoxyUwU commented Aug 21, 2026

Copy link
Copy Markdown
Member

I think this is a partial revert of #160982 which we don't want. I think that teaching scrape_region_constraints to handle the new kind of constraints is exactly correct. The whole point of that function is to return the region constraints so it not doing that under -Zassumptions-on-binders seems like a clear bug to me :3

@rustbot author

@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 21, 2026
@rustbot

rustbot commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Aug 21, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 21, 2026
…tions_binders_diagnostics, r=BoxyUwU

trait_selection: fix assumptions-on-binders diagnostics

fixes rust-lang#157732

`-Zassumptions-on-binders` was losing the origin of solver region constraints. By the time regionck or borrowck reported them, every constraint received the containing item span, so diagnostics pointed at an entire function or const. Some paths were also still emitting placeholder text (`:3` and `meoow :c`).

This keeps canonical solver responses and `ExternalConstraintsData` span-free, so source locations do not participate in candidate equality or caching. When a response is applied, `EvalCtxt::origin_span` is attached to each atomic solver `RegionConstraint` stored in `InferCtxt`. Late region conversion then uses the span attached to each constraint, including for ambiguity diagnostics.

The affected paths now report `higher-ranked lifetime bound could not be satisfied` at the type use that introduced the failing constraint. UI coverage checks the rust-lang#157732 call-site diagnostic and the existing regionck alias-outlives case. Unit coverage checks that the spanned evaluator stays in semantic parity with the type-ir evaluator and preserves the first ambiguity origin span.

The type-op behavior I ran into while working on this is split into rust-lang#161423.

Future work: carry the failed outlives predicate or originating binder far enough through this path to name the exact bound that failed, rather than only pointing at its origin.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 21, 2026
…tions_binders_diagnostics, r=BoxyUwU

trait_selection: fix assumptions-on-binders diagnostics

fixes rust-lang#157732

`-Zassumptions-on-binders` was losing the origin of solver region constraints. By the time regionck or borrowck reported them, every constraint received the containing item span, so diagnostics pointed at an entire function or const. Some paths were also still emitting placeholder text (`:3` and `meoow :c`).

This keeps canonical solver responses and `ExternalConstraintsData` span-free, so source locations do not participate in candidate equality or caching. When a response is applied, `EvalCtxt::origin_span` is attached to each atomic solver `RegionConstraint` stored in `InferCtxt`. Late region conversion then uses the span attached to each constraint, including for ambiguity diagnostics.

The affected paths now report `higher-ranked lifetime bound could not be satisfied` at the type use that introduced the failing constraint. UI coverage checks the rust-lang#157732 call-site diagnostic and the existing regionck alias-outlives case. Unit coverage checks that the spanned evaluator stays in semantic parity with the type-ir evaluator and preserves the first ambiguity origin span.

The type-op behavior I ran into while working on this is split into rust-lang#161423.

Future work: carry the failed outlives predicate or originating binder far enough through this path to name the exact bound that failed, rather than only pointing at its origin.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 21, 2026
…tions_binders_diagnostics, r=BoxyUwU

trait_selection: fix assumptions-on-binders diagnostics

fixes rust-lang#157732

`-Zassumptions-on-binders` was losing the origin of solver region constraints. By the time regionck or borrowck reported them, every constraint received the containing item span, so diagnostics pointed at an entire function or const. Some paths were also still emitting placeholder text (`:3` and `meoow :c`).

This keeps canonical solver responses and `ExternalConstraintsData` span-free, so source locations do not participate in candidate equality or caching. When a response is applied, `EvalCtxt::origin_span` is attached to each atomic solver `RegionConstraint` stored in `InferCtxt`. Late region conversion then uses the span attached to each constraint, including for ambiguity diagnostics.

The affected paths now report `higher-ranked lifetime bound could not be satisfied` at the type use that introduced the failing constraint. UI coverage checks the rust-lang#157732 call-site diagnostic and the existing regionck alias-outlives case. Unit coverage checks that the spanned evaluator stays in semantic parity with the type-ir evaluator and preserves the first ambiguity origin span.

The type-op behavior I ran into while working on this is split into rust-lang#161423.

Future work: carry the failed outlives predicate or originating binder far enough through this path to name the exact bound that failed, rather than only pointing at its origin.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 22, 2026
…tions_binders_diagnostics, r=BoxyUwU

trait_selection: fix assumptions-on-binders diagnostics

fixes rust-lang#157732

`-Zassumptions-on-binders` was losing the origin of solver region constraints. By the time regionck or borrowck reported them, every constraint received the containing item span, so diagnostics pointed at an entire function or const. Some paths were also still emitting placeholder text (`:3` and `meoow :c`).

This keeps canonical solver responses and `ExternalConstraintsData` span-free, so source locations do not participate in candidate equality or caching. When a response is applied, `EvalCtxt::origin_span` is attached to each atomic solver `RegionConstraint` stored in `InferCtxt`. Late region conversion then uses the span attached to each constraint, including for ambiguity diagnostics.

The affected paths now report `higher-ranked lifetime bound could not be satisfied` at the type use that introduced the failing constraint. UI coverage checks the rust-lang#157732 call-site diagnostic and the existing regionck alias-outlives case. Unit coverage checks that the spanned evaluator stays in semantic parity with the type-ir evaluator and preserves the first ambiguity origin span.

The type-op behavior I ran into while working on this is split into rust-lang#161423.

Future work: carry the failed outlives predicate or originating binder far enough through this path to name the exact bound that failed, rather than only pointing at its origin.
jhpratt added a commit to jhpratt/rust that referenced this pull request Aug 22, 2026
…tions_binders_diagnostics, r=BoxyUwU

trait_selection: fix assumptions-on-binders diagnostics

fixes rust-lang#157732

`-Zassumptions-on-binders` was losing the origin of solver region constraints. By the time regionck or borrowck reported them, every constraint received the containing item span, so diagnostics pointed at an entire function or const. Some paths were also still emitting placeholder text (`:3` and `meoow :c`).

This keeps canonical solver responses and `ExternalConstraintsData` span-free, so source locations do not participate in candidate equality or caching. When a response is applied, `EvalCtxt::origin_span` is attached to each atomic solver `RegionConstraint` stored in `InferCtxt`. Late region conversion then uses the span attached to each constraint, including for ambiguity diagnostics.

The affected paths now report `higher-ranked lifetime bound could not be satisfied` at the type use that introduced the failing constraint. UI coverage checks the rust-lang#157732 call-site diagnostic and the existing regionck alias-outlives case. Unit coverage checks that the spanned evaluator stays in semantic parity with the type-ir evaluator and preserves the first ambiguity origin span.

The type-op behavior I ran into while working on this is split into rust-lang#161423.

Future work: carry the failed outlives predicate or originating binder far enough through this path to name the exact bound that failed, rather than only pointing at its origin.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 22, 2026
…tions_binders_diagnostics, r=BoxyUwU

trait_selection: fix assumptions-on-binders diagnostics

fixes rust-lang#157732

`-Zassumptions-on-binders` was losing the origin of solver region constraints. By the time regionck or borrowck reported them, every constraint received the containing item span, so diagnostics pointed at an entire function or const. Some paths were also still emitting placeholder text (`:3` and `meoow :c`).

This keeps canonical solver responses and `ExternalConstraintsData` span-free, so source locations do not participate in candidate equality or caching. When a response is applied, `EvalCtxt::origin_span` is attached to each atomic solver `RegionConstraint` stored in `InferCtxt`. Late region conversion then uses the span attached to each constraint, including for ambiguity diagnostics.

The affected paths now report `higher-ranked lifetime bound could not be satisfied` at the type use that introduced the failing constraint. UI coverage checks the rust-lang#157732 call-site diagnostic and the existing regionck alias-outlives case. Unit coverage checks that the spanned evaluator stays in semantic parity with the type-ir evaluator and preserves the first ambiguity origin span.

The type-op behavior I ran into while working on this is split into rust-lang#161423.

Future work: carry the failed outlives predicate or originating binder far enough through this path to name the exact bound that failed, rather than only pointing at its origin.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 22, 2026
…tions_binders_diagnostics, r=BoxyUwU

trait_selection: fix assumptions-on-binders diagnostics

fixes rust-lang#157732

`-Zassumptions-on-binders` was losing the origin of solver region constraints. By the time regionck or borrowck reported them, every constraint received the containing item span, so diagnostics pointed at an entire function or const. Some paths were also still emitting placeholder text (`:3` and `meoow :c`).

This keeps canonical solver responses and `ExternalConstraintsData` span-free, so source locations do not participate in candidate equality or caching. When a response is applied, `EvalCtxt::origin_span` is attached to each atomic solver `RegionConstraint` stored in `InferCtxt`. Late region conversion then uses the span attached to each constraint, including for ambiguity diagnostics.

The affected paths now report `higher-ranked lifetime bound could not be satisfied` at the type use that introduced the failing constraint. UI coverage checks the rust-lang#157732 call-site diagnostic and the existing regionck alias-outlives case. Unit coverage checks that the spanned evaluator stays in semantic parity with the type-ir evaluator and preserves the first ambiguity origin span.

The type-op behavior I ran into while working on this is split into rust-lang#161423.

Future work: carry the failed outlives predicate or originating binder far enough through this path to name the exact bound that failed, rather than only pointing at its origin.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 22, 2026
…tions_binders_diagnostics, r=BoxyUwU

trait_selection: fix assumptions-on-binders diagnostics

fixes rust-lang#157732

`-Zassumptions-on-binders` was losing the origin of solver region constraints. By the time regionck or borrowck reported them, every constraint received the containing item span, so diagnostics pointed at an entire function or const. Some paths were also still emitting placeholder text (`:3` and `meoow :c`).

This keeps canonical solver responses and `ExternalConstraintsData` span-free, so source locations do not participate in candidate equality or caching. When a response is applied, `EvalCtxt::origin_span` is attached to each atomic solver `RegionConstraint` stored in `InferCtxt`. Late region conversion then uses the span attached to each constraint, including for ambiguity diagnostics.

The affected paths now report `higher-ranked lifetime bound could not be satisfied` at the type use that introduced the failing constraint. UI coverage checks the rust-lang#157732 call-site diagnostic and the existing regionck alias-outlives case. Unit coverage checks that the spanned evaluator stays in semantic parity with the type-ir evaluator and preserves the first ambiguity origin span.

The type-op behavior I ran into while working on this is split into rust-lang#161423.

Future work: carry the failed outlives predicate or originating binder far enough through this path to name the exact bound that failed, rather than only pointing at its origin.
rust-bors Bot pushed a commit that referenced this pull request Aug 22, 2026
Rollup merge of #158588 - Dnreikronos:trait_selection/assumptions_binders_diagnostics, r=BoxyUwU

trait_selection: fix assumptions-on-binders diagnostics

fixes #157732

`-Zassumptions-on-binders` was losing the origin of solver region constraints. By the time regionck or borrowck reported them, every constraint received the containing item span, so diagnostics pointed at an entire function or const. Some paths were also still emitting placeholder text (`:3` and `meoow :c`).

This keeps canonical solver responses and `ExternalConstraintsData` span-free, so source locations do not participate in candidate equality or caching. When a response is applied, `EvalCtxt::origin_span` is attached to each atomic solver `RegionConstraint` stored in `InferCtxt`. Late region conversion then uses the span attached to each constraint, including for ambiguity diagnostics.

The affected paths now report `higher-ranked lifetime bound could not be satisfied` at the type use that introduced the failing constraint. UI coverage checks the #157732 call-site diagnostic and the existing regionck alias-outlives case. Unit coverage checks that the spanned evaluator stays in semantic parity with the type-ir evaluator and preserves the first ambiguity origin span.

The type-op behavior I ran into while working on this is split into #161423.

Future work: carry the failed outlives predicate or originating binder far enough through this path to name the exact bound that failed, rather than only pointing at its origin.
@Dnreikronos
Dnreikronos force-pushed the trait_selection/preserve_type_op_constraints branch from 65f9dd2 to 2959d13 Compare August 22, 2026 23:42
@rustbot

This comment has been minimized.

@Dnreikronos

Dnreikronos commented Aug 22, 2026

Copy link
Copy Markdown
Contributor Author

Sup,@BoxyUwU :)

Yeah, scrape_region_constraints makes more sense here. I went with the local type op first because it made the new constraints survive, but after tracing it a bit more I realized, as you said, that was just dodging the query path from #160982.

The next solver was storing the tree in the temporary query InferCtxt, but the query result only knew about the old region constraints. So when that context went away, the tree went with it. I changed QueryRegionConstraints to carry the tree too. It stays unspanned in the cached result, and the caller adds the local span when it registers it. scrape_region_constraints now returns the constraints made by that op without messing with whatever the caller already had.

I also found another place dropping the same tree during implied-bound normalization, before lexical regionck. I fixed that too and added regressions for that path and the borrowck case.

I like this version a lot more. It fixes the point where the data was lost and keeps the cache behavior from #160982. The local version worked, but mostly by going around the problem, and that felt wrong once I understood the full path.

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 22, 2026
@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Aug 27, 2026
@rustbot

rustbot commented Aug 29, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred to the core trait solver

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

@Dnreikronos

Copy link
Copy Markdown
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 29, 2026
@rust-bors

This comment has been minimized.

@Dnreikronos
Dnreikronos force-pushed the trait_selection/preserve_type_op_constraints branch from 96e94dd to 0f14fc7 Compare September 4, 2026 14:07
@rustbot rustbot added the WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) label Sep 4, 2026
@rustbot

rustbot commented Sep 4, 2026

Copy link
Copy Markdown
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.

@BoxyUwU BoxyUwU 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.

this looks pretty much done now :)

View changes since this review

type_tests,
// These have already been destructured into `outlives_constraints` at the
// end of MIR type checking.
solver_constraints: _,

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.

want to add an assert that this is empty? that way the comment cant go out of date

@Dnreikronos Dnreikronos Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yep....the comment is an assert now. It binds the field and checks it's still trivially true right after the destructure, so if something starts pushing constraints in there after typeck we get a panic instead of quietly dropping them on the floor.

I almost left it as a comment because I'd already convinced myself nothing could get in there. But that's exactly the sort of thing I'd forget in two months, so.

region_obligations,
region_constraints,
region_assumptions,
Default::default(),

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.

Can you add a comment about why we ignore new style constraints here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added. Short version is this only runs with the flag off, and with the flag off the solver never makes new style constraints in the first place. Turn it on and we go down the NextGen path instead, which reads the tree straight off the InferCtxt, so this function doesn't even get called.

Took me a minute to talk myself into that when I first passed the empty default in, so the comment probably saves the next person the same trip.

Comment on lines +63 to +64
/// Executes `op` and then scrapes out all resulting region constraints,
/// creating query-region-constraints.

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.

Suggested change
/// Executes `op` and then scrapes out all resulting region constraints,
/// creating query-region-constraints.
/// Executes `op` and then scrapes out all resulting region constraints
/// in the `infcx`, creating query-region-constraints.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Applied. "in the infcx" is the part that actually carries the meaning, my version was vaguer for no reason.

region_obligations,
&region_constraints,
region_assumptions,
Default::default(),

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.

comment about why we dont care about new style constraints here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added. This one returns early unless we're on the old solver globally, and the flag switches the new solver on globally, so the two can't ever be true at the same time. There's just never anything to pass along here.

let region_obligations = self.take_registered_region_obligations();
let region_assumptions = self.take_registered_region_assumptions();
debug!(?region_obligations);
let solver_constraints = self.clone_solver_region_constraints();

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.

why not take_solver_region_constraints like we do for the other stuff?

@Dnreikronos Dnreikronos Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No good reason...that's leftover from the version with the swap, where the tree had to stay in the InferCtxt because borrowck read it much later, so cloning was the only option. Once the swap went away the clone was pure habit and I didn't notice.

Switched to take. We already take the region obligations and assumptions a couple of lines above, so we can't be in a snapshot there and the assert inside take is fine. clone_solver_region_constraints had no other callers, so it's deleted.

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.

want to destructure query_response.value.region_constraints into all of its fields by pattern matching so that its clear we're not forgetting anything

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done. I did the same in the NLL variant since it reads the same three fields and would go stale the same way.

It also just reads better. Three separate walks down query_response.value.region_constraints and I was counting fields by hand to be sure I hadn't skipped one, which is the thing the pattern match is there to stop.

@BoxyUwU

BoxyUwU commented Sep 8, 2026

Copy link
Copy Markdown
Member

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 8, 2026

@BoxyUwU BoxyUwU 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.

great yeah this looks good, can you squash your commits then I'll approve :)

View changes since this review

Under `-Zassumptions-on-binders` the next solver stores its region
constraints in the `InferCtxt` instead of registering region
obligations. The canonical type-op path never copied them into
`QueryResponse`, so they were dropped once the query's inference
context went away. Borrowck then saw a type op with no constraints and
lost the outlives error entirely.

`QueryRegionConstraints` now carries the constraint next to the old
style constraints and assumptions. It stays unspanned while passing
through a canonical query and the caller attaches its own origin span
when consuming the response.

Borrowck accumulates these in `MirTypeckRegionConstraints` through
`ConstraintConversion`, the same way it handles everything else, and
destructures them into NLL outlives constraints at the end of MIR type
checking. Implied bound normalization was dropping the same constraint
before lexical regionck, so that path registers it now as well.
@Dnreikronos
Dnreikronos force-pushed the trait_selection/preserve_type_op_constraints branch from 9c65b1e to a80f20d Compare September 8, 2026 14:29
@Dnreikronos

Copy link
Copy Markdown
Contributor Author

great yeah this looks good, can you squash your commits then I'll approve :)

View changes since this review

Did, Boxy :)

@BoxyUwU

BoxyUwU commented Sep 8, 2026

Copy link
Copy Markdown
Member

@bors r+

@rust-bors

rust-bors Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

📌 Commit a80f20d has been approved by BoxyUwU

It is now in the queue for this repository.

🌲 The tree is currently closed for pull requests below priority 5. This pull request will be tested once the tree is reopened.

Reason for tree closure: spurious failures

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 8, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 8, 2026
…ve_type_op_constraints, r=BoxyUwU

trait_selection: Keep type-op region constraints in borrowck

I ran into this while working on rust-lang#158588. `borrowck_env_fail` still had a FIXME because the function body wasn't reporting the outlives error. The next solver creates the region constraint, but the canonical type-op path doesn't put it in `QueryResponse`. Borrowck never sees it, so the type op looks fine and the error is lost.

With `-Zassumptions-on-binders`, these type ops now run locally on borrowck's `InferCtxt`. The fast path still runs first. That leaves the constraint in the same inference context borrowck reads later.

I prefer this over adding more data to the old canonical response. The next solver already caches its work, and teaching the old query path about these constraints felt like extra machinery for something we can avoid. Running locally is pretty boring, but I think that's a good thing here. The old FIXME is now the regression test.
rust-bors Bot pushed a commit that referenced this pull request Sep 8, 2026
…uwer

Rollup of 6 pull requests

Successful merges:

 - #162309 (offload: automate manual clang-linker-wrapper step)
 - #160505 (delegation: supporting inherent impls)
 - #160712 (windows-gnullvm: always link libunwind statically)
 - #161423 (trait_selection: Keep type-op region constraints in borrowck)
 - #162461 (limit the api of `fold_predicate` and `visit_predicate`)
 - #162475 (Fix unsoundness bug on next trait solver for dyn const generics placeholder)
@rust-bors
rust-bors Bot merged commit 9318843 into rust-lang:main Sep 8, 2026
13 checks passed
@rustbot rustbot added this to the 1.100.0 milestone Sep 8, 2026
rust-bors Bot pushed a commit that referenced this pull request Sep 8, 2026
Rollup merge of #161423 - Dnreikronos:trait_selection/preserve_type_op_constraints, r=BoxyUwU

trait_selection: Keep type-op region constraints in borrowck

I ran into this while working on #158588. `borrowck_env_fail` still had a FIXME because the function body wasn't reporting the outlives error. The next solver creates the region constraint, but the canonical type-op path doesn't put it in `QueryResponse`. Borrowck never sees it, so the type op looks fine and the error is lost.

With `-Zassumptions-on-binders`, these type ops now run locally on borrowck's `InferCtxt`. The fast path still runs first. That leaves the constraint in the same inference context borrowck reads later.

I prefer this over adding more data to the old canonical response. The next solver already caches its work, and teaching the old query path about these constraints felt like extra machinery for something we can avoid. Running locally is pretty boring, but I think that's a good thing here. The old FIXME is now the regression test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

4 participants