Skip to content

Commit fbf7ebf

Browse files
Anonymize binders in tail call sig
1 parent 6d091b2 commit fbf7ebf

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

compiler/rustc_mir_build/src/check_tail_calls.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ impl<'tcx> TailCallCkVisitor<'_, 'tcx> {
6363
"`become` outside of functions should have been disallowed by hit_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+
//~^ WARN the feature `explicit_tail_calls` is incomplete
6+
7+
fn foo(x: fn(&i32)) {
8+
become bar(x);
9+
}
10+
11+
fn bar(_: fn(&i32)) {}
12+
13+
fn main() {}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
warning: the feature `explicit_tail_calls` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/higher-ranked-arg.rs:4:12
3+
|
4+
LL | #![feature(explicit_tail_calls)]
5+
| ^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: see issue #112788 <https://github.com/rust-lang/rust/issues/112788> for more information
8+
= note: `#[warn(incomplete_features)]` on by default
9+
10+
warning: 1 warning emitted
11+

0 commit comments

Comments
 (0)