diff options
| author | bors <bors@rust-lang.org> | 2015-04-08 22:08:31 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-04-08 22:08:31 +0000 |
| commit | 6436e348e97a09c2155d0dcd710416e6e0d84371 (patch) | |
| tree | 592eb6fa4567c7b29cd90c17c370d0fa0f692cf7 /src/liballoc | |
| parent | ff804778c8d69d7835cf7076886ac5dac9a39659 (diff) | |
| parent | a329a61b9bf01bfc3f9f7316bb800b2bc8b76382 (diff) | |
| download | rust-6436e348e97a09c2155d0dcd710416e6e0d84371.tar.gz rust-6436e348e97a09c2155d0dcd710416e6e0d84371.zip | |
Auto merge of #24144 - richo:ptr-formatter, r=alexcrichton
~~I believe this should fix the issue. Opening a PR to ensure noone duplicates effort, I'm running check now.~~ Closes #24091
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/arc.rs | 7 | ||||
| -rw-r--r-- | src/liballoc/boxed.rs | 10 | ||||
| -rw-r--r-- | src/liballoc/rc.rs | 7 |
3 files changed, 24 insertions, 0 deletions
diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index 68bde147611..ff176d81591 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -669,6 +669,13 @@ impl<T: fmt::Debug> fmt::Debug for Arc<T> { } #[stable(feature = "rust1", since = "1.0.0")] +impl<T> fmt::Pointer for Arc<T> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Pointer::fmt(&*self._ptr, f) + } +} + +#[stable(feature = "rust1", since = "1.0.0")] impl<T: Default + Sync + Send> Default for Arc<T> { #[stable(feature = "rust1", since = "1.0.0")] fn default() -> Arc<T> { Arc::new(Default::default()) } diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 2801cf38cb7..4468e425a85 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -276,6 +276,16 @@ impl<T: fmt::Debug + ?Sized> fmt::Debug for Box<T> { } #[stable(feature = "rust1", since = "1.0.0")] +impl<T> fmt::Pointer for Box<T> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + // It's not possible to extract the inner Uniq directly from the Box, + // instead we cast it to a *const which aliases the Unique + let ptr: *const T = &**self; + fmt::Pointer::fmt(&ptr, f) + } +} + +#[stable(feature = "rust1", since = "1.0.0")] impl<T: ?Sized> Deref for Box<T> { type Target = T; diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 56822cfe28a..67805d10a4a 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -634,6 +634,13 @@ impl<T: fmt::Debug> fmt::Debug for Rc<T> { } } +#[stable(feature = "rust1", since = "1.0.0")] +impl<T> fmt::Pointer for Rc<T> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Pointer::fmt(&*self._ptr, f) + } +} + /// A weak version of `Rc<T>`. /// /// Weak references do not count when determining if the inner value should be |
