Skip to content

Defer tail call ret ty equality to check_tail_calls #144915

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Aug 4, 2025

Fixes #144892.

Currently the tail call signature check assumes that return types have been accounted for. However, this is not complete for several reasons.

Firstly, we were using subtyping instead of equality in the HIR typeck code:

self.demand_suptype(expr.span, ret_ty, call_expr_ty);

We could fix this, but it doesn't really do much for us anyways since HIR typeck doesn't care about regions.

That means, secondly, we'd need to fix the terminator type check in MIR typeck to account for variances. This seems annoying.

All of this seems like a lot of work, and we already are manually checking argument equality. Let's just extend the check_tail_calls to account for mismatches in return types anyways.

r? @WaffleLapkin

@rustbot
Copy link
Collaborator

rustbot commented Aug 4, 2025

WaffleLapkin is not on the review rotation at the moment.
They may take a while to respond.

@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 Aug 4, 2025
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.

Explicit tail call returning a HRTB causes ICE: "hir typeck should have checked the return type already"
3 participants