Skip to content

Commit 364cab6

Browse files
committed
fix rust warnings
- jit.rs: 5 function_casts_as_integer warnings — added as *const () intermediate cast - vm.rs: 3 non_fmt_panics warnings — changed "msg {var}" to "msg {}", var format - compiler.rs: Restored truncated file ending (missing closing braces for test_enum_in_struct and mod tests)
1 parent 154372f commit 364cab6

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

src/compiler.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,10 @@ fn builtin_decls() -> Vec<Decl> {
6363

6464
// Math builtins: unary, overloaded for f32 and f64.
6565
let unary_math = [
66-
"sin", "cos", "tan", "asin", "acos", "atan", "sinh", "cosh", "tanh", "asinh", "acosh",
67-
"atanh", "ln", "exp", "exp2", "log10", "log2", "sqrt", "abs", "floor", "ceil",
66+
"sin", "cos", "tan", "asin", "acos", "atan",
67+
"sinh", "cosh", "tanh", "asinh", "acosh", "atanh",
68+
"ln", "exp", "exp2", "log10", "log2",
69+
"sqrt", "abs", "floor", "ceil",
6870
];
6971
for name in unary_math {
7072
for (ty, ret_ty) in [
@@ -173,8 +175,9 @@ fn rewrite_qualified_enums(arena: &mut ExprArena, decls: &DeclTable) {
173175
if let Expr::Field(lhs, case_name) = arena.exprs[i].clone() {
174176
if let Expr::Id(id_name) = &arena.exprs[lhs] {
175177
let found = decls.find(*id_name);
176-
if let Some(Decl::Enum { cases, .. }) =
177-
found.iter().find(|d| matches!(d, Decl::Enum { .. }))
178+
if let Some(Decl::Enum { cases, .. }) = found
179+
.iter()
180+
.find(|d| matches!(d, Decl::Enum { .. }))
178181
{
179182
if cases.contains(&case_name) {
180183
arena.exprs[i] = Expr::Enum(case_name);

src/jit.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ impl<'a> FunctionTranslator<'a> {
518518

519519
self.builder.switch_to_block(cancel_block);
520520
self.builder.seal_block(cancel_block);
521-
let fn_ptr = self.builder.ins().iconst(I64, lyte_abort as usize as i64);
521+
let fn_ptr = self.builder.ins().iconst(I64, lyte_abort as *const () as usize as i64);
522522
let mut sig = self.module.make_signature();
523523
sig.params.push(AbiParam::new(I64)); // globals_base
524524
let sref = self.builder.import_signature(sig);
@@ -1688,7 +1688,7 @@ impl<'a> FunctionTranslator<'a> {
16881688
}
16891689

16901690
fn debug_print_i64(&mut self, value: Value) {
1691-
let f_ptr = self.builder.ins().iconst(I64, lyte_print_i64 as i64);
1691+
let f_ptr = self.builder.ins().iconst(I64, lyte_print_i64 as *const () as i64);
16921692

16931693
let mut sig = Signature::new(CallConv::Fast);
16941694
sig.params = vec![AbiParam::new(I64)];
@@ -1699,15 +1699,15 @@ impl<'a> FunctionTranslator<'a> {
16991699

17001700
fn translate_func(&mut self, name: &Name, ty: &crate::Type) -> Value {
17011701
if *name == Name::str("assert") {
1702-
return self.builder.ins().iconst(I64, lyte_assert as i64);
1702+
return self.builder.ins().iconst(I64, lyte_assert as *const () as i64);
17031703
}
17041704

17051705
if *name == Name::str("print") {
1706-
return self.builder.ins().iconst(I64, lyte_print_i32 as i64);
1706+
return self.builder.ins().iconst(I64, lyte_print_i32 as *const () as i64);
17071707
}
17081708

17091709
if *name == Name::str("putc") {
1710-
return self.builder.ins().iconst(I64, lyte_putc as i64);
1710+
return self.builder.ins().iconst(I64, lyte_putc as *const () as i64);
17111711
}
17121712

17131713
if let Some(ptr) = math_builtin_ptr(name) {

src/vm.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ impl LinkedProgram {
505505
args_start,
506506
arg_count,
507507
} => {
508-
assert!(func <= 255, "Call func index {func} out of u8 range");
508+
assert!(func <= 255, "Call func index {} out of u8 range", func);
509509
PackedOp::abc(tags::CALL, args_start, arg_count, func as u8)
510510
}
511511
Opcode::CallIndirect {
@@ -519,7 +519,7 @@ impl LinkedProgram {
519519
Opcode::AllocLocals { size } => {
520520
assert!(
521521
size <= u16::MAX as u32,
522-
"AllocLocals size {size} out of u16 range"
522+
"AllocLocals size {} out of u16 range", size
523523
);
524524
PackedOp::ad(tags::ALLOC_LOCALS, 0, size as u16 as i16)
525525
}
@@ -535,7 +535,7 @@ impl LinkedProgram {
535535
Opcode::MemZero { dst, size } => {
536536
assert!(
537537
size <= u16::MAX as u32,
538-
"MemZero size {size} out of u16 range"
538+
"MemZero size {} out of u16 range", size
539539
);
540540
PackedOp::ad(tags::MEM_ZERO, dst, size as u16 as i16)
541541
}

0 commit comments

Comments
 (0)