ref args,
ref destination,
from_hir_call,
- fn_span,
+ target,
..
} => {
self.check_operand(func, term_location);
}
let func_ty = func.ty(body, tcx);
- debug!("check_terminator: call, func_ty={:?}", func_ty);
debug!("func_ty.kind: {:?}", func_ty.kind());
- debug!(?fn_span);
+
let sig = match func_ty.kind() {
ty::FnDef(..) | ty::FnPtr(_) => func_ty.fn_sig(tcx),
_ => {
);
debug!(?sig);
let sig = self.normalize(sig, term_location);
- self.check_call_dest(body, term, &sig, destination, target, term_location);
+ self.check_call_dest(body, term, &sig, *destination, target, term_location);
self.prove_predicates(
sig.inputs_and_output
span_mirbug!(self, term, "call to {:?} with wrong # of args", sig);
}
- let call_arg = if let TerminatorKind::Call { func, .. } = &term.kind {
- let func_ty = func.ty(body, self.infcx.tcx);
- if let ty::FnDef(fn_did, substs) = func_ty.kind() {
- Some((*fn_did, *substs))
- } else {
- None
- }
+ let func_ty = if let TerminatorKind::Call { func, .. } = &term.kind {
+ Some(func.ty(body, self.infcx.tcx))
} else {
None
};
- debug!(?call_arg);
+ debug!(?func_ty);
for (n, (fn_arg, op_arg)) in iter::zip(sig.inputs(), args).enumerate() {
let op_arg_ty = op_arg.ty(body, self.tcx());
let op_arg_ty = self.normalize(op_arg_ty, term_location);
let category = if from_hir_call {
- ConstraintCategory::CallArgument(call_arg)
+ ConstraintCategory::CallArgument(func_ty)
} else {
ConstraintCategory::Boring
};
}
}
- CastKind::Misc => {
+ CastKind::PointerExposeAddress => {
let ty_from = op.ty(body, tcx);
let cast_ty_from = CastTy::from_ty(ty_from);
let cast_ty_to = CastTy::from_ty(*ty);
match (cast_ty_from, cast_ty_to) {
- (None, _)
- | (_, None | Some(CastTy::FnPtr))
- | (Some(CastTy::Float), Some(CastTy::Ptr(_)))
- | (Some(CastTy::Ptr(_) | CastTy::FnPtr), Some(CastTy::Float)) => {
- span_mirbug!(self, rvalue, "Invalid cast {:?} -> {:?}", ty_from, ty,)
+ (Some(CastTy::Ptr(_) | CastTy::FnPtr), Some(CastTy::Int(_))) => (),
+ _ => {
+ span_mirbug!(
+ self,
+ rvalue,
+ "Invalid PointerExposeAddress cast {:?} -> {:?}",
+ ty_from,
+ ty
+ )
+ }
+ }
+ }
+
+ CastKind::PointerFromExposedAddress => {
+ let ty_from = op.ty(body, tcx);
+ let cast_ty_from = CastTy::from_ty(ty_from);
+ let cast_ty_to = CastTy::from_ty(*ty);
+ match (cast_ty_from, cast_ty_to) {
+ (Some(CastTy::Int(_)), Some(CastTy::Ptr(_))) => (),
+ _ => {
+ span_mirbug!(
+ self,
+ rvalue,
+ "Invalid PointerFromExposedAddress cast {:?} -> {:?}",
+ ty_from,
+ ty
+ )
}
+ }
+ }
+
+ CastKind::Misc => {
+ let ty_from = op.ty(body, tcx);
+ let cast_ty_from = CastTy::from_ty(ty_from);
+ let cast_ty_to = CastTy::from_ty(*ty);
+ // Misc casts are either between floats and ints, or one ptr type to another.
+ match (cast_ty_from, cast_ty_to) {
(
- Some(CastTy::Int(_)),
- Some(CastTy::Int(_) | CastTy::Float | CastTy::Ptr(_)),
+ Some(CastTy::Int(_) | CastTy::Float),
+ Some(CastTy::Int(_) | CastTy::Float),
)
- | (Some(CastTy::Float), Some(CastTy::Int(_) | CastTy::Float))
- | (Some(CastTy::Ptr(_)), Some(CastTy::Int(_) | CastTy::Ptr(_)))
- | (Some(CastTy::FnPtr), Some(CastTy::Int(_) | CastTy::Ptr(_))) => (),
+ | (Some(CastTy::Ptr(_) | CastTy::FnPtr), Some(CastTy::Ptr(_))) => (),
+ _ => {
+ span_mirbug!(
+ self,
+ rvalue,
+ "Invalid Misc cast {:?} -> {:?}",
+ ty_from,
+ ty,
+ )
+ }
}
}
}