Skip to content

Commit b1e4463

Browse files
committed
add an error message if you attempt to pass indirect args via guaranteed tail calls.
1 parent ec64d6f commit b1e4463

File tree

1 file changed

+7
-0
lines changed
  • compiler/rustc_codegen_ssa/src/mir

1 file changed

+7
-0
lines changed

compiler/rustc_codegen_ssa/src/mir/block.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,13 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
10451045
// to generate `lifetime_end` when the call returns.
10461046
let mut lifetime_ends_after_call: Vec<(Bx::Value, Size)> = Vec::new();
10471047
'make_args: for (i, arg) in first_args.iter().enumerate() {
1048+
if tail && matches!(fn_abi.args[i].mode, PassMode::Indirect { .. }) {
1049+
bug!(
1050+
r"Arguments using PassMode::Indirect are currently not supported for tail calls.
1051+
See https://github.com/rust-lang/rust/pull/144232#discussion_r2218543841 for more information."
1052+
);
1053+
}
1054+
10481055
let mut op = self.codegen_operand(bx, &arg.node);
10491056

10501057
if let (0, Some(ty::InstanceKind::Virtual(_, idx))) = (i, instance.map(|i| i.def)) {

0 commit comments

Comments
 (0)