Skip to content

Fallible type ops - #165335

Open
jdonszelmann wants to merge 1 commit into
rust-lang:mainfrom
jdonszelmann:fallible-type-ops
Open

jdonszelmann wants to merge 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 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.

This branch has not been deployed

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

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants