|
11 | 11 | use std::{fmt, env};
|
12 | 12 |
|
13 | 13 | use mir;
|
14 |
| -use ty::{FnSig, Ty, layout}; |
| 14 | +use ty::{Ty, layout}; |
15 | 15 | use ty::layout::{Size, Align};
|
16 | 16 | use rustc_data_structures::sync::Lrc;
|
| 17 | +use rustc_target::spec::abi::Abi; |
17 | 18 |
|
18 | 19 | use super::{
|
19 | 20 | Pointer, Lock, AccessKind
|
@@ -182,7 +183,10 @@ pub enum EvalErrorKind<'tcx, O> {
|
182 | 183 | /// This variant is used by machines to signal their own errors that do not
|
183 | 184 | /// match an existing variant
|
184 | 185 | MachineError(String),
|
185 |
| - FunctionPointerTyMismatch(FnSig<'tcx>, FnSig<'tcx>), |
| 186 | + |
| 187 | + FunctionAbiMismatch(Abi, Abi), |
| 188 | + FunctionArgMismatch(Ty<'tcx>, Ty<'tcx>), |
| 189 | + FunctionArgCountMismatch, |
186 | 190 | NoMirFor(String),
|
187 | 191 | UnterminatedCString(Pointer),
|
188 | 192 | DanglingPointerDeref,
|
@@ -290,8 +294,8 @@ impl<'tcx, O> EvalErrorKind<'tcx, O> {
|
290 | 294 | use self::EvalErrorKind::*;
|
291 | 295 | match *self {
|
292 | 296 | MachineError(ref inner) => inner,
|
293 |
| - FunctionPointerTyMismatch(..) => |
294 |
| - "tried to call a function through a function pointer of a different type", |
| 297 | + FunctionAbiMismatch(..) | FunctionArgMismatch(..) | FunctionArgCountMismatch => |
| 298 | + "tried to call a function through a function pointer of incompatible type", |
295 | 299 | InvalidMemoryAccess =>
|
296 | 300 | "tried to access memory through an invalid pointer",
|
297 | 301 | DanglingPointerDeref =>
|
@@ -459,9 +463,15 @@ impl<'tcx, O: fmt::Debug> fmt::Debug for EvalErrorKind<'tcx, O> {
|
459 | 463 | write!(f, "type validation failed: {}", err)
|
460 | 464 | }
|
461 | 465 | NoMirFor(ref func) => write!(f, "no mir for `{}`", func),
|
462 |
| - FunctionPointerTyMismatch(sig, got) => |
463 |
| - write!(f, "tried to call a function with sig {} through a \ |
464 |
| - function pointer of type {}", sig, got), |
| 466 | + FunctionAbiMismatch(caller_abi, callee_abi) => |
| 467 | + write!(f, "tried to call a function with ABI {:?} using caller ABI {:?}", |
| 468 | + callee_abi, caller_abi), |
| 469 | + FunctionArgMismatch(caller_ty, callee_ty) => |
| 470 | + write!(f, "tried to call a function with argument of type {:?} \ |
| 471 | + passing data of type {:?}", |
| 472 | + callee_ty, caller_ty), |
| 473 | + FunctionArgCountMismatch => |
| 474 | + write!(f, "tried to call a function with incorrect number of arguments"), |
465 | 475 | BoundsCheck { ref len, ref index } =>
|
466 | 476 | write!(f, "index out of bounds: the len is {:?} but the index is {:?}", len, index),
|
467 | 477 | ReallocatedWrongMemoryKind(ref old, ref new) =>
|
|
0 commit comments