Skip to content

Fallible type ops - #165335

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
jdonszelmann:fallible-type-ops
Nov 7, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
jdonszelmann:fallible-type-ops

Conversation

@jdonszelmann

@jdonszelmann jdonszelmann commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

View all comments

This PR adds a new TypeOp which is expected to properly report fulfillment errors rather than assert all obligations holds.

This is a single commit extracted from #156018 and #161457. It adds a currently unused api to mir typeck, that's required to implement the move trait, but is on its own also useful for other changes like resolving all cases of #132279

By extracting it, we can lower the review burden on the other PRs

cc: @zannabianca1997

@rustbot

rustbot commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in engine.rs, potentially modifying the public API of ObligationCtxt.

cc @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. labels Nov 2, 2026
@rustbot

rustbot commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

r? @mejrs

rustbot has assigned @mejrs.
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 77 candidates
  • Random selection from 21 candidates

@jdonszelmann

Copy link
Copy Markdown
Contributor Author

r? @lcnr or anyone in @rust-lang/initiative-trait-system-refactor

@rustbot rustbot assigned lcnr and unassigned mejrs Nov 2, 2026
@jdonszelmann

Copy link
Copy Markdown
Contributor Author

r? @rust-lang/initiative-trait-system-refactor (lcnr isn't on rotation right now, confirmed with them)

@rustbot

This comment was marked as outdated.

@jdonszelmann

This comment was marked as outdated.

@rustbot

This comment was marked as off-topic.

@jdonszelmann

Copy link
Copy Markdown
Contributor Author

r? project-trait-system-refactor

@rustbot rustbot assigned adwinwhite and unassigned lcnr Nov 2, 2026
}

