From 5aaf753ce9c1b52d2b8ae46c93b0e57e7ac0f4fc Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Thu, 20 Jul 2023 22:51:01 +0000 Subject: [PATCH] Handle all traits in type resolution, including no-export ones In the previous commit, we set up handling of no-export traits with only a single implementor. In order to utilize that, we need such traits to participate in type resolution, which we add support for here. --- c-bindings-gen/src/main.rs | 10 ++++++---- c-bindings-gen/src/types.rs | 9 ++------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/c-bindings-gen/src/main.rs b/c-bindings-gen/src/main.rs index 0a1d22a..ad2690c 100644 --- a/c-bindings-gen/src/main.rs +++ b/c-bindings-gen/src/main.rs @@ -73,7 +73,7 @@ fn maybe_convert_trait_impl(w: &mut W, trait_path: &syn::Path let mut for_obj_vec = Vec::new(); types.write_c_type(&mut for_obj_vec, for_ty, Some(generics), false); full_obj_path = String::from_utf8(for_obj_vec).unwrap(); - assert!(full_obj_path.starts_with(TypeResolver::generated_container_path())); + if !full_obj_path.starts_with(TypeResolver::generated_container_path()) { return; } for_obj = full_obj_path[TypeResolver::generated_container_path().len() + 2..].into(); } @@ -945,9 +945,11 @@ fn writeln_impl(w: &mut W, w_uses: &mut HashSet ImportResolver<'mod_lifetime, 'cr } }, syn::Item::Trait(t) => { - match export_status(&t.attrs) { - ExportStatus::Export|ExportStatus::NotImplementable => { - if let syn::Visibility::Public(_) = t.vis { - declared.insert(t.ident.clone(), DeclType::Trait(t)); - } - }, - _ => continue, + if let syn::Visibility::Public(_) = t.vis { + declared.insert(t.ident.clone(), DeclType::Trait(t)); } }, syn::Item::Mod(m) => { -- 2.30.2