From 1ee857de6a8b004a4ef4939fe1583e5319968923 Mon Sep 17 00:00:00 2001 From: ychenfo Date: Sun, 9 Jan 2022 01:05:17 +0800 Subject: [PATCH] nac3core: format, fix clippy warning --- nac3core/src/codegen/expr.rs | 3 ++- nac3core/src/codegen/irrt/mod.rs | 9 +++------ nac3core/src/codegen/stmt.rs | 5 +---- nac3core/src/typecheck/type_inferencer/mod.rs | 2 +- runkernel/src/main.rs | 1 - 5 files changed, 7 insertions(+), 13 deletions(-) diff --git a/nac3core/src/codegen/expr.rs b/nac3core/src/codegen/expr.rs index 6c8af87d..9f1d1fa0 100644 --- a/nac3core/src/codegen/expr.rs +++ b/nac3core/src/codegen/expr.rs @@ -448,7 +448,8 @@ pub fn gen_call<'ctx, 'a, G: CodeGenerator>( if let Some(obj) = &obj { args.insert(0, FuncArg { name: "self".into(), ty: obj.0, default_value: None }); } - let params = args.iter().map(|arg| ctx.get_llvm_type(generator, arg.ty).into()).collect_vec(); + let params = + args.iter().map(|arg| ctx.get_llvm_type(generator, arg.ty).into()).collect_vec(); let fun_ty = if ctx.unifier.unioned(fun.0.ret, ctx.primitives.none) { ctx.ctx.void_type().fn_type(¶ms, false) } else { diff --git a/nac3core/src/codegen/irrt/mod.rs b/nac3core/src/codegen/irrt/mod.rs index af48bd20..6ba63b73 100644 --- a/nac3core/src/codegen/irrt/mod.rs +++ b/nac3core/src/codegen/irrt/mod.rs @@ -1,13 +1,10 @@ use super::CodeGenContext; use inkwell::{ - context::Context, - attributes::AttributeLoc, - memory_buffer::MemoryBuffer, - module::Module, + attributes::AttributeLoc, context::Context, memory_buffer::MemoryBuffer, module::Module, values::IntValue, }; -pub fn load_irrt<'ctx>(ctx: &'ctx Context) -> Module<'ctx> { +pub fn load_irrt(ctx: &Context) -> Module { let bitcode_buf = MemoryBuffer::create_from_memory_range( include_bytes!(concat!(env!("OUT_DIR"), "/irrt.bc")), "irrt_bitcode_buffer", @@ -19,7 +16,7 @@ pub fn load_irrt<'ctx>(ctx: &'ctx Context) -> Module<'ctx> { let function = irrt_mod.get_function(symbol).unwrap(); function.add_attribute(AttributeLoc::Function, ctx.create_enum_attribute(1, 0)); } - return irrt_mod; + irrt_mod } // repeated squaring method adapted from GNU Scientific Library: diff --git a/nac3core/src/codegen/stmt.rs b/nac3core/src/codegen/stmt.rs index 333ed351..9903bd88 100644 --- a/nac3core/src/codegen/stmt.rs +++ b/nac3core/src/codegen/stmt.rs @@ -1,10 +1,7 @@ use super::{ super::symbol_resolver::ValueEnum, expr::destructure_range, CodeGenContext, CodeGenerator, }; -use crate::{ - codegen::expr::gen_binop_expr, - typecheck::typedef::Type, -}; +use crate::{codegen::expr::gen_binop_expr, typecheck::typedef::Type}; use inkwell::{ types::BasicTypeEnum, values::{BasicValue, BasicValueEnum, PointerValue}, diff --git a/nac3core/src/typecheck/type_inferencer/mod.rs b/nac3core/src/typecheck/type_inferencer/mod.rs index ad32baaa..a6ca491b 100644 --- a/nac3core/src/typecheck/type_inferencer/mod.rs +++ b/nac3core/src/typecheck/type_inferencer/mod.rs @@ -688,7 +688,7 @@ impl<'a> Inferencer<'a> { location: args[0].location, custom, node: ExprKind::Constant { - value: ast::Constant::Int(val.clone()), + value: ast::Constant::Int(*val), kind: kind.clone(), }, }); diff --git a/runkernel/src/main.rs b/runkernel/src/main.rs index 5ce64d9c..68f7cb54 100644 --- a/runkernel/src/main.rs +++ b/runkernel/src/main.rs @@ -1,5 +1,4 @@ use std::env; -use libloading; static mut NOW: i64 = 0;