about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2025-08-02 17:36:34 +0000
committerMichael Goulet <michael@errs.io>2025-08-04 15:31:50 +0000
commitf6ce4ac9d38fca2df5bc408de8f4c2567d2f2709 (patch)
treecc4451413f9a5578de9ee41b98a03867537cf07e /compiler
parente1b9081e699065badfc1a9419ec9566e5c8615c4 (diff)
downloadrust-f6ce4ac9d38fca2df5bc408de8f4c2567d2f2709.tar.gz
rust-f6ce4ac9d38fca2df5bc408de8f4c2567d2f2709.zip
Anonymize binders in tail call sig
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_mir_build/src/check_tail_calls.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/rustc_mir_build/src/check_tail_calls.rs b/compiler/rustc_mir_build/src/check_tail_calls.rs
index 6ed100899d8..036e20c22b8 100644
--- a/compiler/rustc_mir_build/src/check_tail_calls.rs
+++ b/compiler/rustc_mir_build/src/check_tail_calls.rs
@@ -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:?}")