From 20d180b6b0f064c8fe197ac52d93339abe908779 Mon Sep 17 00:00:00 2001 From: Kurt Wolf Date: Sun, 15 Sep 2024 14:39:01 -0700 Subject: [PATCH] wip --- libninja/src/rust/codegen/ty.rs | 7 +++---- mir_rust/src/enum.rs | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/libninja/src/rust/codegen/ty.rs b/libninja/src/rust/codegen/ty.rs index 56d8606..8b6c3d2 100644 --- a/libninja/src/rust/codegen/ty.rs +++ b/libninja/src/rust/codegen/ty.rs @@ -1,8 +1,7 @@ -use proc_macro2::TokenStream; -use quote::quote; - use hir::HirSpec; use mir::Ty; +use proc_macro2::TokenStream; +use quote::quote; use crate::rust::codegen::ToRustIdent; use crate::rust::lower_hir::HirFieldExt; @@ -85,7 +84,7 @@ impl ToRustType for Ty { Ty::Array(_) => true, Ty::Model(name) => { let model = spec.get_record(name.as_str()).expect("Model not found"); - model.fields().all(|f| f.implements_default(spec)) + model.fields().count() > 0 && model.fields().all(|f| f.implements_default(spec)) } Ty::Unit => true, Ty::Any(_) => true, diff --git a/mir_rust/src/enum.rs b/mir_rust/src/enum.rs index 5fe2bbe..f968f98 100644 --- a/mir_rust/src/enum.rs +++ b/mir_rust/src/enum.rs @@ -29,7 +29,7 @@ pub fn lower_enum(e: &hir::Enum, derives: &[String]) -> Enum