From 2ea1d2d0077914282d87cfd66897410f6214daa7 Mon Sep 17 00:00:00 2001 From: Federico Ravasio Date: Fri, 23 Jun 2017 12:47:43 +0200 Subject: [PATCH 1/2] Correctly iterate on keys/values when debugging BTreeMap::{Keys,Values}. --- src/liballoc/btree/map.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/liballoc/btree/map.rs b/src/liballoc/btree/map.rs index d73c0254a7457..6656c90d7e9c7 100644 --- a/src/liballoc/btree/map.rs +++ b/src/liballoc/btree/map.rs @@ -336,7 +336,7 @@ pub struct Keys<'a, K: 'a, V: 'a> { #[stable(feature = "collection_debug", since = "1.17.0")] impl<'a, K: 'a + fmt::Debug, V: 'a + fmt::Debug> fmt::Debug for Keys<'a, K, V> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_list().entries(self.inner.clone()).finish() + f.debug_list().entries(self.clone()).finish() } } @@ -355,7 +355,7 @@ pub struct Values<'a, K: 'a, V: 'a> { #[stable(feature = "collection_debug", since = "1.17.0")] impl<'a, K: 'a + fmt::Debug, V: 'a + fmt::Debug> fmt::Debug for Values<'a, K, V> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_list().entries(self.inner.clone()).finish() + f.debug_list().entries(self.clone()).finish() } } From 545bfcd864683a6e774762cf5f872615de7b1b51 Mon Sep 17 00:00:00 2001 From: Federico Ravasio Date: Fri, 23 Jun 2017 12:48:19 +0200 Subject: [PATCH 2/2] Relax Debug constraints when debugging {HashMap,BTreeMap}::{Keys,Values}. Fixed #41924. --- src/liballoc/btree/map.rs | 4 ++-- src/libstd/collections/hash/map.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/liballoc/btree/map.rs b/src/liballoc/btree/map.rs index 6656c90d7e9c7..a51c70159db4d 100644 --- a/src/liballoc/btree/map.rs +++ b/src/liballoc/btree/map.rs @@ -334,7 +334,7 @@ pub struct Keys<'a, K: 'a, V: 'a> { } #[stable(feature = "collection_debug", since = "1.17.0")] -impl<'a, K: 'a + fmt::Debug, V: 'a + fmt::Debug> fmt::Debug for Keys<'a, K, V> { +impl<'a, K: 'a + fmt::Debug, V: 'a> fmt::Debug for Keys<'a, K, V> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_list().entries(self.clone()).finish() } @@ -353,7 +353,7 @@ pub struct Values<'a, K: 'a, V: 'a> { } #[stable(feature = "collection_debug", since = "1.17.0")] -impl<'a, K: 'a + fmt::Debug, V: 'a + fmt::Debug> fmt::Debug for Values<'a, K, V> { +impl<'a, K: 'a, V: 'a + fmt::Debug> fmt::Debug for Values<'a, K, V> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_list().entries(self.clone()).finish() } diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index aef88e3d5636c..31efae18816c2 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -1407,7 +1407,7 @@ impl<'a, K, V> Clone for Keys<'a, K, V> { } #[stable(feature = "std_debug", since = "1.16.0")] -impl<'a, K: Debug, V: Debug> fmt::Debug for Keys<'a, K, V> { +impl<'a, K: Debug, V> fmt::Debug for Keys<'a, K, V> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_list() .entries(self.clone()) @@ -1436,7 +1436,7 @@ impl<'a, K, V> Clone for Values<'a, K, V> { } #[stable(feature = "std_debug", since = "1.16.0")] -impl<'a, K: Debug, V: Debug> fmt::Debug for Values<'a, K, V> { +impl<'a, K, V: Debug> fmt::Debug for Values<'a, K, V> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_list() .entries(self.clone())