From 072a9e1c2b85291f6acbf21ab83f38ecd6325cb5 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Tue, 23 Jan 2024 20:01:23 +0000 Subject: [PATCH] Ignore `Debug` bounds on generics which may be redundant --- c-bindings-gen/src/types.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/c-bindings-gen/src/types.rs b/c-bindings-gen/src/types.rs index 0c4c1d8..bd04ba2 100644 --- a/c-bindings-gen/src/types.rs +++ b/c-bindings-gen/src/types.rs @@ -223,6 +223,15 @@ impl<'a, 'p: 'a> GenericTypes<'a, 'p> { if let Some(path) = types.maybe_resolve_path(&trait_bound.path, None) { if types.skip_path(&path) { continue; } if path == "Sized" { continue; } + if path == "core::fmt::Debug" { + // #[derive(Debug)] will add Debug bounds on each genericin the + // auto-generated impl. In cases where the existing generic + // bound already requires Debug this is redundant and should be + // ignored (which we do here). However, in cases where this is + // not redundant, this may cause spurious Debug impls which may + // fail to compile. + continue; + } if non_lifetimes_processed { return false; } non_lifetimes_processed = true; if path != "std::ops::Deref" && path != "core::ops::Deref" && -- 2.39.5