提交 a05914e2 编写于 作者: R Ralf Jung

check return type even for uninhabited case

上级 5b75ec0a
......@@ -375,18 +375,19 @@ fn eval_fn_call(
return err!(FunctionArgCountMismatch);
}
// Don't forget to check the return type!
let callee_ret = self.eval_place(&mir::Place::Local(mir::RETURN_PLACE))?;
if let Some(caller_ret) = dest {
let callee_ret = self.eval_place(&mir::Place::Local(mir::RETURN_PLACE))?;
if !Self::check_argument_compat(caller_ret.layout, callee_ret.layout) {
return err!(FunctionRetMismatch(
caller_ret.layout.ty, callee_ret.layout.ty
));
}
} else {
// FIXME: The caller thinks this function cannot return. How do
// we verify that the callee agrees?
// On the plus side, the the callee ever writes to its return place,
// that will be detected as UB (because we set that to NULL above).
if !callee_ret.layout.abi.is_uninhabited() {
return err!(FunctionRetMismatch(
self.tcx.types.never, callee_ret.layout.ty
));
}
}
Ok(())
})();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册