diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2017-09-06 17:22:54 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-06 17:22:54 -0500 |
commit | cb1059786df114cae72b8baea038dc5ea638269d (patch) | |
tree | 8a16bb41fb191db502b810c3da7f67ed19c027df /src/codegen/derive_debug.rs | |
parent | 1e49750a4effcc1d773e667aabf821dde2cebfab (diff) | |
parent | 74e2aeab89cec911ccaecdc349c27e896f40f8f7 (diff) |
Auto merge of #950 - fitzgen:no-derive-copy-for-blacklisted-types, r=emilio
Derive + blacklisted types
* [X] document blacklisting + derive interaction
* [X] derive `Copy`
* [X] derive `Debug`
* [X] `--impl-debug`
* [x] derive `Default`
* [x] derive `Hash`
* [x] derive `PartialEq`
Diffstat (limited to 'src/codegen/derive_debug.rs')
-rw-r--r-- | src/codegen/derive_debug.rs | 10 |
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 => { |