summaryrefslogtreecommitdiff
path: root/src/codegen/derive_debug.rs
diff options
context:
space:
mode:
authorNick Fitzgerald <fitzgen@gmail.com>2017-09-05 11:44:01 -0700
committerNick Fitzgerald <fitzgen@gmail.com>2017-09-06 13:46:58 -0700
commit310890c828c1b9d6c3de8bb61e67080e7d1f1966 (patch)
tree5cb2914c0e421589662d32262915230c6a78520b /src/codegen/derive_debug.rs
parentc1965e75c1c862aaf3d63c2cfd314be01d096dcf (diff)
Don't try and debug format blacklisted types when generating `impl Debug` blocks
Diffstat (limited to 'src/codegen/derive_debug.rs')
-rw-r--r--src/codegen/derive_debug.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/codegen/derive_debug.rs b/src/codegen/derive_debug.rs
index 066af339..82456797 100644
--- a/src/codegen/derive_debug.rs
+++ b/src/codegen/derive_debug.rs
@@ -53,7 +53,7 @@ pub fn gen_debug_impl(
impl X {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
write!(f, $format_string $tokens)
- }
+ }
});
match impl_.unwrap().node {
@@ -127,6 +127,12 @@ impl<'a> ImplDebug<'a> for Item {
) -> Option<(String, Vec<TokenTree>)> {
let name_ident = ctx.rust_ident_raw(name);
+ // We don't know if blacklisted items `impl Debug` or not, so we can't
+ // add them to the format string we're building up.
+ if !ctx.whitelisted_items().contains(&self.id()) {
+ return None;
+ }
+
let ty = match self.as_type() {
Some(ty) => ty,
None => {
@@ -168,7 +174,7 @@ impl<'a> ImplDebug<'a> for Item {
} else {
debug_print(ctx, name, name_ident)
}
- }
+ }
// The generic is not required to implement Debug, so we can not debug print that type
TypeKind::TypeParam => {