impl<'tcx> EngineError<'tcx> for ScrubbedTraitError<'tcx> {
fn try_report_errors(_infcx: &InferCtxt<'tcx>, _errors: ThinVec<Self>) {}

@adwinwhite adwinwhite Nov 4, 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.

Surprising that try_report_errors doesn't actually report anything?

View changes since the review

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.

it doesn't in this impl of EngineError but it does for FulfullmentError. I've left a comment in the source.

let errors = ocx.evaluate_obligations_error_on_ambiguity();
match errors {
TraitErrors::HasErrors(errors) => {
E::try_report_errors(infcx, errors);

@adwinwhite adwinwhite Nov 4, 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.

We would duplicate the reporting? try_report_errors and check_potentially_region_dependent_goals can report similar errors 🤔

View changes since the review

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.

when check_potentially_region_dependent_goals emits errors, it returnsErr(). I have not been able to find a single case in which this actually happens, either manually or in the test suite. I think it's a separate concern that maybe, since that's highly dubious....

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.

it probably needs a bug!() or something, or potentially we can just remove this entire call

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.

but at least I don't think we can get duplicate errors

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.

Yeah, it seems check_potentially_region_dependent_goals is currently not exercised, since we silently ignore ambiguity.
But with #164055 , it'll be used.

@adwinwhite adwinwhite Nov 5, 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.

We won't have duplicate errors but the control flow is a bit convoluted. Could you comment in this and_then closure that this is to report non-region dependent errors, or specifically for the FallableCustomTypeOp?

Can Move obligations have nested goals that're region dependent? Then we'll have duplicate errors.

@adwinwhite

Copy link
Copy Markdown
Contributor

@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 Nov 4, 2026
@rustbot

rustbot commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

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

@jdonszelmann

Copy link
Copy Markdown
Contributor Author

@rustbot review

@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 Nov 4, 2026
@rust-log-analyzer

This comment has been minimized.

@adwinwhite adwinwhite left a comment •

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.

Thank you for added comments!
Now I get the motivation is to report Move trait fulfillment errors in borrowck and those are not related to region uniquification.
This seems to violate the invariant that we shall not have obligation errors in borrowck if HIR typeck succeeds. But if it's what the Move design requires, then no problem from me.

View changes since this review

@jdonszelmann

Copy link
Copy Markdown
Contributor Author

We cannot know these bounds earlier, since it depends on whether we move a value, which we only know in mir.

@rustbot

rustbot commented Nov 5, 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.

@adwinwhite

Copy link
Copy Markdown
Contributor

The duplicate diagnostics concern is non-fatal and we can improve things later.

@bors r+ rollup

@rust-bors

rust-bors Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 4400802 has been approved by adwinwhite

It is now in the queue for this repository.

@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-review Status: Awaiting review from the assignee but also interested parties. labels Nov 6, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 6, 2026
…adwinwhite

Fallible type ops

This PR adds a new `TypeOp` which is expected to properly report fulfillment errors rather than assert all obligations holds.

This is a single commit extracted from rust-lang#156018 and rust-lang#161457. It adds a currently *unused* api to mir typeck, that's required to implement the move trait, but is on its own also useful for other changes like resolving all cases of rust-lang#132279

By extracting it, we can lower the review burden on the other PRs

cc: @zannabianca1997
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 6, 2026
…adwinwhite

Fallible type ops

This PR adds a new `TypeOp` which is expected to properly report fulfillment errors rather than assert all obligations holds.

This is a single commit extracted from rust-lang#156018 and rust-lang#161457. It adds a currently *unused* api to mir typeck, that's required to implement the move trait, but is on its own also useful for other changes like resolving all cases of rust-lang#132279

By extracting it, we can lower the review burden on the other PRs

cc: @zannabianca1997
rust-bors Bot pushed a commit that referenced this pull request Nov 6, 2026
…uwer

Rollup of 19 pull requests

Successful merges:

 - #164784 (Introduce OptimizationObjective and fix the entry shim's size attributes)
 - #165037 (Drop array elements in order after a partial move)
 - #165078 (Use the `2.38` binutils version in CI)
 - #159374 (Lower #[no_mangle] to #[symbol_name]/#[link_name])
 - #163284 (feat(Reborrow): Allow multiple lifetimes)
 - #164775 (Tweak output on misused `const` parameter to provide more context and more accurate suggestion)
 - #165194 (name elided lifetimes in `use<...>` suggestion when `impl Trait` params are present)
 - #165222 (Anonymize inner binders when checking refining)
 - #165335 (Fallible type ops)
 - #165388 (Accept variadic SysV64, Win64, and Aapcs FnAbis in rustc_public)
 - #165448 (Update `Vec::retain_unstable` docs to say that this method is generally faster than `Vec::retain_mut`)
 - #165494 (fix Miri ICE on exit with () return type)
 - #165503 (update Enzyme submodule)
 - #165505 (DFV: Reject `#[non_exhaustive]` on enum variants with default field values)
 - #165512 (Fix warnings for the L4Re targets)
 - #165514 (Remove unused `WhereEqPredicate` and `ScopeId` types)
 - #165518 (style-guide: Remove ABI explicitness prescription for extern items)
 - #165519 (Update books)
 - #165534 (rename MIR_borrow_checking timing scope to less confusing name)
rust-bors Bot pushed a commit that referenced this pull request Nov 7, 2026
Rollup of 15 pull requests

Successful merges:

 - #165037 (Drop array elements in order after a partial move)
 - #165550 (Make `Literal::cstr_value` return a `CString`)
 - #159374 (Lower #[no_mangle] to #[symbol_name]/#[link_name])
 - #163284 (feat(Reborrow): Allow multiple lifetimes)
 - #164775 (Tweak output on misused `const` parameter to provide more context and more accurate suggestion)
 - #165194 (name elided lifetimes in `use<...>` suggestion when `impl Trait` params are present)
 - #165222 (Anonymize inner binders when checking refining)
 - #165335 (Fallible type ops)
 - #165388 (Accept variadic SysV64, Win64, and Aapcs FnAbis in rustc_public)
 - #165448 (Update `Vec::retain_unstable` docs to say that this method is generally faster than `Vec::retain_mut`)
 - #165494 (fix Miri ICE on exit with () return type)
 - #165505 (DFV: Reject `#[non_exhaustive]` on enum variants with default field values)
 - #165512 (Fix warnings for the L4Re targets)
 - #165514 (Remove unused `WhereEqPredicate` and `ScopeId` types)
 - #165518 (style-guide: Remove ABI explicitness prescription for extern items)
@rust-bors
rust-bors Bot merged commit 2fc4c29 into rust-lang:main Nov 7, 2026
14 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Nov 7, 2026
rust-bors Bot pushed a commit that referenced this pull request Nov 7, 2026
Rollup merge of #165335 - jdonszelmann:fallible-type-ops, r=adwinwhite

Fallible type ops

This PR adds a new `TypeOp` which is expected to properly report fulfillment errors rather than assert all obligations holds.

This is a single commit extracted from #156018 and #161457. It adds a currently *unused* api to mir typeck, that's required to implement the move trait, but is on its own also useful for other changes like resolving all cases of #132279

By extracting it, we can lower the review burden on the other PRs

cc: @zannabianca1997
@rust-timer

Copy link
Copy Markdown
Collaborator

Note

This PR was benchmarked as part of triage of its containing rollup: triage URL.

Finished benchmarking commit (818c63a): comparison URL.

Overall result: ❌ regressions - please read:

Our benchmarks found a performance regression caused by this PR.
This might be an actual regression, but it can also be just noise.

Next Steps:

  • If the regression was expected or you think it can be justified,
    please write a comment with sufficient written justification, and add
    @rustbot label: +perf-regression-triaged to it, to mark the regression as triaged.
  • If you think that you know of a way to resolve the regression, try to create
    a new PR with a fix for the regression.
  • If you do not understand the regression or you think that it is just noise,
    you can ask the @rust-lang/wg-compiler-performance working group for help (members of this group
    were already notified of this PR).

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
1.1% [0.2%, 3.5%] 108
Regressions ❌
(secondary)
1.4% [0.2%, 4.2%] 124
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.1% [0.2%, 3.5%] 108

Max RSS (memory usage)

This perf run didn't have relevant results for this metric.

Cycles

Results (primary 1.7%, secondary 3.6%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.8% [2.1%, 3.4%] 8
Regressions ❌
(secondary)
3.6% [2.3%, 4.8%] 18
Improvements ✅
(primary)
-2.6% [-2.7%, -2.5%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.7% [-2.7%, 3.4%] 10

Binary size

This perf run didn't have relevant results for this metric.

Artifact size: 406.27 MiB -> 406.18 MiB (-0.02%)

@rustbot rustbot added the perf-regression Performance regression. label Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

perf-regression Performance regression. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants