]> git.bitcoin.ninja Git - ldk-c-bindings/commitdiff
Detect a type as clonable with an explicit `impl Clone`
authorMatt Corallo <git@bluematt.me>
Sun, 26 Sep 2021 06:19:07 +0000 (06:19 +0000)
committerMatt Corallo <git@bluematt.me>
Sun, 26 Sep 2021 06:19:07 +0000 (06:19 +0000)
These stay `impl Clone` even after the pretty-print rustc pass so
we cannot only match `core::clone::Clone`

c-bindings-gen/src/main.rs

index f56f30ff34e04c2d360822b1d2aa670d4e0b083a..9d6f9cfeadad7717594a5d878d19e2a0ac2a1af2 100644 (file)
@@ -1853,7 +1853,8 @@ fn walk_ast<'a>(ast_storage: &'a FullLibraryAST, crate_types: &mut CrateTypes<'a
                                syn::Item::Impl(i) => {
                                        if let &syn::Type::Path(ref p) = &*i.self_ty {
                                                if let Some(trait_path) = i.trait_.as_ref() {
-                                                       if path_matches_nongeneric(&trait_path.1, &["core", "clone", "Clone"]) {
+                                                       if path_matches_nongeneric(&trait_path.1, &["core", "clone", "Clone"]) ||
+                                                          path_matches_nongeneric(&trait_path.1, &["Clone"]) {
                                                                if let Some(full_path) = import_resolver.maybe_resolve_path(&p.path, None) {
                                                                        crate_types.set_clonable("crate::".to_owned() + &full_path);
                                                                }