Skip to content

Commit

Permalink
Rollup merge of rust-lang#55485 - petertodd:2018-10-manuallydrop-dere…
Browse files Browse the repository at this point in the history
…f, r=TimNN

Return &T / &mut T in ManuallyDrop Deref(Mut) impl

Without this change the generated documentation looks like this:

    fn deref(&self) -> &<ManuallyDrop<T> as Deref>::Target

Returning the actual type directly makes the generated docs more clear:

    fn deref(&self) -> &T

Basically, compare how the impl for `Box<T>` and `ManuallyDrop<T>` looks in this screenshot:

![rust docs for ManuallyDrop as Deref](https://user-images.githubusercontent.com/7042/47673083-fc9dc280-db89-11e8-89b0-c6bde663feef.png)
  • Loading branch information
GuillaumeGomez committed Nov 22, 2018
2 parents 9aedfd5 + bc18857 commit 1c57f0a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/libcore/mem.rs
Expand Up @@ -1016,15 +1016,15 @@ impl<T: ?Sized> ManuallyDrop<T> {
impl<T: ?Sized> Deref for ManuallyDrop<T> {
type Target = T;
#[inline]
fn deref(&self) -> &Self::Target {
fn deref(&self) -> &T {
&self.value
}
}

#[stable(feature = "manually_drop", since = "1.20.0")]
impl<T: ?Sized> DerefMut for ManuallyDrop<T> {
#[inline]
fn deref_mut(&mut self) -> &mut Self::Target {
fn deref_mut(&mut self) -> &mut T {
&mut self.value
}
}
Expand Down

0 comments on commit 1c57f0a

Please sign in to comment.