Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f6ce4ac

Browse files
Anonymize binders in tail call sig
1 parent e1b9081 commit f6ce4ac

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

‎compiler/rustc_mir_build/src/check_tail_calls.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,13 @@ impl<'tcx> TailCallCkVisitor<'_, 'tcx> {
6060
let BodyTy::Fn(caller_sig) = self.thir.body_type else {
6161
span_bug!(
6262
call.span,
63-
"`become` outside of functions should have been disallowed by hit_typeck"
63+
"`become` outside of functions should have been disallowed by hir_typeck"
6464
)
6565
};
66+
// While the `caller_sig` does have its regions erased, it does not have its
67+
// binders anonymized. We call `erase_regions` once again to anonymize any binders
68+
// within the signature, such as in function pointer or `dyn Trait` args.
69+
let caller_sig = self.tcx.erase_regions(caller_sig);
6670

6771
let ExprKind::Scope { value, .. } = call.kind else {
6872
span_bug!(call.span, "expected scope, found: {call:?}")
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Regression test for <https://github.com/rust-lang/rust/issues/144826>.
2+
//@ check-pass
3+
4+
#![feature(explicit_tail_calls)]
5+
#![expect(incomplete_features)]
6+
7+
fn foo(x: fn(&i32)) {
8+
become bar(x);
9+
}
10+
11+
fn bar(_: fn(&i32)) {}
12+
13+
fn main() {}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /