Skip to content

Commit 6f03fc7

Browse files
committed
Mark Type as unsized, and fix TomBebbington#5
1 parent 814225f commit 6f03fc7

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/engine.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@ impl<'a> JitEngine {
105105
let sig = function.get_signature();
106106
assert_eq!(Type::get::<R>(ctx), sig.get_return());
107107
let arg = Type::get::<A>(ctx);
108-
if let Some(args) = StructType::cast(arg) {
109-
assert_eq!(sig.get_params(), args.get_elements());
108+
assert_eq!(sig.get_params(), if let Some(args) = StructType::cast(arg) {
109+
args.get_elements()
110110
} else {
111-
assert_eq!(arg, sig.get_return());
112-
}
111+
vec![arg]
112+
});
113113
}
114114
unsafe {
115115
cb(self.get_function::<A, R>(function));

src/ty.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ use context::{Context, GetContext};
66
use target::TargetData;
77
use util::{self, CastFrom};
88
use std::{fmt, mem};
9+
use std::marker::PhantomData;
910
use std::iter::Iterator;
1011
use std::ops::Deref;
1112

1213
/// Defines how a value should be laid out in memory.
13-
pub struct Type;
14+
pub struct Type(PhantomData<[u8]>);
1415
native_ref!(&Type = LLVMTypeRef);
1516
impl Type {
1617
#[inline(always)]
@@ -105,7 +106,7 @@ impl StructType {
105106
})
106107
}
107108
/// Returns the elements that make up this struct.
108-
pub fn get_elements(&self) -> Vec<Type> {
109+
pub fn get_elements(&self) -> Vec<&Type> {
109110
unsafe {
110111
let size = core::LLVMCountStructElementTypes(self.into());
111112
let mut els:Vec<_> = (0..size).map(|_| mem::uninitialized()).collect();

0 commit comments

Comments
 (0)