From b47ac1b89bc651425eca4fb25358484993313350 Mon Sep 17 00:00:00 2001 From: David Mak Date: Wed, 13 Dec 2023 18:15:22 +0800 Subject: [PATCH] core: Minor formatting cleanup --- nac3artiq/src/symbol_resolver.rs | 1 - nac3core/src/codegen/expr.rs | 2 +- nac3core/src/codegen/stmt.rs | 7 +++---- nac3core/src/toplevel/type_annotation.rs | 22 +++++++++++----------- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/nac3artiq/src/symbol_resolver.rs b/nac3artiq/src/symbol_resolver.rs index 18e5fa6d..631e2de2 100644 --- a/nac3artiq/src/symbol_resolver.rs +++ b/nac3artiq/src/symbol_resolver.rs @@ -1064,7 +1064,6 @@ impl InnerResolver { impl SymbolResolver for Resolver { fn get_default_param_value(&self, expr: &ast::Expr) -> Option { let ast::ExprKind::Name { id, .. } = &expr.node else { - unreachable!("only for resolving names") }; diff --git a/nac3core/src/codegen/expr.rs b/nac3core/src/codegen/expr.rs index 7f5881a2..3a894a40 100644 --- a/nac3core/src/codegen/expr.rs +++ b/nac3core/src/codegen/expr.rs @@ -1634,7 +1634,7 @@ pub fn gen_expr<'ctx, G: CodeGenerator>( let ty = func.custom.unwrap(); let TypeEnum::TFunc(sign) = &*ctx.unifier.get_ty(ty) else { unreachable!() - }; + }; sign.clone() }; diff --git a/nac3core/src/codegen/stmt.rs b/nac3core/src/codegen/stmt.rs index 0e0449ef..f15c2b93 100644 --- a/nac3core/src/codegen/stmt.rs +++ b/nac3core/src/codegen/stmt.rs @@ -596,11 +596,10 @@ pub fn exn_constructor<'ctx>( let zelf = zelf.to_basic_value_enum(ctx, generator, zelf_ty)?.into_pointer_value(); let int32 = ctx.ctx.i32_type(); let zero = int32.const_zero(); - let zelf_id = { - let TypeEnum::TObj { obj_id, .. } = &*ctx.unifier.get_ty(zelf_ty) else { - unreachable!() - }; + let zelf_id = if let TypeEnum::TObj { obj_id, .. } = &*ctx.unifier.get_ty(zelf_ty) { obj_id.0 + } else { + unreachable!() }; let defs = ctx.top_level.definitions.read(); let def = defs[zelf_id].read(); diff --git a/nac3core/src/toplevel/type_annotation.rs b/nac3core/src/toplevel/type_annotation.rs index a44de76e..4703bca2 100644 --- a/nac3core/src/toplevel/type_annotation.rs +++ b/nac3core/src/toplevel/type_annotation.rs @@ -390,17 +390,17 @@ pub fn get_type_from_type_annotation_kinds( ])) } - let param_ty = params - .iter() - .map(|x| { - get_type_from_type_annotation_kinds( - top_level_defs, - unifier, - x, - subst_list - ) - }) - .collect::, _>>()?; + let param_ty = params + .iter() + .map(|x| { + get_type_from_type_annotation_kinds( + top_level_defs, + unifier, + x, + subst_list + ) + }) + .collect::, _>>()?; let subst = { // check for compatible range -- 2.44.2