-
Notifications
You must be signed in to change notification settings - Fork 649
New nightly shows warnings that will become hard errors in the future #1143
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Note: These warnings are special because they don't break the CI even though we deny warnings. |
That Can hopefully steal the (I also really want to know how having an unused EDIT: Argh no, the |
One potential fix that shouldn't impact the size/performance of diff --git futures-util/src/io/read_exact.rs futures-util/src/io/read_exact.rs
index 420ea191..da99a97e 100644
--- futures-util/src/io/read_exact.rs
+++ futures-util/src/io/read_exact.rs
@@ -14,7 +14,7 @@ use std::mem::{self, PinMut};
#[derive(Debug)]
pub struct ReadExact<'a, R: ?Sized + 'a> {
reader: &'a mut R,
- buf: &'a mut [u8],
+ buf: Option<&'a mut [u8]>,
}
impl<'a, R: ?Sized> Unpin for ReadExact<'a, R> {}
@@ -24,7 +24,7 @@ impl<'a, R: AsyncRead + ?Sized> ReadExact<'a, R> {
reader: &'a mut R,
buf: &'a mut [u8]
) -> ReadExact<'a, R> {
- ReadExact { reader, buf }
+ ReadExact { reader, buf: Some(buf) }
}
}
@@ -37,16 +37,27 @@ impl<'a, R: AsyncRead + ?Sized> Future for ReadExact<'a, R> {
fn poll(mut self: PinMut<Self>, cx: &mut task::Context) -> Poll<Self::Output> {
let this = &mut *self;
- while !this.buf.is_empty() {
- let n = try_ready!(this.reader.poll_read(cx, this.buf));
- {
- let (_, rest) = mem::replace(&mut this.buf, &mut []).split_at_mut(n);
- this.buf = rest;
- }
- if n == 0 {
- return Poll::Ready(Err(eof()))
+ let mut buf = this.buf.take().unwrap();
+ while !buf.is_empty() {
+ match this.reader.poll_read(cx, buf) {
+ Poll::Ready(Ok(0)) => {
+ this.buf = Some(buf);
+ return Poll::Ready(Err(eof()));
+ }
+ Poll::Ready(Ok(n)) => {
+ buf = &mut buf[n..];
+ }
+ Poll::Ready(Err(e)) => {
+ this.buf = Some(buf);
+ return Poll::Ready(Err(e));
+ }
+ Poll::Pending => {
+ this.buf = Some(buf);
+ return Poll::Pending;
+ }
}
}
+ this.buf = Some(buf);
Poll::Ready(Ok(()))
}
} |
@MajorBreakfast did you and @cramertj discuss using |
@Nemo157 Yeah, there are lots of combinators that'd be nice to define that way, but I think we want to keep all our types nameable for the sake of downstream users, at least until we get some form of nameable existential types. |
I was thinking of wrapping the async block inside a trivial |
For reference rust-lang/rust#52671 provoked the change that caused the |
The warnings are gone now |
Nightly from 2018-07-29
The text was updated successfully, but these errors were encountered: