Call methods explicitly on traits to avoid to deref recursion
authorMatt Corallo <git@bluematt.me>
Wed, 22 Sep 2021 23:15:20 +0000 (23:15 +0000)
committerMatt Corallo <git@bluematt.me>
Thu, 23 Sep 2021 17:49:46 +0000 (17:49 +0000)
c-bindings-gen/src/types.rs

index 96a4135f9c1f3800a00a4eb7239d653a9cb95879..efd6b9afcb24e48bbfef296dcb5e01984816a6b4 100644 (file)
@@ -1922,7 +1922,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                                                DeclType::EnumIgnored|DeclType::StructImported if !is_ref =>
                                                        write!(w, "crate::{} {{ inner: ObjOps::heap_alloc(", decl_path).unwrap(),
                                                DeclType::Trait(_) if is_ref => write!(w, "").unwrap(),
                                                DeclType::EnumIgnored|DeclType::StructImported if !is_ref =>
                                                        write!(w, "crate::{} {{ inner: ObjOps::heap_alloc(", decl_path).unwrap(),
                                                DeclType::Trait(_) if is_ref => write!(w, "").unwrap(),
-                                               DeclType::Trait(_) if !is_ref => {},
+                                               DeclType::Trait(_) if !is_ref => write!(w, "Into::into(").unwrap(),
                                                _ => panic!("{:?}", decl_path),
                                        }
                                });
                                                _ => panic!("{:?}", decl_path),
                                        }
                                });
@@ -1948,7 +1948,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                                                // for use when a Rust trait method returns an associated type.
                                                // Because all of our C traits implement From<RustTypesImplementingTraits>
                                                // we can just call .into() here and be done.
                                                // for use when a Rust trait method returns an associated type.
                                                // Because all of our C traits implement From<RustTypesImplementingTraits>
                                                // we can just call .into() here and be done.
-                                               write!(w, ".into()").unwrap()
+                                               write!(w, ")").unwrap()
                                        },
                                        _ => unimplemented!(),
                                });
                                        },
                                        _ => unimplemented!(),
                                });