Rollup merge of #144835 - compiler-errors:tail-call-sig-binder, r=WaffleLapkin

Anonymize binders in tail call sig

See the comment for explanation

Fixes rust-lang/rust#144826

r? WaffleLapkin
This commit is contained in:
Guillaume Gomez
2025-08-06 21:29:27 +02:00
committed by GitHub
2 changed files with 18 additions and 1 deletions

View File

@@ -60,9 +60,13 @@ impl<'tcx> TailCallCkVisitor<'_, 'tcx> {
let BodyTy::Fn(caller_sig) = self.thir.body_type else {
span_bug!(
call.span,
"`become` outside of functions should have been disallowed by hit_typeck"
"`become` outside of functions should have been disallowed by hir_typeck"
)
};
// While the `caller_sig` does have its regions erased, it does not have its
// binders anonymized. We call `erase_regions` once again to anonymize any binders
// within the signature, such as in function pointer or `dyn Trait` args.
let caller_sig = self.tcx.erase_regions(caller_sig);
let ExprKind::Scope { value, .. } = call.kind else {
span_bug!(call.span, "expected scope, found: {call:?}")