Skip to content

Commit 2e51501

Browse files
committed
Fixed some typecheck errors
1 parent 795f187 commit 2e51501

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

cilly/src/v2/typecheck.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,8 @@ pub fn display_typecheck_err(
236236
) {
237237
eprintln!("{}", typecheck_err_to_string(root_idx, asm, sig, locals))
238238
}
239-
fn display_node(
239+
#[doc(hidden)]
240+
pub fn display_node(
240241
nodeidx: Interned<CILNode>,
241242
asm: &mut Assembly,
242243
sig: Interned<FnSig>,

rustc_codgen_clr_operand/src/constant.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use core::f16;
2+
use std::collections::HashSet;
23

34
use cilly::{
45
Assembly, CILNode, ClassRef, Const, Float, Int, Interned, IntoAsmIndex, MethodRef,
@@ -335,7 +336,9 @@ fn load_const_scalar<'tcx>(
335336
if matches!(scalar_type, Type::Ptr(_) | Type::FnPtr(_)) {
336337
return ctx.cast_ptr(ptr, const_type_idx);
337338
}
338-
return ctx.cast_ptr(ptr, Int::U8);
339+
let src_ptr = ctx.nptr(Int::U8);
340+
let ptr = ctx.cast_ptr(ptr, Int::U8);
341+
return ctx.transmute_on_stack(src_ptr, scalar_type, ptr);
339342
}
340343
};
341344

@@ -352,7 +355,11 @@ fn load_const_scalar<'tcx>(
352355
let val = ctx.alloc_node(Const::USize(
353356
u64::try_from(scalar_u128).expect("pointers must be smaller than 2^64"),
354357
));
355-
ctx.cast_ptr(val, scalar_type)
358+
let const_type = scalar_ty
359+
.builtin_deref(true)
360+
.map(|ty| ctx.type_from_cache(ty))
361+
.unwrap_or(Int::USize.into());
362+
ctx.cast_ptr(val, const_type)
356363
}
357364
}
358365
TyKind::Tuple(elements) => {

rustc_codgen_clr_operand/src/static_data.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,9 @@ pub fn add_allocation(
178178
}
179179
let tpe = ctx[tpe].clone();
180180
ctx.add_static(tpe, &*alloc_name, false, main_module_id, None, false);
181-
let uint8_ptr = ctx.nptr(Int::U8);
181+
182182
let ptr = ctx.static_addr(field_desc);
183-
let ptr = ctx.cast_ptr(ptr, uint8_ptr);
183+
let ptr = ctx.cast_ptr(ptr, Int::U8);
184184

185185
let initialzer: MethodDefIdx =
186186
allocation_initializer_method(const_allocation, &alloc_name, ctx, ptr.into(), true);
@@ -189,7 +189,7 @@ pub fn add_allocation(
189189
let root = ctx.alloc_root(cilly::CILRoot::call(*initialzer, []));
190190
ctx.add_cctor(&[root]);
191191

192-
(ctx.static_addr(field_desc))
192+
ctx.static_addr(field_desc)
193193
}
194194
}
195195
}

0 commit comments

Comments
 (0)