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

/// Certain proofs (e.g. `Move`) may error during MIR typeck, so handle them separately.
#[allow(unused)]
pub(super) fn prove_fallible_predicate(

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

How is this different from prove_clause above? 🤔

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.

that it uses FallibleTypeOp internally, which can return errors that are reported

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.

importantly, prove_clause is effectively an assertion: it produces a span_delayed_bug if the clause does not hold i.e. because it wasn't rejected earlier. Fallible ops can cause new errors unrelated to what is or isn't already proven. Let me add a comment about that.

}

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

/// Processes the operation and all resulting obligations,
/// returning the final result along with any region constraints
/// (they will be given over to the NLL region solver).
fn fully_perform(

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

How is the new TypeOp different from CustomTypeOp except that it uses FulfillmentError?

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.

Well, that is quite a big difference. FulfillmentError reports its 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.

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