Skip to content

Commit 8fc17a2

Browse files
committed
Use resolved-type matching rather than as-written in trait exposing
1 parent e8ac901 commit 8fc17a2

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

c-bindings-gen/src/main.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,8 +1300,8 @@ fn writeln_impl<W: std::io::Write>(w: &mut W, w_uses: &mut HashSet<String, NonRa
13001300
write!(w, "#[must_use]\n#[no_mangle]\npub extern \"C\" fn {}_default() -> {} {{\n", ident, ident).unwrap();
13011301
write!(w, "\t{} {{ inner: ObjOps::heap_alloc(Default::default()), is_owned: true }}\n", ident).unwrap();
13021302
write!(w, "}}\n").unwrap();
1303-
} else if path_matches_nongeneric(&trait_path.1, &["core", "cmp", "PartialEq"]) {
1304-
} else if path_matches_nongeneric(&trait_path.1, &["core", "cmp", "Eq"]) {
1303+
} else if full_trait_path_opt.as_ref().map(|s| s.as_str()) == Some("core::cmp::PartialEq") {
1304+
} else if full_trait_path_opt.as_ref().map(|s| s.as_str()) == Some("core::cmp::Eq") {
13051305
writeln!(w, "/// Checks if two {}s contain equal inner contents.", ident).unwrap();
13061306
writeln!(w, "/// This ignores pointers and is_owned flags and looks at the values in fields.").unwrap();
13071307
if types.c_type_has_inner_from_path(&resolved_path) {
@@ -1327,7 +1327,7 @@ fn writeln_impl<W: std::io::Write>(w: &mut W, w_uses: &mut HashSet<String, NonRa
13271327
types.write_from_c_conversion_suffix(w, &ref_type, Some(&gen_types));
13281328

13291329
writeln!(w, " {{ true }} else {{ false }}\n}}").unwrap();
1330-
} else if path_matches_nongeneric(&trait_path.1, &["core", "hash", "Hash"]) {
1330+
} else if full_trait_path_opt.as_ref().map(|s| s.as_str()) == Some("core::hash::Hash") {
13311331
writeln!(w, "/// Generates a non-cryptographic 64-bit hash of the {}.", ident).unwrap();
13321332
write!(w, "#[no_mangle]\npub extern \"C\" fn {}_hash(o: &{}) -> u64 {{\n", ident, ident).unwrap();
13331333
if types.c_type_has_inner_from_path(&resolved_path) {
@@ -1347,8 +1347,8 @@ fn writeln_impl<W: std::io::Write>(w: &mut W, w_uses: &mut HashSet<String, NonRa
13471347
types.write_from_c_conversion_suffix(w, &ref_type, Some(&gen_types));
13481348
writeln!(w, ", &mut hasher);").unwrap();
13491349
writeln!(w, "\tcore::hash::Hasher::finish(&hasher)\n}}").unwrap();
1350-
} else if (path_matches_nongeneric(&trait_path.1, &["core", "clone", "Clone"]) || path_matches_nongeneric(&trait_path.1, &["Clone"])) &&
1351-
types.c_type_has_inner_from_path(&resolved_path) {
1350+
} else if (full_trait_path_opt.as_ref().map(|s| s.as_str()) == Some("core::clone::Clone") || path_matches_nongeneric(&trait_path.1, &["Clone"])) &&
1351+
types.c_type_has_inner_from_path(&resolved_path) {
13521352
writeln!(w, "impl Clone for {} {{", ident).unwrap();
13531353
writeln!(w, "\tfn clone(&self) -> Self {{").unwrap();
13541354
writeln!(w, "\t\tSelf {{").unwrap();
@@ -1401,7 +1401,7 @@ fn writeln_impl<W: std::io::Write>(w: &mut W, w_uses: &mut HashSet<String, NonRa
14011401

14021402
writeln!(w, "\t}}.into()\n}}").unwrap();
14031403
}
1404-
} else if path_matches_nongeneric(&trait_path.1, &["core", "fmt", "Debug"]) {
1404+
} else if full_trait_path_opt.as_ref().map(|s| s.as_str()) == Some("core::fmt::Debug") {
14051405
writeln!(w, "/// Get a string which allows debug introspection of a {} object", ident).unwrap();
14061406
writeln!(w, "pub extern \"C\" fn {}_debug_str_void(o: *const c_void) -> Str {{", ident).unwrap();
14071407

0 commit comments

Comments
 (0)