Skip to content

Commit cb3c515

Browse files
committed
Remove read-initializer feature
1 parent b48eb2e commit cb3c515

File tree

16 files changed

+2
-159
lines changed

16 files changed

+2
-159
lines changed

futures-io/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ std = []
1818
# These features are outside of the normal semver guarantees and require the
1919
# `unstable` feature as an explicit opt-in to unstable API.
2020
unstable = []
21-
read-initializer = []
2221

2322
[dependencies]
2423

futures-io/src/lib.rs

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
//! All items of this library are only available when the `std` feature of this
99
//! library is activated, and it is activated by default.
1010
11-
#![cfg_attr(all(feature = "read-initializer", feature = "std"), feature(read_initializer))]
1211
#![cfg_attr(not(feature = "std"), no_std)]
1312
#![warn(missing_debug_implementations, missing_docs, rust_2018_idioms, unreachable_pub)]
1413
// It cannot be included in the published code because this lints have false positives in the minimum required version.
@@ -22,9 +21,6 @@
2221
))]
2322
#![cfg_attr(docsrs, feature(doc_cfg))]
2423

25-
#[cfg(all(feature = "read-initializer", not(feature = "unstable")))]
26-
compile_error!("The `read-initializer` feature requires the `unstable` feature as an explicit opt-in to unstable features");
27-
2824
#[cfg(feature = "std")]
2925
mod if_std {
3026
use std::io;
@@ -34,11 +30,6 @@ mod if_std {
3430

3531
// Re-export some types from `std::io` so that users don't have to deal
3632
// with conflicts when `use`ing `futures::io` and `std::io`.
37-
#[cfg(feature = "read-initializer")]
38-
#[cfg_attr(docsrs, doc(cfg(feature = "read-initializer")))]
39-
#[doc(no_inline)]
40-
#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
41-
pub use io::Initializer;
4233
#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
4334
#[doc(no_inline)]
4435
pub use io::{Error, ErrorKind, IoSlice, IoSliceMut, Result, SeekFrom};
@@ -51,27 +42,6 @@ mod if_std {
5142
/// for wakeup and return if data is not yet available, rather than blocking
5243
/// the calling thread.
5344
pub trait AsyncRead {
54-
/// Determines if this `AsyncRead`er can work with buffers of
55-
/// uninitialized memory.
56-
///
57-
/// The default implementation returns an initializer which will zero
58-
/// buffers.
59-
///
60-
/// This method is only available when the `read-initializer` feature of this
61-
/// library is activated.
62-
///
63-
/// # Safety
64-
///
65-
/// This method is `unsafe` because an `AsyncRead`er could otherwise
66-
/// return a non-zeroing `Initializer` from another `AsyncRead` type
67-
/// without an `unsafe` block.
68-
#[cfg(feature = "read-initializer")]
69-
#[cfg_attr(docsrs, doc(cfg(feature = "read-initializer")))]
70-
#[inline]
71-
unsafe fn initializer(&self) -> Initializer {
72-
Initializer::zeroing()
73-
}
74-
7545
/// Attempt to read from the `AsyncRead` into `buf`.
7646
///
7747
/// On success, returns `Poll::Ready(Ok(num_bytes_read))`.
@@ -329,11 +299,6 @@ mod if_std {
329299

330300
macro_rules! deref_async_read {
331301
() => {
332-
#[cfg(feature = "read-initializer")]
333-
unsafe fn initializer(&self) -> Initializer {
334-
(**self).initializer()
335-
}
336-
337302
fn poll_read(
338303
mut self: Pin<&mut Self>,
339304
cx: &mut Context<'_>,
@@ -365,11 +330,6 @@ mod if_std {
365330
P: DerefMut + Unpin,
366331
P::Target: AsyncRead,
367332
{
368-
#[cfg(feature = "read-initializer")]
369-
unsafe fn initializer(&self) -> Initializer {
370-
(**self).initializer()
371-
}
372-
373333
fn poll_read(
374334
self: Pin<&mut Self>,
375335
cx: &mut Context<'_>,
@@ -389,11 +349,6 @@ mod if_std {
389349

390350
macro_rules! delegate_async_read_to_stdio {
391351
() => {
392-
#[cfg(feature = "read-initializer")]
393-
unsafe fn initializer(&self) -> Initializer {
394-
io::Read::initializer(self)
395-
}
396-
397352
fn poll_read(
398353
mut self: Pin<&mut Self>,
399354
_: &mut Context<'_>,

futures-util/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ channel = ["std", "futures-channel"]
2727
# `unstable` feature as an explicit opt-in to unstable API.
2828
unstable = []
2929
bilock = []
30-
read-initializer = ["io", "futures-io/read-initializer", "futures-io/unstable"]
3130
write-all-vectored = ["io"]
3231

3332
[dependencies]

futures-util/src/compat/compat01as03.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,6 @@ unsafe impl UnsafeNotify01 for NotifyWaker {
351351
#[cfg_attr(docsrs, doc(cfg(feature = "io-compat")))]
352352
mod io {
353353
use super::*;
354-
#[cfg(feature = "read-initializer")]
355-
use futures_io::Initializer;
356354
use futures_io::{AsyncRead as AsyncRead03, AsyncWrite as AsyncWrite03};
357355
use std::io::Error;
358356
use tokio_io::{AsyncRead as AsyncRead01, AsyncWrite as AsyncWrite01};
@@ -416,16 +414,6 @@ mod io {
416414
impl<W: AsyncWrite01> AsyncWrite01CompatExt for W {}
417415

418416
impl<R: AsyncRead01> AsyncRead03 for Compat01As03<R> {
419-
#[cfg(feature = "read-initializer")]
420-
unsafe fn initializer(&self) -> Initializer {
421-
// check if `prepare_uninitialized_buffer` needs zeroing
422-
if self.inner.get_ref().prepare_uninitialized_buffer(&mut [1]) {
423-
Initializer::zeroing()
424-
} else {
425-
Initializer::nop()
426-
}
427-
}
428-
429417
fn poll_read(
430418
mut self: Pin<&mut Self>,
431419
cx: &mut Context<'_>,

futures-util/src/compat/compat03as01.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -236,17 +236,7 @@ mod io {
236236
}
237237
}
238238

239-
impl<R: AsyncRead03 + Unpin> AsyncRead01 for Compat<R> {
240-
#[cfg(feature = "read-initializer")]
241-
unsafe fn prepare_uninitialized_buffer(&self, buf: &mut [u8]) -> bool {
242-
let initializer = self.inner.initializer();
243-
let does_init = initializer.should_initialize();
244-
if does_init {
245-
initializer.initialize(buf);
246-
}
247-
does_init
248-
}
249-
}
239+
impl<R: AsyncRead03 + Unpin> AsyncRead01 for Compat<R> {}
250240

251241
impl<W: AsyncWrite03 + Unpin> std::io::Write for Compat<W> {
252242
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {

futures-util/src/future/either.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,6 @@ mod if_std {
184184

185185
use core::pin::Pin;
186186
use core::task::{Context, Poll};
187-
#[cfg(feature = "read-initializer")]
188-
use futures_io::Initializer;
189187
use futures_io::{
190188
AsyncBufRead, AsyncRead, AsyncSeek, AsyncWrite, IoSlice, IoSliceMut, Result, SeekFrom,
191189
};
@@ -195,14 +193,6 @@ mod if_std {
195193
A: AsyncRead,
196194
B: AsyncRead,
197195
{
198-
#[cfg(feature = "read-initializer")]
199-
unsafe fn initializer(&self) -> Initializer {
200-
match self {
201-
Either::Left(x) => x.initializer(),
202-
Either::Right(x) => x.initializer(),
203-
}
204-
}
205-
206196
fn poll_read(
207197
self: Pin<&mut Self>,
208198
cx: &mut Context<'_>,

futures-util/src/io/allow_std.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
use futures_core::task::{Context, Poll};
2-
#[cfg(feature = "read-initializer")]
3-
use futures_io::Initializer;
42
use futures_io::{AsyncBufRead, AsyncRead, AsyncSeek, AsyncWrite, IoSlice, IoSliceMut, SeekFrom};
53
use std::pin::Pin;
64
use std::{fmt, io};
@@ -121,10 +119,6 @@ where
121119
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
122120
self.0.read_vectored(bufs)
123121
}
124-
#[cfg(feature = "read-initializer")]
125-
unsafe fn initializer(&self) -> Initializer {
126-
self.0.initializer()
127-
}
128122
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> io::Result<usize> {
129123
self.0.read_to_end(buf)
130124
}
@@ -155,11 +149,6 @@ where
155149
) -> Poll<io::Result<usize>> {
156150
Poll::Ready(Ok(try_with_interrupt!(self.0.read_vectored(bufs))))
157151
}
158-
159-
#[cfg(feature = "read-initializer")]
160-
unsafe fn initializer(&self) -> Initializer {
161-
self.0.initializer()
162-
}
163152
}
164153

165154
impl<T> io::Seek for AllowStdIo<T>

futures-util/src/io/buf_reader.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ use super::DEFAULT_BUF_SIZE;
22
use futures_core::future::Future;
33
use futures_core::ready;
44
use futures_core::task::{Context, Poll};
5-
#[cfg(feature = "read-initializer")]
6-
use futures_io::Initializer;
75
use futures_io::{AsyncBufRead, AsyncRead, AsyncSeek, AsyncWrite, IoSliceMut, SeekFrom};
86
use pin_project_lite::pin_project;
97
use std::io::{self, Read};
@@ -141,12 +139,6 @@ impl<R: AsyncRead> AsyncRead for BufReader<R> {
141139
self.consume(nread);
142140
Poll::Ready(Ok(nread))
143141
}
144-
145-
// we can't skip unconditionally because of the large buffer case in read.
146-
#[cfg(feature = "read-initializer")]
147-
unsafe fn initializer(&self) -> Initializer {
148-
self.inner.initializer()
149-
}
150142
}
151143

152144
impl<R: AsyncRead> AsyncBufRead for BufReader<R> {

futures-util/src/io/chain.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
use futures_core::ready;
22
use futures_core::task::{Context, Poll};
3-
#[cfg(feature = "read-initializer")]
4-
use futures_io::Initializer;
53
use futures_io::{AsyncBufRead, AsyncRead, IoSliceMut};
64
use pin_project_lite::pin_project;
75
use std::fmt;
@@ -111,16 +109,6 @@ where
111109
}
112110
this.second.poll_read_vectored(cx, bufs)
113111
}
114-
115-
#[cfg(feature = "read-initializer")]
116-
unsafe fn initializer(&self) -> Initializer {
117-
let initializer = self.first.initializer();
118-
if initializer.should_initialize() {
119-
initializer
120-
} else {
121-
self.second.initializer()
122-
}
123-
}
124112
}
125113

126114
impl<T, U> AsyncBufRead for Chain<T, U>

futures-util/src/io/empty.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
use futures_core::task::{Context, Poll};
2-
#[cfg(feature = "read-initializer")]
3-
use futures_io::Initializer;
42
use futures_io::{AsyncBufRead, AsyncRead};
53
use std::fmt;
64
use std::io;
@@ -43,12 +41,6 @@ impl AsyncRead for Empty {
4341
) -> Poll<io::Result<usize>> {
4442
Poll::Ready(Ok(0))
4543
}
46-
47-
#[cfg(feature = "read-initializer")]
48-
#[inline]
49-
unsafe fn initializer(&self) -> Initializer {
50-
Initializer::nop()
51-
}
5244
}
5345

5446
impl AsyncBufRead for Empty {

0 commit comments

Comments
 (0)