From d9df2cde91cc85f0fe1232ba864baecca4b09c1f Mon Sep 17 00:00:00 2001 From: Tom Anderson Date: Mon, 12 Aug 2024 23:05:14 +1000 Subject: [PATCH] tweak type list exporter --- src/builder/ty/util/exporter.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/builder/ty/util/exporter.rs b/src/builder/ty/util/exporter.rs index dd24845..859f8d6 100644 --- a/src/builder/ty/util/exporter.rs +++ b/src/builder/ty/util/exporter.rs @@ -12,10 +12,10 @@ struct TypeListExporter { impl TypeListExporter { /// Create a new empty instance. - pub fn new(out_dir: impl AsRef, dependencies: Vec) -> Self { + pub fn new(out_dir: impl AsRef) -> Self { Self { out_dir: out_dir.as_ref().to_owned(), - dependencies, + dependencies: Vec::new(), } } @@ -27,9 +27,8 @@ impl TypeListExporter { impl TypeVisitor for TypeListExporter { fn visit(&mut self) { + // Ensure that the type is an exportable type (otherwise likely just a primitive) let Some(dep) = Dependency::from_ty::() else { - // Type must be a primitive, so recurse to ensure all generics are properly exported. - return; }; @@ -52,8 +51,11 @@ impl TypeVisitor for TypeListExporter { pub fn export_with_dependencies( out_dir: impl AsRef, ) -> Result, ExportError> { - // Ensure any generics used in the type are exported - let mut exporter = TypeListExporter::new(&out_dir, T::dependencies()); + // Set up an exporter + let mut exporter = TypeListExporter::new(&out_dir); + + // Export all dependencies and generics for the type + T::visit_dependencies(&mut exporter); T::visit_generics(&mut exporter); let mut dependencies = exporter.into_inner();