io: remove unsafe pin-projections and remove manual Unpin implementations (#1588)

* Removes most pin-projection related unsafe code.

* Removes manual Unpin implementations.
  As references always implement Unpin, there is no need to implement
  Unpin manually.

* Adds tests to check that Unpin requirement does not change accidentally 
  because changing Unpin requirements will be breaking changes.
This commit is contained in:
Taiki Endo
2019-09-25 01:17:06 +09:00
committed by GitHub
parent d50d050fae
commit c81447fdcc
19 changed files with 271 additions and 111 deletions
+11 -3
View File
@@ -21,9 +21,6 @@ where
Write { writer, buf }
}
// forward Unpin
impl<W: Unpin + ?Sized> Unpin for Write<'_, W> {}
impl<W> Future for Write<'_, W>
where
W: AsyncWrite + Unpin + ?Sized,
@@ -35,3 +32,14 @@ where
Pin::new(&mut *me.writer).poll_write(cx, me.buf)
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn assert_unpin() {
use std::marker::PhantomPinned;
crate::is_unpin::<Write<'_, PhantomPinned>>();
}
}