Skip to content

Commit ec056d5

Browse files
committed
re-do argument passing one more time to finally be sane
1 parent b8a40aa commit ec056d5

File tree

5 files changed

+189
-193
lines changed

5 files changed

+189
-193
lines changed

src/librustc/ich/impls_ty.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,7 @@ for ::mir::interpret::EvalErrorKind<'gcx, O> {
512512
mem::discriminant(&self).hash_stable(hcx, hasher);
513513

514514
match *self {
515+
FunctionArgCountMismatch |
515516
DanglingPointerDeref |
516517
DoubleFree |
517518
InvalidMemoryAccess |
@@ -558,7 +559,11 @@ for ::mir::interpret::EvalErrorKind<'gcx, O> {
558559
},
559560
ReferencedConstant(ref err) => err.hash_stable(hcx, hasher),
560561
MachineError(ref err) => err.hash_stable(hcx, hasher),
561-
FunctionPointerTyMismatch(a, b) => {
562+
FunctionAbiMismatch(a, b) => {
563+
a.hash_stable(hcx, hasher);
564+
b.hash_stable(hcx, hasher)
565+
},
566+
FunctionArgMismatch(a, b) => {
562567
a.hash_stable(hcx, hasher);
563568
b.hash_stable(hcx, hasher)
564569
},

src/librustc/mir/interpret/error.rs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
use std::{fmt, env};
1212

1313
use mir;
14-
use ty::{FnSig, Ty, layout};
14+
use ty::{Ty, layout};
1515
use ty::layout::{Size, Align};
1616
use rustc_data_structures::sync::Lrc;
17+
use rustc_target::spec::abi::Abi;
1718

1819
use super::{
1920
Pointer, Lock, AccessKind
@@ -182,7 +183,10 @@ pub enum EvalErrorKind<'tcx, O> {
182183
/// This variant is used by machines to signal their own errors that do not
183184
/// match an existing variant
184185
MachineError(String),
185-
FunctionPointerTyMismatch(FnSig<'tcx>, FnSig<'tcx>),
186+
187+
FunctionAbiMismatch(Abi, Abi),
188+
FunctionArgMismatch(Ty<'tcx>, Ty<'tcx>),
189+
FunctionArgCountMismatch,
186190
NoMirFor(String),
187191
UnterminatedCString(Pointer),
188192
DanglingPointerDeref,
@@ -290,8 +294,8 @@ impl<'tcx, O> EvalErrorKind<'tcx, O> {
290294
use self::EvalErrorKind::*;
291295
match *self {
292296
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",
295299
InvalidMemoryAccess =>
296300
"tried to access memory through an invalid pointer",
297301
DanglingPointerDeref =>
@@ -459,9 +463,15 @@ impl<'tcx, O: fmt::Debug> fmt::Debug for EvalErrorKind<'tcx, O> {
459463
write!(f, "type validation failed: {}", err)
460464
}
461465
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"),
465475
BoundsCheck { ref len, ref index } =>
466476
write!(f, "index out of bounds: the len is {:?} but the index is {:?}", len, index),
467477
ReallocatedWrongMemoryKind(ref old, ref new) =>

src/librustc/ty/structural_impls.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,10 +487,12 @@ impl<'a, 'tcx, O: Lift<'tcx>> Lift<'tcx> for interpret::EvalErrorKind<'a, O> {
487487
use ::mir::interpret::EvalErrorKind::*;
488488
Some(match *self {
489489
MachineError(ref err) => MachineError(err.clone()),
490-
FunctionPointerTyMismatch(a, b) => FunctionPointerTyMismatch(
490+
FunctionAbiMismatch(a, b) => FunctionAbiMismatch(a, b),
491+
FunctionArgMismatch(a, b) => FunctionArgMismatch(
491492
tcx.lift(&a)?,
492493
tcx.lift(&b)?,
493494
),
495+
FunctionArgCountMismatch => FunctionArgCountMismatch,
494496
NoMirFor(ref s) => NoMirFor(s.clone()),
495497
UnterminatedCString(ptr) => UnterminatedCString(ptr),
496498
DanglingPointerDeref => DanglingPointerDeref,

0 commit comments

Comments
 (0)