diff --git a/compiler/rustc_ast/src/ptr.rs b/compiler/rustc_ast/src/ptr.rs index 899d8eb7ca99..91f29a4c289f 100644 --- a/compiler/rustc_ast/src/ptr.rs +++ b/compiler/rustc_ast/src/ptr.rs @@ -17,10 +17,9 @@ //! heap, for example). Moreover, a switch to, e.g., `P<'a, T>` would be easy //! and mostly automated. -use std::fmt::{self, Debug, Display}; +use std::fmt::{self, Debug}; use std::ops::{Deref, DerefMut}; -use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; /// An owned smart pointer. @@ -37,28 +36,10 @@ pub fn P(value: T) -> P { } impl P { - /// Move out of the pointer. - /// Intended for chaining transformations not covered by `map`. - pub fn and_then(self, f: F) -> U - where - F: FnOnce(T) -> U, - { - f(*self.ptr) - } - - /// Equivalent to `and_then(|x| x)`. + /// Consume the `P` and return the wrapped value. pub fn into_inner(self) -> T { *self.ptr } - - /// Optionally produce a new `P` from `self` without reallocating. - pub fn filter_map(mut self, f: F) -> Option> - where - F: FnOnce(T) -> Option, - { - *self.ptr = f(*self.ptr)?; - Some(self) - } } impl Deref for P { @@ -87,18 +68,6 @@ impl Debug for P { } } -impl Display for P { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - Display::fmt(&**self, f) - } -} - -impl fmt::Pointer for P { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt::Pointer::fmt(&self.ptr, f) - } -} - impl> Decodable for P { fn decode(d: &mut D) -> P { P(Decodable::decode(d)) @@ -110,12 +79,3 @@ impl> Encodable for P { (**self).encode(s); } } - -impl HashStable for P -where - T: ?Sized + HashStable, -{ - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { - (**self).hash_stable(hcx, hasher); - } -}