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:
@@ -60,9 +60,13 @@ impl<'tcx> TailCallCkVisitor<'_, 'tcx> {
|
|||||||
let BodyTy::Fn(caller_sig) = self.thir.body_type else {
|
let BodyTy::Fn(caller_sig) = self.thir.body_type else {
|
||||||
span_bug!(
|
span_bug!(
|
||||||
call.span,
|
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 {
|
let ExprKind::Scope { value, .. } = call.kind else {
|
||||||
span_bug!(call.span, "expected scope, found: {call:?}")
|
span_bug!(call.span, "expected scope, found: {call:?}")
|
||||||
|
|||||||
13
tests/ui/explicit-tail-calls/higher-ranked-arg.rs
Normal file
13
tests/ui/explicit-tail-calls/higher-ranked-arg.rs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
// Regression test for <https://github.com/rust-lang/rust/issues/144826>.
|
||||||
|
//@ check-pass
|
||||||
|
|
||||||
|
#![feature(explicit_tail_calls)]
|
||||||
|
#![expect(incomplete_features)]
|
||||||
|
|
||||||
|
fn foo(x: fn(&i32)) {
|
||||||
|
become bar(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn bar(_: fn(&i32)) {}
|
||||||
|
|
||||||
|
fn main() {}
|
||||||
Reference in New Issue
Block a user