From 0fc9d3909ac1601d5f91f8da58634ea32b089d90 Mon Sep 17 00:00:00 2001 From: Donough Liu Date: Sat, 25 Apr 2020 02:06:53 +0800 Subject: [PATCH 01/13] Minimize parameter of coerce_borrowed_pointer() --- src/librustc_typeck/check/coercion.rs | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs index 8070ad17120..3d665123f67 100644 --- a/src/librustc_typeck/check/coercion.rs +++ b/src/librustc_typeck/check/coercion.rs @@ -211,12 +211,9 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { ty::RawPtr(mt_b) => { return self.coerce_unsafe_ptr(a, b, mt_b.mutbl); } - - ty::Ref(r_b, ty, mutbl) => { - let mt_b = ty::TypeAndMut { ty, mutbl }; - return self.coerce_borrowed_pointer(a, b, r_b, mt_b); + ty::Ref(r_b, _, mutbl_b) => { + return self.coerce_borrowed_pointer(a, b, r_b, mutbl_b); } - _ => {} } @@ -255,7 +252,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { a: Ty<'tcx>, b: Ty<'tcx>, r_b: ty::Region<'tcx>, - mt_b: TypeAndMut<'tcx>, + mutbl_b: hir::Mutability, ) -> CoerceResult<'tcx> { debug!("coerce_borrowed_pointer(a={:?}, b={:?})", a, b); @@ -268,7 +265,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { let (r_a, mt_a) = match a.kind { ty::Ref(r_a, ty, mutbl) => { let mt_a = ty::TypeAndMut { ty, mutbl }; - coerce_mutbls(mt_a.mutbl, mt_b.mutbl)?; + coerce_mutbls(mt_a.mutbl, mutbl_b)?; (r_a, mt_a) } _ => return self.unify_and(a, b, identity), @@ -364,7 +361,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { r_a // [3] above } else { if r_borrow_var.is_none() { - // create var lazilly, at most once + // create var lazily, at most once let coercion = Coercion(span); let r = self.next_region_var(coercion); r_borrow_var = Some(r); // [4] above @@ -375,7 +372,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { r, TypeAndMut { ty: referent_ty, - mutbl: mt_b.mutbl, // [1] above + mutbl: mutbl_b, // [1] above }, ); match self.unify(derefd_ty_a, b) { @@ -417,11 +414,11 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { // `self.x` both have `&mut `type would be a move of // `self.x`, but we auto-coerce it to `foo(&mut *self.x)`, // which is a borrow. - assert_eq!(mt_b.mutbl, hir::Mutability::Not); // can only coerce &T -> &U + assert_eq!(mutbl_b, hir::Mutability::Not); // can only coerce &T -> &U return success(vec![], ty, obligations); } - let needs = Needs::maybe_mut_place(mt_b.mutbl); + let needs = Needs::maybe_mut_place(mutbl_b); let InferOk { value: mut adjustments, obligations: o } = autoderef.adjust_steps_as_infer_ok(self, needs); obligations.extend(o); @@ -433,7 +430,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { ty::Ref(r_borrow, _, _) => r_borrow, _ => span_bug!(span, "expected a ref type, got {:?}", ty), }; - let mutbl = match mt_b.mutbl { + let mutbl = match mutbl_b { hir::Mutability::Not => AutoBorrowMutability::Not, hir::Mutability::Mut => { AutoBorrowMutability::Mut { allow_two_phase_borrow: self.allow_two_phase } From 15262ec6be6fcfc9f27e174a0714d5a62e775fb0 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Fri, 3 Jan 2020 11:26:05 -0800 Subject: [PATCH 02/13] Add Read/Write::can_read/write_vectored When working with an arbitrary reader or writer, code that uses vectored operations may end up being slower than code that copies into a single buffer when the underlying reader or writer doesn't actually support vectored operations. These new methods allow you to ask the reader or witer up front if vectored operations are efficiently supported. Currently, you have to use some heuristics to guess by e.g. checking if the read or write only accessed the first buffer. Hyper is one concrete example of a library that has to do this dynamically: https://github.com/hyperium/hyper/blob/0eaf304644a396895a4ce1f0146e596640bb666a/src/proto/h1/io.rs#L582-L594 --- src/libstd/fs.rs | 20 ++++++++++ src/libstd/io/buffered.rs | 8 ++++ src/libstd/io/cursor.rs | 24 ++++++++++++ src/libstd/io/impls.rs | 35 +++++++++++++++++ src/libstd/io/mod.rs | 26 +++++++++++++ src/libstd/io/stdio.rs | 56 +++++++++++++++++++++++++++ src/libstd/io/util.rs | 10 +++++ src/libstd/lib.rs | 1 + src/libstd/net/tcp.rs | 20 ++++++++++ src/libstd/process.rs | 14 +++++++ src/libstd/sys/cloudabi/shims/fs.rs | 8 ++++ src/libstd/sys/cloudabi/shims/net.rs | 8 ++++ src/libstd/sys/cloudabi/shims/pipe.rs | 8 ++++ src/libstd/sys/hermit/fs.rs | 10 +++++ src/libstd/sys/hermit/net.rs | 10 +++++ src/libstd/sys/hermit/pipe.rs | 8 ++++ src/libstd/sys/hermit/stdio.rs | 15 +++++++ src/libstd/sys/sgx/fd.rs | 10 +++++ src/libstd/sys/sgx/fs.rs | 8 ++++ src/libstd/sys/sgx/net.rs | 10 +++++ src/libstd/sys/sgx/pipe.rs | 8 ++++ src/libstd/sys/unix/ext/net.rs | 20 ++++++++++ src/libstd/sys/unix/fd.rs | 10 +++++ src/libstd/sys/unix/fs.rs | 10 +++++ src/libstd/sys/unix/l4re.rs | 16 ++++++++ src/libstd/sys/unix/net.rs | 10 +++++ src/libstd/sys/unix/pipe.rs | 10 +++++ src/libstd/sys/unix/stdio.rs | 15 +++++++ src/libstd/sys/vxworks/fd.rs | 10 +++++ src/libstd/sys/vxworks/fs.rs | 10 +++++ src/libstd/sys/vxworks/net.rs | 10 +++++ src/libstd/sys/vxworks/pipe.rs | 11 ++++++ src/libstd/sys/wasi/fs.rs | 10 +++++ src/libstd/sys/wasi/net.rs | 8 ++++ src/libstd/sys/wasi/pipe.rs | 8 ++++ src/libstd/sys/wasi/stdio.rs | 15 +++++++ src/libstd/sys/wasm/fs.rs | 8 ++++ src/libstd/sys/wasm/net.rs | 8 ++++ src/libstd/sys/windows/fs.rs | 10 +++++ src/libstd/sys/windows/handle.rs | 10 +++++ src/libstd/sys/windows/net.rs | 10 +++++ src/libstd/sys/windows/pipe.rs | 10 +++++ src/libstd/sys_common/net.rs | 10 +++++ 43 files changed, 556 insertions(+) diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 119bdfcb0f4..cc2d79ee084 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -659,6 +659,11 @@ impl Read for File { self.inner.read_vectored(bufs) } + #[inline] + fn can_read_vectored(&self) -> bool { + self.inner.can_read_vectored() + } + #[inline] unsafe fn initializer(&self) -> Initializer { Initializer::nop() @@ -674,6 +679,11 @@ impl Write for File { self.inner.write_vectored(bufs) } + #[inline] + fn can_write_vectored(&self) -> bool { + self.inner.can_write_vectored() + } + fn flush(&mut self) -> io::Result<()> { self.inner.flush() } @@ -694,6 +704,11 @@ impl Read for &File { self.inner.read_vectored(bufs) } + #[inline] + fn can_read_vectored(&self) -> bool { + self.inner.can_read_vectored() + } + #[inline] unsafe fn initializer(&self) -> Initializer { Initializer::nop() @@ -709,6 +724,11 @@ impl Write for &File { self.inner.write_vectored(bufs) } + #[inline] + fn can_write_vectored(&self) -> bool { + self.inner.can_write_vectored() + } + fn flush(&mut self) -> io::Result<()> { self.inner.flush() } diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index 16ca539b3c1..cabeaf4ae77 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -292,6 +292,10 @@ impl Read for BufReader { Ok(nread) } + fn can_read_vectored(&self) -> bool { + self.inner.can_read_vectored() + } + // we can't skip unconditionally because of the large buffer case in read. unsafe fn initializer(&self) -> Initializer { self.inner.initializer() @@ -680,6 +684,10 @@ impl Write for BufWriter { } } + fn can_write_vectored(&self) -> bool { + self.get_ref().can_write_vectored() + } + fn flush(&mut self) -> io::Result<()> { self.flush_buf().and_then(|()| self.get_mut().flush()) } diff --git a/src/libstd/io/cursor.rs b/src/libstd/io/cursor.rs index f36aa1846a1..859431ea0ef 100644 --- a/src/libstd/io/cursor.rs +++ b/src/libstd/io/cursor.rs @@ -266,6 +266,10 @@ where Ok(nread) } + fn can_read_vectored(&self) -> bool { + true + } + fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> { let n = buf.len(); Read::read_exact(&mut self.fill_buf()?, buf)?; @@ -372,6 +376,11 @@ impl Write for Cursor<&mut [u8]> { slice_write_vectored(&mut self.pos, self.inner, bufs) } + #[inline] + fn can_write_vectored(&self) -> bool { + true + } + #[inline] fn flush(&mut self) -> io::Result<()> { Ok(()) @@ -388,6 +397,11 @@ impl Write for Cursor<&mut Vec> { vec_write_vectored(&mut self.pos, self.inner, bufs) } + #[inline] + fn can_write_vectored(&self) -> bool { + true + } + #[inline] fn flush(&mut self) -> io::Result<()> { Ok(()) @@ -404,6 +418,11 @@ impl Write for Cursor> { vec_write_vectored(&mut self.pos, &mut self.inner, bufs) } + #[inline] + fn can_write_vectored(&self) -> bool { + true + } + #[inline] fn flush(&mut self) -> io::Result<()> { Ok(()) @@ -422,6 +441,11 @@ impl Write for Cursor> { slice_write_vectored(&mut self.pos, &mut self.inner, bufs) } + #[inline] + fn can_write_vectored(&self) -> bool { + true + } + #[inline] fn flush(&mut self) -> io::Result<()> { Ok(()) diff --git a/src/libstd/io/impls.rs b/src/libstd/io/impls.rs index b7f82e65299..1fb9f12dd90 100644 --- a/src/libstd/io/impls.rs +++ b/src/libstd/io/impls.rs @@ -20,6 +20,11 @@ impl Read for &mut R { (**self).read_vectored(bufs) } + #[inline] + fn can_read_vectored(&self) -> bool { + (**self).can_read_vectored() + } + #[inline] unsafe fn initializer(&self) -> Initializer { (**self).initializer() @@ -52,6 +57,11 @@ impl Write for &mut W { (**self).write_vectored(bufs) } + #[inline] + fn can_write_vectored(&self) -> bool { + (**self).can_write_vectored() + } + #[inline] fn flush(&mut self) -> io::Result<()> { (**self).flush() @@ -109,6 +119,11 @@ impl Read for Box { (**self).read_vectored(bufs) } + #[inline] + fn can_read_vectored(&self) -> bool { + (**self).can_read_vectored() + } + #[inline] unsafe fn initializer(&self) -> Initializer { (**self).initializer() @@ -141,6 +156,11 @@ impl Write for Box { (**self).write_vectored(bufs) } + #[inline] + fn can_write_vectored(&self) -> bool { + (**self).can_write_vectored() + } + #[inline] fn flush(&mut self) -> io::Result<()> { (**self).flush() @@ -240,6 +260,11 @@ impl Read for &[u8] { Ok(nread) } + #[inline] + fn can_read_vectored(&self) -> bool { + true + } + #[inline] unsafe fn initializer(&self) -> Initializer { Initializer::nop() @@ -316,6 +341,11 @@ impl Write for &mut [u8] { Ok(nwritten) } + #[inline] + fn can_write_vectored(&self) -> bool { + true + } + #[inline] fn write_all(&mut self, data: &[u8]) -> io::Result<()> { if self.write(data)? == data.len() { @@ -351,6 +381,11 @@ impl Write for Vec { Ok(len) } + #[inline] + fn can_write_vectored(&self) -> bool { + true + } + #[inline] fn write_all(&mut self, buf: &[u8]) -> io::Result<()> { self.extend_from_slice(buf); diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 5ab88260d6a..c6229fb39e0 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -580,6 +580,19 @@ pub trait Read { default_read_vectored(|b| self.read(b), bufs) } + /// Determines if this `Read`er has an efficient `read_vectored` + /// implementation. + /// + /// If a `Read`er does not override the default `read_vectored` + /// implementation, code using it may want to avoid the method all together + /// and coalesce writes into a single buffer for higher performance. + /// + /// The default implementation returns `false`. + #[unstable(feature = "can_vector", issue = "none")] + fn can_read_vectored(&self) -> bool { + false + } + /// Determines if this `Read`er can work with buffers of uninitialized /// memory. /// @@ -1304,6 +1317,19 @@ pub trait Write { default_write_vectored(|b| self.write(b), bufs) } + /// Determines if this `Write`er has an efficient `write_vectored` + /// implementation. + /// + /// If a `Write`er does not override the default `write_vectored` + /// implementation, code using it may want to avoid the method all together + /// and coalesce writes into a single buffer for higher performance. + /// + /// The default implementation returns `false`. + #[unstable(feature = "can_vector", issue = "none")] + fn can_write_vectored(&self) -> bool { + false + } + /// Flush this output stream, ensuring that all intermediately buffered /// contents reach their destination. /// diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs index a064c552c84..fd5a1291785 100644 --- a/src/libstd/io/stdio.rs +++ b/src/libstd/io/stdio.rs @@ -87,6 +87,11 @@ impl Read for StdinRaw { self.0.read_vectored(bufs) } + #[inline] + fn can_read_vectored(&self) -> bool { + self.0.can_read_vectored() + } + #[inline] unsafe fn initializer(&self) -> Initializer { Initializer::nop() @@ -101,6 +106,11 @@ impl Write for StdoutRaw { self.0.write_vectored(bufs) } + #[inline] + fn can_write_vectored(&self) -> bool { + self.0.can_write_vectored() + } + fn flush(&mut self) -> io::Result<()> { self.0.flush() } @@ -114,6 +124,11 @@ impl Write for StderrRaw { self.0.write_vectored(bufs) } + #[inline] + fn can_write_vectored(&self) -> bool { + self.0.can_write_vectored() + } + fn flush(&mut self) -> io::Result<()> { self.0.flush() } @@ -140,6 +155,14 @@ impl io::Write for Maybe { } } + #[inline] + fn can_write_vectored(&self) -> bool { + match self { + Maybe::Real(w) => w.can_write_vectored(), + Maybe::Fake => true, + } + } + fn flush(&mut self) -> io::Result<()> { match *self { Maybe::Real(ref mut w) => handle_ebadf(w.flush(), ()), @@ -162,6 +185,14 @@ impl io::Read for Maybe { Maybe::Fake => Ok(0), } } + + #[inline] + fn can_read_vectored(&self) -> bool { + match self { + Maybe::Real(w) => w.can_read_vectored(), + Maybe::Fake => true, + } + } } fn handle_ebadf(r: io::Result, default: T) -> io::Result { @@ -352,6 +383,10 @@ impl Read for Stdin { self.lock().read_vectored(bufs) } #[inline] + fn can_read_vectored(&self) -> bool { + self.lock().can_read_vectored() + } + #[inline] unsafe fn initializer(&self) -> Initializer { Initializer::nop() } @@ -376,6 +411,11 @@ impl Read for StdinLock<'_> { self.inner.read_vectored(bufs) } + #[inline] + fn can_read_vectored(&self) -> bool { + self.inner.can_read_vectored() + } + #[inline] unsafe fn initializer(&self) -> Initializer { Initializer::nop() @@ -543,6 +583,10 @@ impl Write for Stdout { fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> io::Result { self.lock().write_vectored(bufs) } + #[inline] + fn can_write_vectored(&self) -> bool { + self.lock().can_write_vectored() + } fn flush(&mut self) -> io::Result<()> { self.lock().flush() } @@ -561,6 +605,10 @@ impl Write for StdoutLock<'_> { fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> io::Result { self.inner.borrow_mut().write_vectored(bufs) } + #[inline] + fn can_write_vectored(&self) -> bool { + self.inner.borrow_mut().can_write_vectored() + } fn flush(&mut self) -> io::Result<()> { self.inner.borrow_mut().flush() } @@ -709,6 +757,10 @@ impl Write for Stderr { fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> io::Result { self.lock().write_vectored(bufs) } + #[inline] + fn can_write_vectored(&self) -> bool { + self.lock().can_write_vectored() + } fn flush(&mut self) -> io::Result<()> { self.lock().flush() } @@ -727,6 +779,10 @@ impl Write for StderrLock<'_> { fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> io::Result { self.inner.borrow_mut().write_vectored(bufs) } + #[inline] + fn can_write_vectored(&self) -> bool { + self.inner.borrow_mut().can_write_vectored() + } fn flush(&mut self) -> io::Result<()> { self.inner.borrow_mut().flush() } diff --git a/src/libstd/io/util.rs b/src/libstd/io/util.rs index b09161b97aa..01947cd8b89 100644 --- a/src/libstd/io/util.rs +++ b/src/libstd/io/util.rs @@ -179,6 +179,11 @@ impl Read for Repeat { Ok(nwritten) } + #[inline] + fn can_read_vectored(&self) -> bool { + true + } + #[inline] unsafe fn initializer(&self) -> Initializer { Initializer::nop() @@ -235,6 +240,11 @@ impl Write for Sink { Ok(total_len) } + #[inline] + fn can_write_vectored(&self) -> bool { + true + } + #[inline] fn flush(&mut self) -> io::Result<()> { Ok(()) diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 5fd15bb8fe4..ac07af5e278 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -243,6 +243,7 @@ #![feature(box_syntax)] #![feature(c_variadic)] #![feature(cfg_accessible)] +#![feature(can_vector)] #![feature(cfg_target_has_atomic)] #![feature(cfg_target_thread_local)] #![feature(char_error_internals)] diff --git a/src/libstd/net/tcp.rs b/src/libstd/net/tcp.rs index 5023d692408..86955a79759 100644 --- a/src/libstd/net/tcp.rs +++ b/src/libstd/net/tcp.rs @@ -576,6 +576,11 @@ impl Read for TcpStream { self.0.read_vectored(bufs) } + #[inline] + fn can_read_vectored(&self) -> bool { + self.0.can_read_vectored() + } + #[inline] unsafe fn initializer(&self) -> Initializer { Initializer::nop() @@ -591,6 +596,11 @@ impl Write for TcpStream { self.0.write_vectored(bufs) } + #[inline] + fn can_write_vectored(&self) -> bool { + self.0.can_write_vectored() + } + fn flush(&mut self) -> io::Result<()> { Ok(()) } @@ -605,6 +615,11 @@ impl Read for &TcpStream { self.0.read_vectored(bufs) } + #[inline] + fn can_read_vectored(&self) -> bool { + self.0.can_read_vectored() + } + #[inline] unsafe fn initializer(&self) -> Initializer { Initializer::nop() @@ -620,6 +635,11 @@ impl Write for &TcpStream { self.0.write_vectored(bufs) } + #[inline] + fn can_write_vectored(&self) -> bool { + self.0.can_write_vectored() + } + fn flush(&mut self) -> io::Result<()> { Ok(()) } diff --git a/src/libstd/process.rs b/src/libstd/process.rs index 3eee45d000c..2d22eb4ceaf 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -245,6 +245,10 @@ impl Write for ChildStdin { self.inner.write_vectored(bufs) } + fn can_write_vectored(&self) -> bool { + self.inner.can_write_vectored() + } + fn flush(&mut self) -> io::Result<()> { Ok(()) } @@ -300,6 +304,11 @@ impl Read for ChildStdout { self.inner.read_vectored(bufs) } + #[inline] + fn can_read_vectored(&self) -> bool { + self.inner.can_read_vectored() + } + #[inline] unsafe fn initializer(&self) -> Initializer { Initializer::nop() @@ -356,6 +365,11 @@ impl Read for ChildStderr { self.inner.read_vectored(bufs) } + #[inline] + fn can_read_vectored(&self) -> bool { + self.inner.can_read_vectored() + } + #[inline] unsafe fn initializer(&self) -> Initializer { Initializer::nop() diff --git a/src/libstd/sys/cloudabi/shims/fs.rs b/src/libstd/sys/cloudabi/shims/fs.rs index e6160d1457d..e34483447e9 100644 --- a/src/libstd/sys/cloudabi/shims/fs.rs +++ b/src/libstd/sys/cloudabi/shims/fs.rs @@ -202,6 +202,10 @@ impl File { match self.0 {} } + pub fn can_read_vectored(&self) -> bool { + match self.0 {} + } + pub fn write(&self, _buf: &[u8]) -> io::Result { match self.0 {} } @@ -210,6 +214,10 @@ impl File { match self.0 {} } + pub fn can_write_vectored(&self) -> bool { + match self.0 {} + } + pub fn flush(&self) -> io::Result<()> { match self.0 {} } diff --git a/src/libstd/sys/cloudabi/shims/net.rs b/src/libstd/sys/cloudabi/shims/net.rs index 67c436fa795..22195661a2e 100644 --- a/src/libstd/sys/cloudabi/shims/net.rs +++ b/src/libstd/sys/cloudabi/shims/net.rs @@ -47,6 +47,10 @@ impl TcpStream { match self.0 {} } + pub fn can_read_vectored(&self) -> bool { + match self.0 {} + } + pub fn write(&self, _: &[u8]) -> io::Result { match self.0 {} } @@ -55,6 +59,10 @@ impl TcpStream { match self.0 {} } + pub fn can_write_vectored(&self) -> bool { + match self.0 {} + } + pub fn peer_addr(&self) -> io::Result { match self.0 {} } diff --git a/src/libstd/sys/cloudabi/shims/pipe.rs b/src/libstd/sys/cloudabi/shims/pipe.rs index fb14dc59101..eed8d1fdd56 100644 --- a/src/libstd/sys/cloudabi/shims/pipe.rs +++ b/src/libstd/sys/cloudabi/shims/pipe.rs @@ -12,6 +12,10 @@ impl AnonPipe { match self.0 {} } + pub fn can_read_vectored(&self) -> bool { + match self.0 {} + } + pub fn write(&self, _buf: &[u8]) -> io::Result { match self.0 {} } @@ -20,6 +24,10 @@ impl AnonPipe { match self.0 {} } + pub fn can_write_vectored(&self) -> bool { + match self.0 {} + } + pub fn diverge(&self) -> ! { match self.0 {} } diff --git a/src/libstd/sys/hermit/fs.rs b/src/libstd/sys/hermit/fs.rs index 287a0390667..8d9a359f94b 100644 --- a/src/libstd/sys/hermit/fs.rs +++ b/src/libstd/sys/hermit/fs.rs @@ -301,6 +301,11 @@ impl File { crate::io::default_read_vectored(|buf| self.read(buf), bufs) } + #[inline] + pub fn can_read_vectored(&self) -> bool { + false + } + pub fn write(&self, buf: &[u8]) -> io::Result { self.0.write(buf) } @@ -309,6 +314,11 @@ impl File { crate::io::default_write_vectored(|buf| self.write(buf), bufs) } + #[inline] + pub fn can_write_vectored(&self) -> bool { + false + } + pub fn flush(&self) -> io::Result<()> { Ok(()) } diff --git a/src/libstd/sys/hermit/net.rs b/src/libstd/sys/hermit/net.rs index 377c3132c5a..a8a82dba62e 100644 --- a/src/libstd/sys/hermit/net.rs +++ b/src/libstd/sys/hermit/net.rs @@ -99,6 +99,11 @@ impl TcpStream { Ok(size) } + #[inline] + pub fn can_read_vectored(&self) -> bool { + true + } + pub fn write(&self, buffer: &[u8]) -> io::Result { self.write_vectored(&[IoSlice::new(buffer)]) } @@ -114,6 +119,11 @@ impl TcpStream { Ok(size) } + #[inline] + pub fn can_write_vectored(&self) -> bool { + true + } + pub fn peer_addr(&self) -> io::Result { Err(io::Error::new(ErrorKind::Other, "peer_addr isn't supported")) } diff --git a/src/libstd/sys/hermit/pipe.rs b/src/libstd/sys/hermit/pipe.rs index fb14dc59101..eed8d1fdd56 100644 --- a/src/libstd/sys/hermit/pipe.rs +++ b/src/libstd/sys/hermit/pipe.rs @@ -12,6 +12,10 @@ impl AnonPipe { match self.0 {} } + pub fn can_read_vectored(&self) -> bool { + match self.0 {} + } + pub fn write(&self, _buf: &[u8]) -> io::Result { match self.0 {} } @@ -20,6 +24,10 @@ impl AnonPipe { match self.0 {} } + pub fn can_write_vectored(&self) -> bool { + match self.0 {} + } + pub fn diverge(&self) -> ! { match self.0 {} } diff --git a/src/libstd/sys/hermit/stdio.rs b/src/libstd/sys/hermit/stdio.rs index 2eb011ccb39..ba72775e145 100644 --- a/src/libstd/sys/hermit/stdio.rs +++ b/src/libstd/sys/hermit/stdio.rs @@ -20,6 +20,11 @@ impl Stdin { // .read(data) Ok(0) } + + #[inline] + pub fn can_read_vectored(&self) -> bool { + true + } } impl Stdout { @@ -51,6 +56,11 @@ impl Stdout { } } + #[inline] + pub fn can_write_vectored(&self) -> bool { + true + } + pub fn flush(&self) -> io::Result<()> { Ok(()) } @@ -85,6 +95,11 @@ impl Stderr { } } + #[inline] + pub fn can_write_vectored(&self) -> bool { + true + } + pub fn flush(&self) -> io::Result<()> { Ok(()) } diff --git a/src/libstd/sys/sgx/fd.rs b/src/libstd/sys/sgx/fd.rs index 7da2424a642..6cc7adde4d1 100644 --- a/src/libstd/sys/sgx/fd.rs +++ b/src/libstd/sys/sgx/fd.rs @@ -34,6 +34,11 @@ impl FileDesc { usercalls::read(self.fd, bufs) } + #[inline] + pub fn can_read_vectored(&self) -> bool { + true + } + pub fn write(&self, buf: &[u8]) -> io::Result { usercalls::write(self.fd, &[IoSlice::new(buf)]) } @@ -42,6 +47,11 @@ impl FileDesc { usercalls::write(self.fd, bufs) } + #[inline] + pub fn can_write_vectored(&self) -> bool { + true + } + pub fn flush(&self) -> io::Result<()> { usercalls::flush(self.fd) } diff --git a/src/libstd/sys/sgx/fs.rs b/src/libstd/sys/sgx/fs.rs index e6160d1457d..e34483447e9 100644 --- a/src/libstd/sys/sgx/fs.rs +++ b/src/libstd/sys/sgx/fs.rs @@ -202,6 +202,10 @@ impl File { match self.0 {} } + pub fn can_read_vectored(&self) -> bool { + match self.0 {} + } + pub fn write(&self, _buf: &[u8]) -> io::Result { match self.0 {} } @@ -210,6 +214,10 @@ impl File { match self.0 {} } + pub fn can_write_vectored(&self) -> bool { + match self.0 {} + } + pub fn flush(&self) -> io::Result<()> { match self.0 {} } diff --git a/src/libstd/sys/sgx/net.rs b/src/libstd/sys/sgx/net.rs index bd0652ab464..12a9a1289df 100644 --- a/src/libstd/sys/sgx/net.rs +++ b/src/libstd/sys/sgx/net.rs @@ -149,6 +149,11 @@ impl TcpStream { self.inner.inner.read_vectored(bufs) } + #[inline] + pub fn can_read_vectored(&self) -> bool { + self.inner.inner.can_read_vectored() + } + pub fn write(&self, buf: &[u8]) -> io::Result { self.inner.inner.write(buf) } @@ -157,6 +162,11 @@ impl TcpStream { self.inner.inner.write_vectored(bufs) } + #[inline] + pub fn can_write_vectored(&self) -> bool { + self.inner.inner.can_write_vectored() + } + pub fn peer_addr(&self) -> io::Result { addr_to_sockaddr(&self.peer_addr) } diff --git a/src/libstd/sys/sgx/pipe.rs b/src/libstd/sys/sgx/pipe.rs index fb14dc59101..eed8d1fdd56 100644 --- a/src/libstd/sys/sgx/pipe.rs +++ b/src/libstd/sys/sgx/pipe.rs @@ -12,6 +12,10 @@ impl AnonPipe { match self.0 {} } + pub fn can_read_vectored(&self) -> bool { + match self.0 {} + } + pub fn write(&self, _buf: &[u8]) -> io::Result { match self.0 {} } @@ -20,6 +24,10 @@ impl AnonPipe { match self.0 {} } + pub fn can_write_vectored(&self) -> bool { + match self.0 {} + } + pub fn diverge(&self) -> ! { match self.0 {} } diff --git a/src/libstd/sys/unix/ext/net.rs b/src/libstd/sys/unix/ext/net.rs index 4c3cb67c9ee..60ec73d9de2 100644 --- a/src/libstd/sys/unix/ext/net.rs +++ b/src/libstd/sys/unix/ext/net.rs @@ -613,6 +613,11 @@ impl io::Read for UnixStream { io::Read::read_vectored(&mut &*self, bufs) } + #[inline] + fn can_read_vectored(&self) -> bool { + io::Read::can_read_vectored(&&*self) + } + #[inline] unsafe fn initializer(&self) -> Initializer { Initializer::nop() @@ -629,6 +634,11 @@ impl<'a> io::Read for &'a UnixStream { self.0.read_vectored(bufs) } + #[inline] + fn can_read_vectored(&self) -> bool { + self.0.can_read_vectored() + } + #[inline] unsafe fn initializer(&self) -> Initializer { Initializer::nop() @@ -645,6 +655,11 @@ impl io::Write for UnixStream { io::Write::write_vectored(&mut &*self, bufs) } + #[inline] + fn can_write_vectored(&self) -> bool { + io::Write::can_write_vectored(&&*self) + } + fn flush(&mut self) -> io::Result<()> { io::Write::flush(&mut &*self) } @@ -660,6 +675,11 @@ impl<'a> io::Write for &'a UnixStream { self.0.write_vectored(bufs) } + #[inline] + fn can_write_vectored(&self) -> bool { + self.0.can_write_vectored() + } + fn flush(&mut self) -> io::Result<()> { Ok(()) } diff --git a/src/libstd/sys/unix/fd.rs b/src/libstd/sys/unix/fd.rs index 1bba56e334a..7083785f426 100644 --- a/src/libstd/sys/unix/fd.rs +++ b/src/libstd/sys/unix/fd.rs @@ -64,6 +64,11 @@ impl FileDesc { Ok(ret as usize) } + #[inline] + pub fn can_read_vectored(&self) -> bool { + true + } + pub fn read_to_end(&self, buf: &mut Vec) -> io::Result { let mut me = self; (&mut me).read_to_end(buf) @@ -116,6 +121,11 @@ impl FileDesc { Ok(ret as usize) } + #[inline] + pub fn can_write_vectored(&self) -> bool { + true + } + pub fn write_at(&self, buf: &[u8], offset: u64) -> io::Result { #[cfg(target_os = "android")] use super::android::cvt_pwrite64; diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs index a233aa47dff..1e8bbd4325b 100644 --- a/src/libstd/sys/unix/fs.rs +++ b/src/libstd/sys/unix/fs.rs @@ -828,6 +828,11 @@ impl File { self.0.read_vectored(bufs) } + #[inline] + pub fn can_read_vectored(&self) -> bool { + self.0.can_read_vectored() + } + pub fn read_at(&self, buf: &mut [u8], offset: u64) -> io::Result { self.0.read_at(buf, offset) } @@ -840,6 +845,11 @@ impl File { self.0.write_vectored(bufs) } + #[inline] + pub fn can_write_vectored(&self) -> bool { + self.0.can_write_vectored() + } + pub fn write_at(&self, buf: &[u8], offset: u64) -> io::Result { self.0.write_at(buf, offset) } diff --git a/src/libstd/sys/unix/l4re.rs b/src/libstd/sys/unix/l4re.rs index c6e4f5693ed..8510e56af37 100644 --- a/src/libstd/sys/unix/l4re.rs +++ b/src/libstd/sys/unix/l4re.rs @@ -55,6 +55,10 @@ pub mod net { unimpl!(); } + pub fn can_read_vectored(&self) -> bool { + unimpl!(); + } + pub fn peek(&self, _: &mut [u8]) -> io::Result { unimpl!(); } @@ -75,6 +79,10 @@ pub mod net { unimpl!(); } + pub fn can_write_vectored(&self) -> bool { + unimpl!(); + } + pub fn set_timeout(&self, _: Option, _: libc::c_int) -> io::Result<()> { unimpl!(); } @@ -171,6 +179,10 @@ pub mod net { unimpl!(); } + pub fn can_read_vectored(&self) -> bool { + unimpl!(); + } + pub fn write(&self, _: &[u8]) -> io::Result { unimpl!(); } @@ -179,6 +191,10 @@ pub mod net { unimpl!(); } + pub fn can_write_vectored(&self) -> bool { + unimpl!(); + } + pub fn peer_addr(&self) -> io::Result { unimpl!(); } diff --git a/src/libstd/sys/unix/net.rs b/src/libstd/sys/unix/net.rs index d18c22b0573..ed97ddf333f 100644 --- a/src/libstd/sys/unix/net.rs +++ b/src/libstd/sys/unix/net.rs @@ -226,6 +226,11 @@ impl Socket { self.0.read_vectored(bufs) } + #[inline] + pub fn can_read_vectored(&self) -> bool { + self.0.can_read_vectored() + } + fn recv_from_with_flags( &self, buf: &mut [u8], @@ -263,6 +268,11 @@ impl Socket { self.0.write_vectored(bufs) } + #[inline] + pub fn can_write_vectored(&self) -> bool { + self.0.can_write_vectored() + } + pub fn set_timeout(&self, dur: Option, kind: libc::c_int) -> io::Result<()> { let timeout = match dur { Some(dur) => { diff --git a/src/libstd/sys/unix/pipe.rs b/src/libstd/sys/unix/pipe.rs index 2a861c87801..d8ac36df9ec 100644 --- a/src/libstd/sys/unix/pipe.rs +++ b/src/libstd/sys/unix/pipe.rs @@ -64,6 +64,11 @@ impl AnonPipe { self.0.read_vectored(bufs) } + #[inline] + pub fn can_read_vectored(&self) -> bool { + self.0.can_read_vectored() + } + pub fn write(&self, buf: &[u8]) -> io::Result { self.0.write(buf) } @@ -72,6 +77,11 @@ impl AnonPipe { self.0.write_vectored(bufs) } + #[inline] + pub fn can_write_vectored(&self) -> bool { + self.0.can_write_vectored() + } + pub fn fd(&self) -> &FileDesc { &self.0 } diff --git a/src/libstd/sys/unix/stdio.rs b/src/libstd/sys/unix/stdio.rs index b9c56963885..4026dd4e497 100644 --- a/src/libstd/sys/unix/stdio.rs +++ b/src/libstd/sys/unix/stdio.rs @@ -20,6 +20,11 @@ impl io::Read for Stdin { fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> io::Result { ManuallyDrop::new(FileDesc::new(libc::STDIN_FILENO)).read_vectored(bufs) } + + #[inline] + fn can_read_vectored(&self) -> bool { + true + } } impl Stdout { @@ -37,6 +42,11 @@ impl io::Write for Stdout { ManuallyDrop::new(FileDesc::new(libc::STDOUT_FILENO)).write_vectored(bufs) } + #[inline] + fn can_write_vectored(&self) -> bool { + true + } + fn flush(&mut self) -> io::Result<()> { Ok(()) } @@ -57,6 +67,11 @@ impl io::Write for Stderr { ManuallyDrop::new(FileDesc::new(libc::STDERR_FILENO)).write_vectored(bufs) } + #[inline] + fn can_write_vectored(&self) -> bool { + true + } + fn flush(&mut self) -> io::Result<()> { Ok(()) } diff --git a/src/libstd/sys/vxworks/fd.rs b/src/libstd/sys/vxworks/fd.rs index 65c67dabc1a..0593db65047 100644 --- a/src/libstd/sys/vxworks/fd.rs +++ b/src/libstd/sys/vxworks/fd.rs @@ -54,6 +54,11 @@ impl FileDesc { Ok(ret as usize) } + #[inline] + fn can_read_vectored(&self) -> bool { + true + } + pub fn read_to_end(&self, buf: &mut Vec) -> io::Result { let mut me = self; (&mut me).read_to_end(buf) @@ -99,6 +104,11 @@ impl FileDesc { Ok(ret as usize) } + #[inline] + pub fn can_write_vectored(&self) -> bool { + true + } + pub fn write_at(&self, buf: &[u8], offset: u64) -> io::Result { unsafe fn cvt_pwrite( fd: c_int, diff --git a/src/libstd/sys/vxworks/fs.rs b/src/libstd/sys/vxworks/fs.rs index 68f2c133170..449431f23d9 100644 --- a/src/libstd/sys/vxworks/fs.rs +++ b/src/libstd/sys/vxworks/fs.rs @@ -351,6 +351,11 @@ impl File { self.0.read_vectored(bufs) } + #[inline] + pub fn can_read_vectored(&self) -> bool { + self.0.can_read_vectored() + } + pub fn read_at(&self, buf: &mut [u8], offset: u64) -> io::Result { self.0.read_at(buf, offset) } @@ -363,6 +368,11 @@ impl File { self.0.write_vectored(bufs) } + #[inline] + pub fn can_write_vectored(&self) -> bool { + self.0.can_write_vectored() + } + pub fn write_at(&self, buf: &[u8], offset: u64) -> io::Result { self.0.write_at(buf, offset) } diff --git a/src/libstd/sys/vxworks/net.rs b/src/libstd/sys/vxworks/net.rs index 7d4e5624f7e..455bbf3683f 100644 --- a/src/libstd/sys/vxworks/net.rs +++ b/src/libstd/sys/vxworks/net.rs @@ -163,6 +163,11 @@ impl Socket { self.0.read_vectored(bufs) } + #[inline] + pub fn can_read_vectored(&self) -> bool { + self.0.can_read_vectored() + } + fn recv_from_with_flags( &self, buf: &mut [u8], @@ -200,6 +205,11 @@ impl Socket { self.0.write_vectored(bufs) } + #[inline] + pub fn can_write_vectored(&self) -> bool { + self.0.can_write_vectored() + } + pub fn set_timeout(&self, dur: Option, kind: libc::c_int) -> io::Result<()> { let timeout = match dur { Some(dur) => { diff --git a/src/libstd/sys/vxworks/pipe.rs b/src/libstd/sys/vxworks/pipe.rs index 0990cb8e83c..eb99eba9888 100644 --- a/src/libstd/sys/vxworks/pipe.rs +++ b/src/libstd/sys/vxworks/pipe.rs @@ -24,10 +24,16 @@ impl AnonPipe { pub fn read(&self, buf: &mut [u8]) -> io::Result { self.0.read(buf) } + pub fn read_vectored(&self, bufs: &mut [IoSliceMut<'_>]) -> io::Result { self.0.read_vectored(bufs) } + #[inline] + pub fn can_read_vectored(&self) -> bool { + self.0.can_read_vectored() + } + pub fn write(&self, buf: &[u8]) -> io::Result { self.0.write(buf) } @@ -36,6 +42,11 @@ impl AnonPipe { self.0.write_vectored(bufs) } + #[inline] + pub fn can_write_vectored(&self) -> bool { + self.0.can_write_vectored() + } + pub fn fd(&self) -> &FileDesc { &self.0 } diff --git a/src/libstd/sys/wasi/fs.rs b/src/libstd/sys/wasi/fs.rs index a11f61fdd69..eaf8d3e0ae8 100644 --- a/src/libstd/sys/wasi/fs.rs +++ b/src/libstd/sys/wasi/fs.rs @@ -399,6 +399,11 @@ impl File { self.fd.read(bufs) } + #[inline] + pub fn can_read_vectored(&self) -> bool { + true + } + pub fn write(&self, buf: &[u8]) -> io::Result { self.write_vectored(&[IoSlice::new(buf)]) } @@ -407,6 +412,11 @@ impl File { self.fd.write(bufs) } + #[inline] + pub fn can_write_vectored(&self) -> bool { + true + } + pub fn flush(&self) -> io::Result<()> { Ok(()) } diff --git a/src/libstd/sys/wasi/net.rs b/src/libstd/sys/wasi/net.rs index 8a69028ff1d..ac4f55f5f86 100644 --- a/src/libstd/sys/wasi/net.rs +++ b/src/libstd/sys/wasi/net.rs @@ -48,6 +48,10 @@ impl TcpStream { unsupported() } + pub fn can_read_vectored(&self) -> bool { + unsupported() + } + pub fn write(&self, _: &[u8]) -> io::Result { unsupported() } @@ -56,6 +60,10 @@ impl TcpStream { unsupported() } + pub fn can_write_vectored(&self) -> bool { + unsupported() + } + pub fn peer_addr(&self) -> io::Result { unsupported() } diff --git a/src/libstd/sys/wasi/pipe.rs b/src/libstd/sys/wasi/pipe.rs index fb14dc59101..eed8d1fdd56 100644 --- a/src/libstd/sys/wasi/pipe.rs +++ b/src/libstd/sys/wasi/pipe.rs @@ -12,6 +12,10 @@ impl AnonPipe { match self.0 {} } + pub fn can_read_vectored(&self) -> bool { + match self.0 {} + } + pub fn write(&self, _buf: &[u8]) -> io::Result { match self.0 {} } @@ -20,6 +24,10 @@ impl AnonPipe { match self.0 {} } + pub fn can_write_vectored(&self) -> bool { + match self.0 {} + } + pub fn diverge(&self) -> ! { match self.0 {} } diff --git a/src/libstd/sys/wasi/stdio.rs b/src/libstd/sys/wasi/stdio.rs index 1d53884f2d6..01b041141a7 100644 --- a/src/libstd/sys/wasi/stdio.rs +++ b/src/libstd/sys/wasi/stdio.rs @@ -19,6 +19,11 @@ impl Stdin { ManuallyDrop::new(unsafe { WasiFd::from_raw(self.as_raw_fd()) }).read(data) } + #[inline] + pub fn can_read_vectored(&self) -> bool { + true + } + pub fn as_raw_fd(&self) -> u32 { 0 } @@ -37,6 +42,11 @@ impl Stdout { ManuallyDrop::new(unsafe { WasiFd::from_raw(self.as_raw_fd()) }).write(data) } + #[inline] + pub fn can_write_vectored(&self) -> bool { + true + } + pub fn flush(&self) -> io::Result<()> { Ok(()) } @@ -59,6 +69,11 @@ impl Stderr { ManuallyDrop::new(unsafe { WasiFd::from_raw(self.as_raw_fd()) }).write(data) } + #[inline] + pub fn can_write_vectored(&self) -> bool { + true + } + pub fn flush(&self) -> io::Result<()> { Ok(()) } diff --git a/src/libstd/sys/wasm/fs.rs b/src/libstd/sys/wasm/fs.rs index e6160d1457d..e34483447e9 100644 --- a/src/libstd/sys/wasm/fs.rs +++ b/src/libstd/sys/wasm/fs.rs @@ -202,6 +202,10 @@ impl File { match self.0 {} } + pub fn can_read_vectored(&self) -> bool { + match self.0 {} + } + pub fn write(&self, _buf: &[u8]) -> io::Result { match self.0 {} } @@ -210,6 +214,10 @@ impl File { match self.0 {} } + pub fn can_write_vectored(&self) -> bool { + match self.0 {} + } + pub fn flush(&self) -> io::Result<()> { match self.0 {} } diff --git a/src/libstd/sys/wasm/net.rs b/src/libstd/sys/wasm/net.rs index b7c3108f172..b9c54f4612e 100644 --- a/src/libstd/sys/wasm/net.rs +++ b/src/libstd/sys/wasm/net.rs @@ -44,6 +44,10 @@ impl TcpStream { match self.0 {} } + pub fn can_read_vectored(&self) -> bool { + match self.0 {} + } + pub fn write(&self, _: &[u8]) -> io::Result { match self.0 {} } @@ -52,6 +56,10 @@ impl TcpStream { match self.0 {} } + pub fn can_write_vectored(&self) -> bool { + match self.0 {} + } + pub fn peer_addr(&self) -> io::Result { match self.0 {} } diff --git a/src/libstd/sys/windows/fs.rs b/src/libstd/sys/windows/fs.rs index 427f4b684e1..70134439290 100644 --- a/src/libstd/sys/windows/fs.rs +++ b/src/libstd/sys/windows/fs.rs @@ -409,6 +409,11 @@ impl File { self.handle.read_vectored(bufs) } + #[inline] + pub fn can_read_vectored(&self) -> bool { + self.handle.can_read_vectored() + } + pub fn read_at(&self, buf: &mut [u8], offset: u64) -> io::Result { self.handle.read_at(buf, offset) } @@ -421,6 +426,11 @@ impl File { self.handle.write_vectored(bufs) } + #[inline] + pub fn can_write_vectored(&self) -> bool { + self.handle.can_write_vectored() + } + pub fn write_at(&self, buf: &[u8], offset: u64) -> io::Result { self.handle.write_at(buf, offset) } diff --git a/src/libstd/sys/windows/handle.rs b/src/libstd/sys/windows/handle.rs index d00381792e3..15a8af71d7f 100644 --- a/src/libstd/sys/windows/handle.rs +++ b/src/libstd/sys/windows/handle.rs @@ -92,6 +92,11 @@ impl RawHandle { crate::io::default_read_vectored(|buf| self.read(buf), bufs) } + #[inline] + pub fn can_read_vectored(&self) -> bool { + false + } + pub fn read_at(&self, buf: &mut [u8], offset: u64) -> io::Result { let mut read = 0; let len = cmp::min(buf.len(), ::max_value() as usize) as c::DWORD; @@ -171,6 +176,11 @@ impl RawHandle { crate::io::default_write_vectored(|buf| self.write(buf), bufs) } + #[inline] + pub fn can_write_vectored(&self) -> bool { + false + } + pub fn write_at(&self, buf: &[u8], offset: u64) -> io::Result { let mut written = 0; let len = cmp::min(buf.len(), ::max_value() as usize) as c::DWORD; diff --git a/src/libstd/sys/windows/net.rs b/src/libstd/sys/windows/net.rs index d8d4fdfce2f..1b4411e38aa 100644 --- a/src/libstd/sys/windows/net.rs +++ b/src/libstd/sys/windows/net.rs @@ -266,6 +266,11 @@ impl Socket { } } + #[inline] + pub fn can_read_vectored(&self) -> bool { + true + } + pub fn peek(&self, buf: &mut [u8]) -> io::Result { self.recv_with_flags(buf, c::MSG_PEEK) } @@ -324,6 +329,11 @@ impl Socket { Ok(nwritten as usize) } + #[inline] + pub fn can_write_vectored(&self) -> bool { + true + } + pub fn set_timeout(&self, dur: Option, kind: c_int) -> io::Result<()> { let timeout = match dur { Some(dur) => { diff --git a/src/libstd/sys/windows/pipe.rs b/src/libstd/sys/windows/pipe.rs index 992e634dea5..f6358cf9efd 100644 --- a/src/libstd/sys/windows/pipe.rs +++ b/src/libstd/sys/windows/pipe.rs @@ -182,6 +182,11 @@ impl AnonPipe { self.inner.read_vectored(bufs) } + #[inline] + pub fn can_read_vectored(&self) -> bool { + self.inner.can_read_vectored() + } + pub fn write(&self, buf: &[u8]) -> io::Result { self.inner.write(buf) } @@ -189,6 +194,11 @@ impl AnonPipe { pub fn write_vectored(&self, bufs: &[IoSlice<'_>]) -> io::Result { self.inner.write_vectored(bufs) } + + #[inline] + pub fn can_write_vectored(&self) -> bool { + self.inner.can_write_vectored() + } } pub fn read2(p1: AnonPipe, v1: &mut Vec, p2: AnonPipe, v2: &mut Vec) -> io::Result<()> { diff --git a/src/libstd/sys_common/net.rs b/src/libstd/sys_common/net.rs index cdd3d2edf1f..bfa93cb4e2c 100644 --- a/src/libstd/sys_common/net.rs +++ b/src/libstd/sys_common/net.rs @@ -265,6 +265,11 @@ impl TcpStream { self.inner.read_vectored(bufs) } + #[inline] + pub fn can_read_vectored(&self) -> bool { + self.inner.can_read_vectored() + } + pub fn write(&self, buf: &[u8]) -> io::Result { let len = cmp::min(buf.len(), ::max_value() as usize) as wrlen_t; let ret = cvt(unsafe { @@ -277,6 +282,11 @@ impl TcpStream { self.inner.write_vectored(bufs) } + #[inline] + pub fn can_write_vectored(&self) -> bool { + self.inner.can_write_vectored() + } + pub fn peer_addr(&self) -> io::Result { sockname(|buf, len| unsafe { c::getpeername(*self.inner.as_inner(), buf, len) }) } From 07443f17d4c2e8135d1cbf415f6bd22eee86b64a Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Wed, 11 Mar 2020 18:02:52 -0700 Subject: [PATCH 03/13] Update name --- src/libstd/fs.rs | 16 +++++----- src/libstd/io/buffered.rs | 8 ++--- src/libstd/io/cursor.rs | 10 +++--- src/libstd/io/impls.rs | 22 +++++++------- src/libstd/io/mod.rs | 8 ++--- src/libstd/io/stdio.rs | 44 +++++++++++++-------------- src/libstd/io/util.rs | 4 +-- src/libstd/net/tcp.rs | 16 +++++----- src/libstd/process.rs | 12 ++++---- src/libstd/sys/cloudabi/shims/fs.rs | 2 +- src/libstd/sys/cloudabi/shims/net.rs | 2 +- src/libstd/sys/cloudabi/shims/pipe.rs | 2 +- src/libstd/sys/hermit/fs.rs | 4 +-- src/libstd/sys/hermit/net.rs | 4 +-- src/libstd/sys/hermit/pipe.rs | 4 +-- src/libstd/sys/hermit/stdio.rs | 6 ++-- src/libstd/sys/sgx/fd.rs | 4 +-- src/libstd/sys/sgx/fs.rs | 4 +-- src/libstd/sys/sgx/net.rs | 6 ++-- src/libstd/sys/sgx/pipe.rs | 4 +-- src/libstd/sys/unix/ext/net.rs | 6 ++-- src/libstd/sys/unix/fd.rs | 4 +-- src/libstd/sys/unix/fs.rs | 8 ++--- src/libstd/sys/unix/l4re.rs | 8 ++--- src/libstd/sys/unix/net.rs | 8 ++--- src/libstd/sys/unix/pipe.rs | 8 ++--- src/libstd/sys/unix/stdio.rs | 6 ++-- src/libstd/sys/vxworks/fd.rs | 4 +-- src/libstd/sys/vxworks/fs.rs | 8 ++--- src/libstd/sys/vxworks/net.rs | 8 ++--- src/libstd/sys/vxworks/pipe.rs | 8 ++--- src/libstd/sys/wasi/fs.rs | 4 +-- src/libstd/sys/wasi/net.rs | 4 +-- src/libstd/sys/wasi/pipe.rs | 4 +-- src/libstd/sys/wasi/stdio.rs | 6 ++-- src/libstd/sys/wasm/fs.rs | 4 +-- src/libstd/sys/wasm/net.rs | 4 +-- src/libstd/sys/windows/fs.rs | 8 ++--- src/libstd/sys/windows/handle.rs | 4 +-- src/libstd/sys/windows/net.rs | 4 +-- src/libstd/sys/windows/pipe.rs | 8 ++--- src/libstd/sys_common/net.rs | 8 ++--- 42 files changed, 158 insertions(+), 158 deletions(-) diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index cc2d79ee084..f4c164a324e 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -660,8 +660,8 @@ impl Read for File { } #[inline] - fn can_read_vectored(&self) -> bool { - self.inner.can_read_vectored() + fn is_read_vectored(&self) -> bool { + self.inner.is_read_vectored() } #[inline] @@ -680,8 +680,8 @@ impl Write for File { } #[inline] - fn can_write_vectored(&self) -> bool { - self.inner.can_write_vectored() + fn is_write_vectored(&self) -> bool { + self.inner.is_write_vectored() } fn flush(&mut self) -> io::Result<()> { @@ -705,8 +705,8 @@ impl Read for &File { } #[inline] - fn can_read_vectored(&self) -> bool { - self.inner.can_read_vectored() + fn is_read_vectored(&self) -> bool { + self.inner.is_read_vectored() } #[inline] @@ -725,8 +725,8 @@ impl Write for &File { } #[inline] - fn can_write_vectored(&self) -> bool { - self.inner.can_write_vectored() + fn is_write_vectored(&self) -> bool { + self.inner.is_write_vectored() } fn flush(&mut self) -> io::Result<()> { diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index cabeaf4ae77..046b1a68880 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -292,8 +292,8 @@ impl Read for BufReader { Ok(nread) } - fn can_read_vectored(&self) -> bool { - self.inner.can_read_vectored() + fn is_read_vectored(&self) -> bool { + self.inner.is_read_vectored() } // we can't skip unconditionally because of the large buffer case in read. @@ -684,8 +684,8 @@ impl Write for BufWriter { } } - fn can_write_vectored(&self) -> bool { - self.get_ref().can_write_vectored() + fn is_write_vectored(&self) -> bool { + self.get_ref().is_write_vectored() } fn flush(&mut self) -> io::Result<()> { diff --git a/src/libstd/io/cursor.rs b/src/libstd/io/cursor.rs index 859431ea0ef..f3e3fc81a5d 100644 --- a/src/libstd/io/cursor.rs +++ b/src/libstd/io/cursor.rs @@ -266,7 +266,7 @@ where Ok(nread) } - fn can_read_vectored(&self) -> bool { + fn is_read_vectored(&self) -> bool { true } @@ -377,7 +377,7 @@ impl Write for Cursor<&mut [u8]> { } #[inline] - fn can_write_vectored(&self) -> bool { + fn is_write_vectored(&self) -> bool { true } @@ -398,7 +398,7 @@ impl Write for Cursor<&mut Vec> { } #[inline] - fn can_write_vectored(&self) -> bool { + fn is_write_vectored(&self) -> bool { true } @@ -419,7 +419,7 @@ impl Write for Cursor> { } #[inline] - fn can_write_vectored(&self) -> bool { + fn is_write_vectored(&self) -> bool { true } @@ -442,7 +442,7 @@ impl Write for Cursor> { } #[inline] - fn can_write_vectored(&self) -> bool { + fn is_write_vectored(&self) -> bool { true } diff --git a/src/libstd/io/impls.rs b/src/libstd/io/impls.rs index 1fb9f12dd90..01dff0b3eb3 100644 --- a/src/libstd/io/impls.rs +++ b/src/libstd/io/impls.rs @@ -21,8 +21,8 @@ impl Read for &mut R { } #[inline] - fn can_read_vectored(&self) -> bool { - (**self).can_read_vectored() + fn is_read_vectored(&self) -> bool { + (**self).is_read_vectored() } #[inline] @@ -58,8 +58,8 @@ impl Write for &mut W { } #[inline] - fn can_write_vectored(&self) -> bool { - (**self).can_write_vectored() + fn is_write_vectored(&self) -> bool { + (**self).is_write_vectored() } #[inline] @@ -120,8 +120,8 @@ impl Read for Box { } #[inline] - fn can_read_vectored(&self) -> bool { - (**self).can_read_vectored() + fn is_read_vectored(&self) -> bool { + (**self).is_read_vectored() } #[inline] @@ -157,8 +157,8 @@ impl Write for Box { } #[inline] - fn can_write_vectored(&self) -> bool { - (**self).can_write_vectored() + fn is_write_vectored(&self) -> bool { + (**self).is_write_vectored() } #[inline] @@ -261,7 +261,7 @@ impl Read for &[u8] { } #[inline] - fn can_read_vectored(&self) -> bool { + fn is_read_vectored(&self) -> bool { true } @@ -342,7 +342,7 @@ impl Write for &mut [u8] { } #[inline] - fn can_write_vectored(&self) -> bool { + fn is_write_vectored(&self) -> bool { true } @@ -382,7 +382,7 @@ impl Write for Vec { } #[inline] - fn can_write_vectored(&self) -> bool { + fn is_write_vectored(&self) -> bool { true } diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index c6229fb39e0..c9db48db9bd 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -588,8 +588,8 @@ pub trait Read { /// and coalesce writes into a single buffer for higher performance. /// /// The default implementation returns `false`. - #[unstable(feature = "can_vector", issue = "none")] - fn can_read_vectored(&self) -> bool { + #[unstable(feature = "can_vector", issue = "69941")] + fn is_read_vectored(&self) -> bool { false } @@ -1325,8 +1325,8 @@ pub trait Write { /// and coalesce writes into a single buffer for higher performance. /// /// The default implementation returns `false`. - #[unstable(feature = "can_vector", issue = "none")] - fn can_write_vectored(&self) -> bool { + #[unstable(feature = "can_vector", issue = "69941")] + fn is_write_vectored(&self) -> bool { false } diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs index fd5a1291785..b65b150d2c3 100644 --- a/src/libstd/io/stdio.rs +++ b/src/libstd/io/stdio.rs @@ -88,8 +88,8 @@ impl Read for StdinRaw { } #[inline] - fn can_read_vectored(&self) -> bool { - self.0.can_read_vectored() + fn is_read_vectored(&self) -> bool { + self.0.is_read_vectored() } #[inline] @@ -107,8 +107,8 @@ impl Write for StdoutRaw { } #[inline] - fn can_write_vectored(&self) -> bool { - self.0.can_write_vectored() + fn is_write_vectored(&self) -> bool { + self.0.is_write_vectored() } fn flush(&mut self) -> io::Result<()> { @@ -125,8 +125,8 @@ impl Write for StderrRaw { } #[inline] - fn can_write_vectored(&self) -> bool { - self.0.can_write_vectored() + fn is_write_vectored(&self) -> bool { + self.0.is_write_vectored() } fn flush(&mut self) -> io::Result<()> { @@ -156,9 +156,9 @@ impl io::Write for Maybe { } #[inline] - fn can_write_vectored(&self) -> bool { + fn is_write_vectored(&self) -> bool { match self { - Maybe::Real(w) => w.can_write_vectored(), + Maybe::Real(w) => w.is_write_vectored(), Maybe::Fake => true, } } @@ -187,9 +187,9 @@ impl io::Read for Maybe { } #[inline] - fn can_read_vectored(&self) -> bool { + fn is_read_vectored(&self) -> bool { match self { - Maybe::Real(w) => w.can_read_vectored(), + Maybe::Real(w) => w.is_read_vectored(), Maybe::Fake => true, } } @@ -383,8 +383,8 @@ impl Read for Stdin { self.lock().read_vectored(bufs) } #[inline] - fn can_read_vectored(&self) -> bool { - self.lock().can_read_vectored() + fn is_read_vectored(&self) -> bool { + self.lock().is_read_vectored() } #[inline] unsafe fn initializer(&self) -> Initializer { @@ -412,8 +412,8 @@ impl Read for StdinLock<'_> { } #[inline] - fn can_read_vectored(&self) -> bool { - self.inner.can_read_vectored() + fn is_read_vectored(&self) -> bool { + self.inner.is_read_vectored() } #[inline] @@ -584,8 +584,8 @@ impl Write for Stdout { self.lock().write_vectored(bufs) } #[inline] - fn can_write_vectored(&self) -> bool { - self.lock().can_write_vectored() + fn is_write_vectored(&self) -> bool { + self.lock().is_write_vectored() } fn flush(&mut self) -> io::Result<()> { self.lock().flush() @@ -606,8 +606,8 @@ impl Write for StdoutLock<'_> { self.inner.borrow_mut().write_vectored(bufs) } #[inline] - fn can_write_vectored(&self) -> bool { - self.inner.borrow_mut().can_write_vectored() + fn is_write_vectored(&self) -> bool { + self.inner.borrow_mut().is_write_vectored() } fn flush(&mut self) -> io::Result<()> { self.inner.borrow_mut().flush() @@ -758,8 +758,8 @@ impl Write for Stderr { self.lock().write_vectored(bufs) } #[inline] - fn can_write_vectored(&self) -> bool { - self.lock().can_write_vectored() + fn is_write_vectored(&self) -> bool { + self.lock().is_write_vectored() } fn flush(&mut self) -> io::Result<()> { self.lock().flush() @@ -780,8 +780,8 @@ impl Write for StderrLock<'_> { self.inner.borrow_mut().write_vectored(bufs) } #[inline] - fn can_write_vectored(&self) -> bool { - self.inner.borrow_mut().can_write_vectored() + fn is_write_vectored(&self) -> bool { + self.inner.borrow_mut().is_write_vectored() } fn flush(&mut self) -> io::Result<()> { self.inner.borrow_mut().flush() diff --git a/src/libstd/io/util.rs b/src/libstd/io/util.rs index 01947cd8b89..b9d5dc27db0 100644 --- a/src/libstd/io/util.rs +++ b/src/libstd/io/util.rs @@ -180,7 +180,7 @@ impl Read for Repeat { } #[inline] - fn can_read_vectored(&self) -> bool { + fn is_read_vectored(&self) -> bool { true } @@ -241,7 +241,7 @@ impl Write for Sink { } #[inline] - fn can_write_vectored(&self) -> bool { + fn is_write_vectored(&self) -> bool { true } diff --git a/src/libstd/net/tcp.rs b/src/libstd/net/tcp.rs index 86955a79759..9ac54dd5f7a 100644 --- a/src/libstd/net/tcp.rs +++ b/src/libstd/net/tcp.rs @@ -577,8 +577,8 @@ impl Read for TcpStream { } #[inline] - fn can_read_vectored(&self) -> bool { - self.0.can_read_vectored() + fn is_read_vectored(&self) -> bool { + self.0.is_read_vectored() } #[inline] @@ -597,8 +597,8 @@ impl Write for TcpStream { } #[inline] - fn can_write_vectored(&self) -> bool { - self.0.can_write_vectored() + fn is_write_vectored(&self) -> bool { + self.0.is_write_vectored() } fn flush(&mut self) -> io::Result<()> { @@ -616,8 +616,8 @@ impl Read for &TcpStream { } #[inline] - fn can_read_vectored(&self) -> bool { - self.0.can_read_vectored() + fn is_read_vectored(&self) -> bool { + self.0.is_read_vectored() } #[inline] @@ -636,8 +636,8 @@ impl Write for &TcpStream { } #[inline] - fn can_write_vectored(&self) -> bool { - self.0.can_write_vectored() + fn is_write_vectored(&self) -> bool { + self.0.is_write_vectored() } fn flush(&mut self) -> io::Result<()> { diff --git a/src/libstd/process.rs b/src/libstd/process.rs index 2d22eb4ceaf..b457d190b95 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -245,8 +245,8 @@ impl Write for ChildStdin { self.inner.write_vectored(bufs) } - fn can_write_vectored(&self) -> bool { - self.inner.can_write_vectored() + fn is_write_vectored(&self) -> bool { + self.inner.is_write_vectored() } fn flush(&mut self) -> io::Result<()> { @@ -305,8 +305,8 @@ impl Read for ChildStdout { } #[inline] - fn can_read_vectored(&self) -> bool { - self.inner.can_read_vectored() + fn is_read_vectored(&self) -> bool { + self.inner.is_read_vectored() } #[inline] @@ -366,8 +366,8 @@ impl Read for ChildStderr { } #[inline] - fn can_read_vectored(&self) -> bool { - self.inner.can_read_vectored() + fn is_read_vectored(&self) -> bool { + self.inner.is_read_vectored() } #[inline] diff --git a/src/libstd/sys/cloudabi/shims/fs.rs b/src/libstd/sys/cloudabi/shims/fs.rs index e34483447e9..9323d7d89cf 100644 --- a/src/libstd/sys/cloudabi/shims/fs.rs +++ b/src/libstd/sys/cloudabi/shims/fs.rs @@ -214,7 +214,7 @@ impl File { match self.0 {} } - pub fn can_write_vectored(&self) -> bool { + pub fn is_write_vectored(&self) -> bool { match self.0 {} } diff --git a/src/libstd/sys/cloudabi/shims/net.rs b/src/libstd/sys/cloudabi/shims/net.rs index 22195661a2e..9d40fa1a8ea 100644 --- a/src/libstd/sys/cloudabi/shims/net.rs +++ b/src/libstd/sys/cloudabi/shims/net.rs @@ -59,7 +59,7 @@ impl TcpStream { match self.0 {} } - pub fn can_write_vectored(&self) -> bool { + pub fn is_write_vectored(&self) -> bool { match self.0 {} } diff --git a/src/libstd/sys/cloudabi/shims/pipe.rs b/src/libstd/sys/cloudabi/shims/pipe.rs index eed8d1fdd56..b2b68a0f0ca 100644 --- a/src/libstd/sys/cloudabi/shims/pipe.rs +++ b/src/libstd/sys/cloudabi/shims/pipe.rs @@ -24,7 +24,7 @@ impl AnonPipe { match self.0 {} } - pub fn can_write_vectored(&self) -> bool { + pub fn is_write_vectored(&self) -> bool { match self.0 {} } diff --git a/src/libstd/sys/hermit/fs.rs b/src/libstd/sys/hermit/fs.rs index 8d9a359f94b..82ccab1462b 100644 --- a/src/libstd/sys/hermit/fs.rs +++ b/src/libstd/sys/hermit/fs.rs @@ -302,7 +302,7 @@ impl File { } #[inline] - pub fn can_read_vectored(&self) -> bool { + pub fn is_read_vectored(&self) -> bool { false } @@ -315,7 +315,7 @@ impl File { } #[inline] - pub fn can_write_vectored(&self) -> bool { + pub fn is_write_vectored(&self) -> bool { false } diff --git a/src/libstd/sys/hermit/net.rs b/src/libstd/sys/hermit/net.rs index a8a82dba62e..5b5379c8b05 100644 --- a/src/libstd/sys/hermit/net.rs +++ b/src/libstd/sys/hermit/net.rs @@ -100,7 +100,7 @@ impl TcpStream { } #[inline] - pub fn can_read_vectored(&self) -> bool { + pub fn is_read_vectored(&self) -> bool { true } @@ -120,7 +120,7 @@ impl TcpStream { } #[inline] - pub fn can_write_vectored(&self) -> bool { + pub fn is_write_vectored(&self) -> bool { true } diff --git a/src/libstd/sys/hermit/pipe.rs b/src/libstd/sys/hermit/pipe.rs index eed8d1fdd56..10d0925823e 100644 --- a/src/libstd/sys/hermit/pipe.rs +++ b/src/libstd/sys/hermit/pipe.rs @@ -12,7 +12,7 @@ impl AnonPipe { match self.0 {} } - pub fn can_read_vectored(&self) -> bool { + pub fn is_read_vectored(&self) -> bool { match self.0 {} } @@ -24,7 +24,7 @@ impl AnonPipe { match self.0 {} } - pub fn can_write_vectored(&self) -> bool { + pub fn is_write_vectored(&self) -> bool { match self.0 {} } diff --git a/src/libstd/sys/hermit/stdio.rs b/src/libstd/sys/hermit/stdio.rs index ba72775e145..208265de465 100644 --- a/src/libstd/sys/hermit/stdio.rs +++ b/src/libstd/sys/hermit/stdio.rs @@ -22,7 +22,7 @@ impl Stdin { } #[inline] - pub fn can_read_vectored(&self) -> bool { + pub fn is_read_vectored(&self) -> bool { true } } @@ -57,7 +57,7 @@ impl Stdout { } #[inline] - pub fn can_write_vectored(&self) -> bool { + pub fn is_write_vectored(&self) -> bool { true } @@ -96,7 +96,7 @@ impl Stderr { } #[inline] - pub fn can_write_vectored(&self) -> bool { + pub fn is_write_vectored(&self) -> bool { true } diff --git a/src/libstd/sys/sgx/fd.rs b/src/libstd/sys/sgx/fd.rs index 6cc7adde4d1..90158030c7f 100644 --- a/src/libstd/sys/sgx/fd.rs +++ b/src/libstd/sys/sgx/fd.rs @@ -35,7 +35,7 @@ impl FileDesc { } #[inline] - pub fn can_read_vectored(&self) -> bool { + pub fn is_read_vectored(&self) -> bool { true } @@ -48,7 +48,7 @@ impl FileDesc { } #[inline] - pub fn can_write_vectored(&self) -> bool { + pub fn is_write_vectored(&self) -> bool { true } diff --git a/src/libstd/sys/sgx/fs.rs b/src/libstd/sys/sgx/fs.rs index e34483447e9..ecb5b51cccd 100644 --- a/src/libstd/sys/sgx/fs.rs +++ b/src/libstd/sys/sgx/fs.rs @@ -202,7 +202,7 @@ impl File { match self.0 {} } - pub fn can_read_vectored(&self) -> bool { + pub fn is_read_vectored(&self) -> bool { match self.0 {} } @@ -214,7 +214,7 @@ impl File { match self.0 {} } - pub fn can_write_vectored(&self) -> bool { + pub fn is_write_vectored(&self) -> bool { match self.0 {} } diff --git a/src/libstd/sys/sgx/net.rs b/src/libstd/sys/sgx/net.rs index 12a9a1289df..75a48e98e73 100644 --- a/src/libstd/sys/sgx/net.rs +++ b/src/libstd/sys/sgx/net.rs @@ -150,7 +150,7 @@ impl TcpStream { } #[inline] - pub fn can_read_vectored(&self) -> bool { + pub fn is_read_vectored(&self) -> bool { self.inner.inner.can_read_vectored() } @@ -163,8 +163,8 @@ impl TcpStream { } #[inline] - pub fn can_write_vectored(&self) -> bool { - self.inner.inner.can_write_vectored() + pub fn is_write_vectored(&self) -> bool { + self.inner.inner.is_write_vectored() } pub fn peer_addr(&self) -> io::Result { diff --git a/src/libstd/sys/sgx/pipe.rs b/src/libstd/sys/sgx/pipe.rs index eed8d1fdd56..10d0925823e 100644 --- a/src/libstd/sys/sgx/pipe.rs +++ b/src/libstd/sys/sgx/pipe.rs @@ -12,7 +12,7 @@ impl AnonPipe { match self.0 {} } - pub fn can_read_vectored(&self) -> bool { + pub fn is_read_vectored(&self) -> bool { match self.0 {} } @@ -24,7 +24,7 @@ impl AnonPipe { match self.0 {} } - pub fn can_write_vectored(&self) -> bool { + pub fn is_write_vectored(&self) -> bool { match self.0 {} } diff --git a/src/libstd/sys/unix/ext/net.rs b/src/libstd/sys/unix/ext/net.rs index 60ec73d9de2..ca1a2b5b3fb 100644 --- a/src/libstd/sys/unix/ext/net.rs +++ b/src/libstd/sys/unix/ext/net.rs @@ -656,8 +656,8 @@ impl io::Write for UnixStream { } #[inline] - fn can_write_vectored(&self) -> bool { - io::Write::can_write_vectored(&&*self) + fn is_write_vectored(&self) -> bool { + io::Write::is_write_vectored(&&*self) } fn flush(&mut self) -> io::Result<()> { @@ -676,7 +676,7 @@ impl<'a> io::Write for &'a UnixStream { } #[inline] - fn can_write_vectored(&self) -> bool { + fn is_write_vectored(&self) -> bool { self.0.can_write_vectored() } diff --git a/src/libstd/sys/unix/fd.rs b/src/libstd/sys/unix/fd.rs index 7083785f426..1ef7ffacfcf 100644 --- a/src/libstd/sys/unix/fd.rs +++ b/src/libstd/sys/unix/fd.rs @@ -65,7 +65,7 @@ impl FileDesc { } #[inline] - pub fn can_read_vectored(&self) -> bool { + pub fn is_read_vectored(&self) -> bool { true } @@ -122,7 +122,7 @@ impl FileDesc { } #[inline] - pub fn can_write_vectored(&self) -> bool { + pub fn is_write_vectored(&self) -> bool { true } diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs index 1e8bbd4325b..2cfc63d9492 100644 --- a/src/libstd/sys/unix/fs.rs +++ b/src/libstd/sys/unix/fs.rs @@ -829,8 +829,8 @@ impl File { } #[inline] - pub fn can_read_vectored(&self) -> bool { - self.0.can_read_vectored() + pub fn is_read_vectored(&self) -> bool { + self.0.is_read_vectored() } pub fn read_at(&self, buf: &mut [u8], offset: u64) -> io::Result { @@ -846,8 +846,8 @@ impl File { } #[inline] - pub fn can_write_vectored(&self) -> bool { - self.0.can_write_vectored() + pub fn is_write_vectored(&self) -> bool { + self.0.is_write_vectored() } pub fn write_at(&self, buf: &[u8], offset: u64) -> io::Result { diff --git a/src/libstd/sys/unix/l4re.rs b/src/libstd/sys/unix/l4re.rs index 8510e56af37..a2912387108 100644 --- a/src/libstd/sys/unix/l4re.rs +++ b/src/libstd/sys/unix/l4re.rs @@ -55,7 +55,7 @@ pub mod net { unimpl!(); } - pub fn can_read_vectored(&self) -> bool { + pub fn is_read_vectored(&self) -> bool { unimpl!(); } @@ -79,7 +79,7 @@ pub mod net { unimpl!(); } - pub fn can_write_vectored(&self) -> bool { + pub fn is_write_vectored(&self) -> bool { unimpl!(); } @@ -179,7 +179,7 @@ pub mod net { unimpl!(); } - pub fn can_read_vectored(&self) -> bool { + pub fn is_read_vectored(&self) -> bool { unimpl!(); } @@ -191,7 +191,7 @@ pub mod net { unimpl!(); } - pub fn can_write_vectored(&self) -> bool { + pub fn is_write_vectored(&self) -> bool { unimpl!(); } diff --git a/src/libstd/sys/unix/net.rs b/src/libstd/sys/unix/net.rs index ed97ddf333f..f062bc012f7 100644 --- a/src/libstd/sys/unix/net.rs +++ b/src/libstd/sys/unix/net.rs @@ -227,8 +227,8 @@ impl Socket { } #[inline] - pub fn can_read_vectored(&self) -> bool { - self.0.can_read_vectored() + pub fn is_read_vectored(&self) -> bool { + self.0.is_read_vectored() } fn recv_from_with_flags( @@ -269,8 +269,8 @@ impl Socket { } #[inline] - pub fn can_write_vectored(&self) -> bool { - self.0.can_write_vectored() + pub fn is_write_vectored(&self) -> bool { + self.0.is_write_vectored() } pub fn set_timeout(&self, dur: Option, kind: libc::c_int) -> io::Result<()> { diff --git a/src/libstd/sys/unix/pipe.rs b/src/libstd/sys/unix/pipe.rs index d8ac36df9ec..f2a2eabef91 100644 --- a/src/libstd/sys/unix/pipe.rs +++ b/src/libstd/sys/unix/pipe.rs @@ -65,8 +65,8 @@ impl AnonPipe { } #[inline] - pub fn can_read_vectored(&self) -> bool { - self.0.can_read_vectored() + pub fn is_read_vectored(&self) -> bool { + self.0.is_read_vectored() } pub fn write(&self, buf: &[u8]) -> io::Result { @@ -78,8 +78,8 @@ impl AnonPipe { } #[inline] - pub fn can_write_vectored(&self) -> bool { - self.0.can_write_vectored() + pub fn is_write_vectored(&self) -> bool { + self.0.is_write_vectored() } pub fn fd(&self) -> &FileDesc { diff --git a/src/libstd/sys/unix/stdio.rs b/src/libstd/sys/unix/stdio.rs index 4026dd4e497..f8353214cbc 100644 --- a/src/libstd/sys/unix/stdio.rs +++ b/src/libstd/sys/unix/stdio.rs @@ -22,7 +22,7 @@ impl io::Read for Stdin { } #[inline] - fn can_read_vectored(&self) -> bool { + fn is_read_vectored(&self) -> bool { true } } @@ -43,7 +43,7 @@ impl io::Write for Stdout { } #[inline] - fn can_write_vectored(&self) -> bool { + fn is_write_vectored(&self) -> bool { true } @@ -68,7 +68,7 @@ impl io::Write for Stderr { } #[inline] - fn can_write_vectored(&self) -> bool { + fn is_write_vectored(&self) -> bool { true } diff --git a/src/libstd/sys/vxworks/fd.rs b/src/libstd/sys/vxworks/fd.rs index 0593db65047..23e9dc428ce 100644 --- a/src/libstd/sys/vxworks/fd.rs +++ b/src/libstd/sys/vxworks/fd.rs @@ -55,7 +55,7 @@ impl FileDesc { } #[inline] - fn can_read_vectored(&self) -> bool { + fn is_read_vectored(&self) -> bool { true } @@ -105,7 +105,7 @@ impl FileDesc { } #[inline] - pub fn can_write_vectored(&self) -> bool { + pub fn is_write_vectored(&self) -> bool { true } diff --git a/src/libstd/sys/vxworks/fs.rs b/src/libstd/sys/vxworks/fs.rs index 449431f23d9..557e65ca01b 100644 --- a/src/libstd/sys/vxworks/fs.rs +++ b/src/libstd/sys/vxworks/fs.rs @@ -352,8 +352,8 @@ impl File { } #[inline] - pub fn can_read_vectored(&self) -> bool { - self.0.can_read_vectored() + pub fn is_read_vectored(&self) -> bool { + self.0.is_read_vectored() } pub fn read_at(&self, buf: &mut [u8], offset: u64) -> io::Result { @@ -369,8 +369,8 @@ impl File { } #[inline] - pub fn can_write_vectored(&self) -> bool { - self.0.can_write_vectored() + pub fn is_write_vectored(&self) -> bool { + self.0.is_write_vectored() } pub fn write_at(&self, buf: &[u8], offset: u64) -> io::Result { diff --git a/src/libstd/sys/vxworks/net.rs b/src/libstd/sys/vxworks/net.rs index 455bbf3683f..de0b15b43a2 100644 --- a/src/libstd/sys/vxworks/net.rs +++ b/src/libstd/sys/vxworks/net.rs @@ -164,8 +164,8 @@ impl Socket { } #[inline] - pub fn can_read_vectored(&self) -> bool { - self.0.can_read_vectored() + pub fn is_read_vectored(&self) -> bool { + self.0.is_read_vectored() } fn recv_from_with_flags( @@ -206,8 +206,8 @@ impl Socket { } #[inline] - pub fn can_write_vectored(&self) -> bool { - self.0.can_write_vectored() + pub fn is_write_vectored(&self) -> bool { + self.0.is_write_vectored() } pub fn set_timeout(&self, dur: Option, kind: libc::c_int) -> io::Result<()> { diff --git a/src/libstd/sys/vxworks/pipe.rs b/src/libstd/sys/vxworks/pipe.rs index eb99eba9888..a18376212af 100644 --- a/src/libstd/sys/vxworks/pipe.rs +++ b/src/libstd/sys/vxworks/pipe.rs @@ -30,8 +30,8 @@ impl AnonPipe { } #[inline] - pub fn can_read_vectored(&self) -> bool { - self.0.can_read_vectored() + pub fn is_read_vectored(&self) -> bool { + self.0.is_read_vectored() } pub fn write(&self, buf: &[u8]) -> io::Result { @@ -43,8 +43,8 @@ impl AnonPipe { } #[inline] - pub fn can_write_vectored(&self) -> bool { - self.0.can_write_vectored() + pub fn is_write_vectored(&self) -> bool { + self.0.is_write_vectored() } pub fn fd(&self) -> &FileDesc { diff --git a/src/libstd/sys/wasi/fs.rs b/src/libstd/sys/wasi/fs.rs index eaf8d3e0ae8..793daea43c2 100644 --- a/src/libstd/sys/wasi/fs.rs +++ b/src/libstd/sys/wasi/fs.rs @@ -400,7 +400,7 @@ impl File { } #[inline] - pub fn can_read_vectored(&self) -> bool { + pub fn is_read_vectored(&self) -> bool { true } @@ -413,7 +413,7 @@ impl File { } #[inline] - pub fn can_write_vectored(&self) -> bool { + pub fn is_write_vectored(&self) -> bool { true } diff --git a/src/libstd/sys/wasi/net.rs b/src/libstd/sys/wasi/net.rs index ac4f55f5f86..30b6b984f30 100644 --- a/src/libstd/sys/wasi/net.rs +++ b/src/libstd/sys/wasi/net.rs @@ -48,7 +48,7 @@ impl TcpStream { unsupported() } - pub fn can_read_vectored(&self) -> bool { + pub fn is_read_vectored(&self) -> bool { unsupported() } @@ -60,7 +60,7 @@ impl TcpStream { unsupported() } - pub fn can_write_vectored(&self) -> bool { + pub fn is_write_vectored(&self) -> bool { unsupported() } diff --git a/src/libstd/sys/wasi/pipe.rs b/src/libstd/sys/wasi/pipe.rs index eed8d1fdd56..10d0925823e 100644 --- a/src/libstd/sys/wasi/pipe.rs +++ b/src/libstd/sys/wasi/pipe.rs @@ -12,7 +12,7 @@ impl AnonPipe { match self.0 {} } - pub fn can_read_vectored(&self) -> bool { + pub fn is_read_vectored(&self) -> bool { match self.0 {} } @@ -24,7 +24,7 @@ impl AnonPipe { match self.0 {} } - pub fn can_write_vectored(&self) -> bool { + pub fn is_write_vectored(&self) -> bool { match self.0 {} } diff --git a/src/libstd/sys/wasi/stdio.rs b/src/libstd/sys/wasi/stdio.rs index 01b041141a7..9f9e35566ec 100644 --- a/src/libstd/sys/wasi/stdio.rs +++ b/src/libstd/sys/wasi/stdio.rs @@ -20,7 +20,7 @@ impl Stdin { } #[inline] - pub fn can_read_vectored(&self) -> bool { + pub fn is_read_vectored(&self) -> bool { true } @@ -43,7 +43,7 @@ impl Stdout { } #[inline] - pub fn can_write_vectored(&self) -> bool { + pub fn is_write_vectored(&self) -> bool { true } @@ -70,7 +70,7 @@ impl Stderr { } #[inline] - pub fn can_write_vectored(&self) -> bool { + pub fn is_write_vectored(&self) -> bool { true } diff --git a/src/libstd/sys/wasm/fs.rs b/src/libstd/sys/wasm/fs.rs index e34483447e9..ecb5b51cccd 100644 --- a/src/libstd/sys/wasm/fs.rs +++ b/src/libstd/sys/wasm/fs.rs @@ -202,7 +202,7 @@ impl File { match self.0 {} } - pub fn can_read_vectored(&self) -> bool { + pub fn is_read_vectored(&self) -> bool { match self.0 {} } @@ -214,7 +214,7 @@ impl File { match self.0 {} } - pub fn can_write_vectored(&self) -> bool { + pub fn is_write_vectored(&self) -> bool { match self.0 {} } diff --git a/src/libstd/sys/wasm/net.rs b/src/libstd/sys/wasm/net.rs index b9c54f4612e..5c9f1098f9b 100644 --- a/src/libstd/sys/wasm/net.rs +++ b/src/libstd/sys/wasm/net.rs @@ -44,7 +44,7 @@ impl TcpStream { match self.0 {} } - pub fn can_read_vectored(&self) -> bool { + pub fn is_read_vectored(&self) -> bool { match self.0 {} } @@ -56,7 +56,7 @@ impl TcpStream { match self.0 {} } - pub fn can_write_vectored(&self) -> bool { + pub fn is_write_vectored(&self) -> bool { match self.0 {} } diff --git a/src/libstd/sys/windows/fs.rs b/src/libstd/sys/windows/fs.rs index 70134439290..cdbfac267b9 100644 --- a/src/libstd/sys/windows/fs.rs +++ b/src/libstd/sys/windows/fs.rs @@ -410,8 +410,8 @@ impl File { } #[inline] - pub fn can_read_vectored(&self) -> bool { - self.handle.can_read_vectored() + pub fn is_read_vectored(&self) -> bool { + self.handle.is_read_vectored() } pub fn read_at(&self, buf: &mut [u8], offset: u64) -> io::Result { @@ -427,8 +427,8 @@ impl File { } #[inline] - pub fn can_write_vectored(&self) -> bool { - self.handle.can_write_vectored() + pub fn is_write_vectored(&self) -> bool { + self.handle.is_write_vectored() } pub fn write_at(&self, buf: &[u8], offset: u64) -> io::Result { diff --git a/src/libstd/sys/windows/handle.rs b/src/libstd/sys/windows/handle.rs index 15a8af71d7f..2131cfc2c94 100644 --- a/src/libstd/sys/windows/handle.rs +++ b/src/libstd/sys/windows/handle.rs @@ -93,7 +93,7 @@ impl RawHandle { } #[inline] - pub fn can_read_vectored(&self) -> bool { + pub fn is_read_vectored(&self) -> bool { false } @@ -177,7 +177,7 @@ impl RawHandle { } #[inline] - pub fn can_write_vectored(&self) -> bool { + pub fn is_write_vectored(&self) -> bool { false } diff --git a/src/libstd/sys/windows/net.rs b/src/libstd/sys/windows/net.rs index 1b4411e38aa..a15ded92f08 100644 --- a/src/libstd/sys/windows/net.rs +++ b/src/libstd/sys/windows/net.rs @@ -267,7 +267,7 @@ impl Socket { } #[inline] - pub fn can_read_vectored(&self) -> bool { + pub fn is_read_vectored(&self) -> bool { true } @@ -330,7 +330,7 @@ impl Socket { } #[inline] - pub fn can_write_vectored(&self) -> bool { + pub fn is_write_vectored(&self) -> bool { true } diff --git a/src/libstd/sys/windows/pipe.rs b/src/libstd/sys/windows/pipe.rs index f6358cf9efd..104a8db4659 100644 --- a/src/libstd/sys/windows/pipe.rs +++ b/src/libstd/sys/windows/pipe.rs @@ -183,8 +183,8 @@ impl AnonPipe { } #[inline] - pub fn can_read_vectored(&self) -> bool { - self.inner.can_read_vectored() + pub fn is_read_vectored(&self) -> bool { + self.inner.is_read_vectored() } pub fn write(&self, buf: &[u8]) -> io::Result { @@ -196,8 +196,8 @@ impl AnonPipe { } #[inline] - pub fn can_write_vectored(&self) -> bool { - self.inner.can_write_vectored() + pub fn is_write_vectored(&self) -> bool { + self.inner.is_write_vectored() } } diff --git a/src/libstd/sys_common/net.rs b/src/libstd/sys_common/net.rs index bfa93cb4e2c..a9b6079de75 100644 --- a/src/libstd/sys_common/net.rs +++ b/src/libstd/sys_common/net.rs @@ -266,8 +266,8 @@ impl TcpStream { } #[inline] - pub fn can_read_vectored(&self) -> bool { - self.inner.can_read_vectored() + pub fn is_read_vectored(&self) -> bool { + self.inner.is_read_vectored() } pub fn write(&self, buf: &[u8]) -> io::Result { @@ -283,8 +283,8 @@ impl TcpStream { } #[inline] - pub fn can_write_vectored(&self) -> bool { - self.inner.can_write_vectored() + pub fn is_write_vectored(&self) -> bool { + self.inner.is_write_vectored() } pub fn peer_addr(&self) -> io::Result { From 4bad27a467300ec6cb86b34218c17f2fc05e3624 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Wed, 11 Mar 2020 18:32:18 -0700 Subject: [PATCH 04/13] Fix stragglers --- src/libstd/sys/cloudabi/shims/fs.rs | 2 +- src/libstd/sys/cloudabi/shims/net.rs | 2 +- src/libstd/sys/cloudabi/shims/pipe.rs | 2 +- src/libstd/sys/sgx/net.rs | 2 +- src/libstd/sys/unix/ext/net.rs | 10 +++++----- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/libstd/sys/cloudabi/shims/fs.rs b/src/libstd/sys/cloudabi/shims/fs.rs index 9323d7d89cf..ecb5b51cccd 100644 --- a/src/libstd/sys/cloudabi/shims/fs.rs +++ b/src/libstd/sys/cloudabi/shims/fs.rs @@ -202,7 +202,7 @@ impl File { match self.0 {} } - pub fn can_read_vectored(&self) -> bool { + pub fn is_read_vectored(&self) -> bool { match self.0 {} } diff --git a/src/libstd/sys/cloudabi/shims/net.rs b/src/libstd/sys/cloudabi/shims/net.rs index 9d40fa1a8ea..375aaab405d 100644 --- a/src/libstd/sys/cloudabi/shims/net.rs +++ b/src/libstd/sys/cloudabi/shims/net.rs @@ -47,7 +47,7 @@ impl TcpStream { match self.0 {} } - pub fn can_read_vectored(&self) -> bool { + pub fn is_read_vectored(&self) -> bool { match self.0 {} } diff --git a/src/libstd/sys/cloudabi/shims/pipe.rs b/src/libstd/sys/cloudabi/shims/pipe.rs index b2b68a0f0ca..10d0925823e 100644 --- a/src/libstd/sys/cloudabi/shims/pipe.rs +++ b/src/libstd/sys/cloudabi/shims/pipe.rs @@ -12,7 +12,7 @@ impl AnonPipe { match self.0 {} } - pub fn can_read_vectored(&self) -> bool { + pub fn is_read_vectored(&self) -> bool { match self.0 {} } diff --git a/src/libstd/sys/sgx/net.rs b/src/libstd/sys/sgx/net.rs index 75a48e98e73..666a157b09c 100644 --- a/src/libstd/sys/sgx/net.rs +++ b/src/libstd/sys/sgx/net.rs @@ -151,7 +151,7 @@ impl TcpStream { #[inline] pub fn is_read_vectored(&self) -> bool { - self.inner.inner.can_read_vectored() + self.inner.inner.is_read_vectored() } pub fn write(&self, buf: &[u8]) -> io::Result { diff --git a/src/libstd/sys/unix/ext/net.rs b/src/libstd/sys/unix/ext/net.rs index ca1a2b5b3fb..bfdc39ada75 100644 --- a/src/libstd/sys/unix/ext/net.rs +++ b/src/libstd/sys/unix/ext/net.rs @@ -614,8 +614,8 @@ impl io::Read for UnixStream { } #[inline] - fn can_read_vectored(&self) -> bool { - io::Read::can_read_vectored(&&*self) + fn is_read_vectored(&self) -> bool { + io::Read::is_read_vectored(&&*self) } #[inline] @@ -635,8 +635,8 @@ impl<'a> io::Read for &'a UnixStream { } #[inline] - fn can_read_vectored(&self) -> bool { - self.0.can_read_vectored() + fn is_read_vectored(&self) -> bool { + self.0.is_read_vectored() } #[inline] @@ -677,7 +677,7 @@ impl<'a> io::Write for &'a UnixStream { #[inline] fn is_write_vectored(&self) -> bool { - self.0.can_write_vectored() + self.0.is_write_vectored() } fn flush(&mut self) -> io::Result<()> { From 3a6fa99f9eec7bb3293a75eb0dd0d26b47323ed5 Mon Sep 17 00:00:00 2001 From: Ujjwal Sharma Date: Sun, 26 Apr 2020 17:09:15 +0530 Subject: [PATCH 05/13] linkchecker: fix typo in main.rs --- src/tools/linkchecker/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/linkchecker/main.rs b/src/tools/linkchecker/main.rs index fb4611ed1ca..570ffd5d306 100644 --- a/src/tools/linkchecker/main.rs +++ b/src/tools/linkchecker/main.rs @@ -114,7 +114,7 @@ fn walk(cache: &mut Cache, root: &Path, dir: &Path, errors: &mut bool) { } fn check(cache: &mut Cache, root: &Path, file: &Path, errors: &mut bool) -> Option { - // Ignore none HTML files. + // Ignore non-HTML files. if file.extension().and_then(|s| s.to_str()) != Some("html") { return None; } From 5d8fe1c4e6b214916de690ee25c17f862e166a28 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Sun, 26 Apr 2020 04:48:51 -0700 Subject: [PATCH 06/13] Suppress file length check temporarily Will clean up in a separate PR --- src/libstd/io/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index c9db48db9bd..9cfb1728c04 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -256,6 +256,7 @@ //! [`Read::read`]: trait.Read.html#tymethod.read //! [`Result`]: ../result/enum.Result.html //! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap +// ignore-tidy-filelength #![stable(feature = "rust1", since = "1.0.0")] From efb6d6c027da344753f343fffc5012f29bfecb0e Mon Sep 17 00:00:00 2001 From: LeSeulArtichaut Date: Sun, 26 Apr 2020 22:32:14 +0200 Subject: [PATCH 07/13] Fix broken link in `QPath` documentation --- src/librustc_hir/hir.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_hir/hir.rs b/src/librustc_hir/hir.rs index d342f8b0ad2..654cd4980a4 100644 --- a/src/librustc_hir/hir.rs +++ b/src/librustc_hir/hir.rs @@ -1601,7 +1601,7 @@ pub enum ExprKind<'hir> { /// /// To resolve the path to a `DefId`, call [`qpath_res`]. /// -/// [`qpath_res`]: ../ty/struct.TypeckTables.html#method.qpath_res +/// [`qpath_res`]: ../rustc_middle/ty/struct.TypeckTables.html#method.qpath_res #[derive(RustcEncodable, RustcDecodable, Debug, HashStable_Generic)] pub enum QPath<'hir> { /// Path to a definition, optionally "fully-qualified" with a `Self` From feeb75e2639be481ef4428320b234d1e5b99e42d Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sat, 25 Apr 2020 21:45:21 +0300 Subject: [PATCH 08/13] rustc_target: Stop using "string typing" for TLS models Introduce `enum TlsModel` instead. --- src/librustc_codegen_llvm/back/write.rs | 7 --- src/librustc_codegen_llvm/context.rs | 23 +++----- src/librustc_codegen_llvm/lib.rs | 2 +- src/librustc_interface/tests.rs | 5 +- src/librustc_session/config.rs | 8 ++- src/librustc_session/options.rs | 15 +++++- src/librustc_session/session.rs | 6 ++- src/librustc_target/spec/cloudabi_base.rs | 4 +- src/librustc_target/spec/hermit_base.rs | 5 +- .../spec/hermit_kernel_base.rs | 5 +- src/librustc_target/spec/mod.rs | 54 +++++++++++++++++-- src/librustc_target/spec/wasm32_base.rs | 4 +- 12 files changed, 94 insertions(+), 44 deletions(-) diff --git a/src/librustc_codegen_llvm/back/write.rs b/src/librustc_codegen_llvm/back/write.rs index bf79c5b593e..3ec7ef831b5 100644 --- a/src/librustc_codegen_llvm/back/write.rs +++ b/src/librustc_codegen_llvm/back/write.rs @@ -43,13 +43,6 @@ pub const CODE_GEN_MODEL_ARGS: &[(&str, llvm::CodeModel)] = &[ ("large", llvm::CodeModel::Large), ]; -pub const TLS_MODEL_ARGS: [(&str, llvm::ThreadLocalMode); 4] = [ - ("global-dynamic", llvm::ThreadLocalMode::GeneralDynamic), - ("local-dynamic", llvm::ThreadLocalMode::LocalDynamic), - ("initial-exec", llvm::ThreadLocalMode::InitialExec), - ("local-exec", llvm::ThreadLocalMode::LocalExec), -]; - pub fn llvm_err(handler: &rustc_errors::Handler, msg: &str) -> FatalError { match llvm::last_error() { Some(err) => handler.fatal(&format!("{}: {}", msg, err)), diff --git a/src/librustc_codegen_llvm/context.rs b/src/librustc_codegen_llvm/context.rs index df442609052..f868385ee86 100644 --- a/src/librustc_codegen_llvm/context.rs +++ b/src/librustc_codegen_llvm/context.rs @@ -21,7 +21,7 @@ use rustc_session::Session; use rustc_span::source_map::{Span, DUMMY_SP}; use rustc_span::symbol::Symbol; use rustc_target::abi::{HasDataLayout, LayoutOf, PointeeInfo, Size, TargetDataLayout, VariantIdx}; -use rustc_target::spec::{HasTargetSpec, RelocModel, Target}; +use rustc_target::spec::{HasTargetSpec, RelocModel, Target, TlsModel}; use std::cell::{Cell, RefCell}; use std::ffi::CStr; @@ -87,19 +87,12 @@ pub struct CodegenCx<'ll, 'tcx> { local_gen_sym_counter: Cell, } -fn get_tls_model(sess: &Session) -> llvm::ThreadLocalMode { - let tls_model_arg = match sess.opts.debugging_opts.tls_model { - Some(ref s) => &s[..], - None => &sess.target.target.options.tls_model[..], - }; - - match crate::back::write::TLS_MODEL_ARGS.iter().find(|&&arg| arg.0 == tls_model_arg) { - Some(x) => x.1, - _ => { - sess.err(&format!("{:?} is not a valid TLS model", tls_model_arg)); - sess.abort_if_errors(); - bug!(); - } +fn to_llvm_tls_model(tls_model: TlsModel) -> llvm::ThreadLocalMode { + match tls_model { + TlsModel::GeneralDynamic => llvm::ThreadLocalMode::GeneralDynamic, + TlsModel::LocalDynamic => llvm::ThreadLocalMode::LocalDynamic, + TlsModel::InitialExec => llvm::ThreadLocalMode::InitialExec, + TlsModel::LocalExec => llvm::ThreadLocalMode::LocalExec, } } @@ -267,7 +260,7 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> { let check_overflow = tcx.sess.overflow_checks(); - let tls_model = get_tls_model(&tcx.sess); + let tls_model = to_llvm_tls_model(tcx.sess.tls_model()); let (llcx, llmod) = (&*llvm_module.llcx, llvm_module.llmod()); diff --git a/src/librustc_codegen_llvm/lib.rs b/src/librustc_codegen_llvm/lib.rs index 330d6ea75d2..42302a56b41 100644 --- a/src/librustc_codegen_llvm/lib.rs +++ b/src/librustc_codegen_llvm/lib.rs @@ -216,7 +216,7 @@ impl CodegenBackend for LlvmCodegenBackend { } PrintRequest::TlsModels => { println!("Available TLS models:"); - for &(name, _) in back::write::TLS_MODEL_ARGS.iter() { + for name in &["global-dynamic", "local-dynamic", "initial-exec", "local-exec"] { println!(" {}", name); } println!(); diff --git a/src/librustc_interface/tests.rs b/src/librustc_interface/tests.rs index f0e7581b760..cee2e5b5bec 100644 --- a/src/librustc_interface/tests.rs +++ b/src/librustc_interface/tests.rs @@ -14,7 +14,8 @@ use rustc_session::{build_session, Session}; use rustc_span::edition::{Edition, DEFAULT_EDITION}; use rustc_span::symbol::sym; use rustc_span::SourceFileHashAlgorithm; -use rustc_target::spec::{LinkerFlavor, MergeFunctions, PanicStrategy, RelocModel, RelroLevel}; +use rustc_target::spec::{LinkerFlavor, MergeFunctions, PanicStrategy}; +use rustc_target::spec::{RelocModel, RelroLevel, TlsModel}; use std::collections::{BTreeMap, BTreeSet}; use std::iter::FromIterator; use std::path::PathBuf; @@ -567,7 +568,7 @@ fn test_debugging_options_tracking_hash() { tracked!(symbol_mangling_version, SymbolManglingVersion::V0); tracked!(teach, true); tracked!(thinlto, Some(true)); - tracked!(tls_model, Some(String::from("tls model"))); + tracked!(tls_model, Some(TlsModel::GeneralDynamic)); tracked!(treat_err_as_bug, Some(1)); tracked!(unleash_the_miri_inside_of_you, true); tracked!(verify_llvm_ir, true); diff --git a/src/librustc_session/config.rs b/src/librustc_session/config.rs index 1ab02f84c11..0dfc391d9cd 100644 --- a/src/librustc_session/config.rs +++ b/src/librustc_session/config.rs @@ -1315,10 +1315,6 @@ fn collect_print_requests( prints.push(PrintRequest::CodeModels); cg.code_model = None; } - if dopts.tls_model.as_ref().map_or(false, |s| s == "help") { - prints.push(PrintRequest::TlsModels); - dopts.tls_model = None; - } prints.extend(matches.opt_strs("print").into_iter().map(|s| match &*s { "crate-name" => PrintRequest::CrateName, @@ -2001,7 +1997,8 @@ crate mod dep_tracking { use crate::utils::NativeLibraryKind; use rustc_feature::UnstableFeatures; use rustc_span::edition::Edition; - use rustc_target::spec::{MergeFunctions, PanicStrategy, RelocModel, RelroLevel, TargetTriple}; + use rustc_target::spec::{MergeFunctions, PanicStrategy, RelocModel}; + use rustc_target::spec::{RelroLevel, TargetTriple, TlsModel}; use std::collections::hash_map::DefaultHasher; use std::collections::BTreeMap; use std::hash::Hash; @@ -2050,6 +2047,7 @@ crate mod dep_tracking { impl_dep_tracking_hash_via_hash!(Option>); impl_dep_tracking_hash_via_hash!(Option); impl_dep_tracking_hash_via_hash!(Option); + impl_dep_tracking_hash_via_hash!(Option); impl_dep_tracking_hash_via_hash!(Option); impl_dep_tracking_hash_via_hash!(Option); impl_dep_tracking_hash_via_hash!(Option); diff --git a/src/librustc_session/options.rs b/src/librustc_session/options.rs index 2279c16748c..5b983d1105d 100644 --- a/src/librustc_session/options.rs +++ b/src/librustc_session/options.rs @@ -6,7 +6,8 @@ use crate::search_paths::SearchPath; use crate::utils::NativeLibraryKind; use rustc_target::spec::TargetTriple; -use rustc_target::spec::{LinkerFlavor, MergeFunctions, PanicStrategy, RelocModel, RelroLevel}; +use rustc_target::spec::{LinkerFlavor, MergeFunctions, PanicStrategy}; +use rustc_target::spec::{RelocModel, RelroLevel, TlsModel}; use rustc_feature::UnstableFeatures; use rustc_span::edition::Edition; @@ -267,6 +268,8 @@ macro_rules! options { pub const parse_src_file_hash: &str = "either `md5` or `sha1`"; pub const parse_relocation_model: &str = "one of supported relocation models (`rustc --print relocation-models`)"; + pub const parse_tls_model: &str = + "one of supported TLS models (`rustc --print tls-models`)"; } #[allow(dead_code)] @@ -606,6 +609,14 @@ macro_rules! options { true } + fn parse_tls_model(slot: &mut Option, v: Option<&str>) -> bool { + match v.and_then(|s| TlsModel::from_str(s).ok()) { + Some(tls_model) => *slot = Some(tls_model), + _ => return false, + } + true + } + fn parse_symbol_mangling_version( slot: &mut SymbolManglingVersion, v: Option<&str>, @@ -977,7 +988,7 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, "measure time of each LLVM pass (default: no)"), time_passes: bool = (false, parse_bool, [UNTRACKED], "measure time of each rustc pass (default: no)"), - tls_model: Option = (None, parse_opt_string, [TRACKED], + tls_model: Option = (None, parse_tls_model, [TRACKED], "choose the TLS model to use (`rustc --print tls-models` for details)"), trace_macros: bool = (false, parse_bool, [UNTRACKED], "for every macro invocation, print its name and arguments (default: no)"), diff --git a/src/librustc_session/session.rs b/src/librustc_session/session.rs index 226d9392095..42f9a8d6b05 100644 --- a/src/librustc_session/session.rs +++ b/src/librustc_session/session.rs @@ -22,7 +22,7 @@ use rustc_errors::{Applicability, DiagnosticBuilder, DiagnosticId, ErrorReported use rustc_span::edition::Edition; use rustc_span::source_map::{self, FileLoader, MultiSpan, RealFileLoader, SourceMap, Span}; use rustc_span::SourceFileHashAlgorithm; -use rustc_target::spec::{PanicStrategy, RelocModel, RelroLevel, Target, TargetTriple}; +use rustc_target::spec::{PanicStrategy, RelocModel, RelroLevel, Target, TargetTriple, TlsModel}; use std::cell::{self, RefCell}; use std::env; @@ -588,6 +588,10 @@ impl Session { self.opts.cg.relocation_model.unwrap_or(self.target.target.options.relocation_model) } + pub fn tls_model(&self) -> TlsModel { + self.opts.debugging_opts.tls_model.unwrap_or(self.target.target.options.tls_model) + } + pub fn must_not_eliminate_frame_pointers(&self) -> bool { // "mcount" function relies on stack pointer. // See . diff --git a/src/librustc_target/spec/cloudabi_base.rs b/src/librustc_target/spec/cloudabi_base.rs index 53af9dcc186..3659c9ecdfc 100644 --- a/src/librustc_target/spec/cloudabi_base.rs +++ b/src/librustc_target/spec/cloudabi_base.rs @@ -1,4 +1,4 @@ -use crate::spec::{LinkArgs, LinkerFlavor, RelroLevel, TargetOptions}; +use crate::spec::{LinkArgs, LinkerFlavor, RelroLevel, TargetOptions, TlsModel}; pub fn opts() -> TargetOptions { let mut args = LinkArgs::new(); @@ -29,7 +29,7 @@ pub fn opts() -> TargetOptions { // (Global Offset Table) to obtain the effective address of a // thread-local variable. Using a GOT is useful only when doing // dynamic linking. - tls_model: "local-exec".to_string(), + tls_model: TlsModel::LocalExec, relro_level: RelroLevel::Full, ..Default::default() } diff --git a/src/librustc_target/spec/hermit_base.rs b/src/librustc_target/spec/hermit_base.rs index cb12055290e..18fb2aa3d56 100644 --- a/src/librustc_target/spec/hermit_base.rs +++ b/src/librustc_target/spec/hermit_base.rs @@ -1,4 +1,5 @@ -use crate::spec::{LinkArgs, LinkerFlavor, LldFlavor, PanicStrategy, RelocModel, TargetOptions}; +use crate::spec::{LinkArgs, LinkerFlavor, LldFlavor, PanicStrategy}; +use crate::spec::{RelocModel, TargetOptions, TlsModel}; pub fn opts() -> TargetOptions { let mut pre_link_args = LinkArgs::new(); @@ -17,7 +18,7 @@ pub fn opts() -> TargetOptions { position_independent_executables: true, relocation_model: RelocModel::Static, target_family: None, - tls_model: "initial-exec".to_string(), + tls_model: TlsModel::InitialExec, ..Default::default() } } diff --git a/src/librustc_target/spec/hermit_kernel_base.rs b/src/librustc_target/spec/hermit_kernel_base.rs index 11599fda409..7f2dada714d 100644 --- a/src/librustc_target/spec/hermit_kernel_base.rs +++ b/src/librustc_target/spec/hermit_kernel_base.rs @@ -1,4 +1,5 @@ -use crate::spec::{LinkArgs, LinkerFlavor, LldFlavor, PanicStrategy, RelocModel, TargetOptions}; +use crate::spec::{LinkArgs, LinkerFlavor, LldFlavor, PanicStrategy}; +use crate::spec::{RelocModel, TargetOptions, TlsModel}; pub fn opts() -> TargetOptions { let mut pre_link_args = LinkArgs::new(); @@ -18,7 +19,7 @@ pub fn opts() -> TargetOptions { position_independent_executables: true, relocation_model: RelocModel::Static, target_family: None, - tls_model: "initial-exec".to_string(), + tls_model: TlsModel::InitialExec, ..Default::default() } } diff --git a/src/librustc_target/spec/mod.rs b/src/librustc_target/spec/mod.rs index 77fc78e8148..e853c07632f 100644 --- a/src/librustc_target/spec/mod.rs +++ b/src/librustc_target/spec/mod.rs @@ -305,6 +305,42 @@ impl ToJson for RelocModel { } } +#[derive(Clone, Copy, PartialEq, Hash, Debug)] +pub enum TlsModel { + GeneralDynamic, + LocalDynamic, + InitialExec, + LocalExec, +} + +impl FromStr for TlsModel { + type Err = (); + + fn from_str(s: &str) -> Result { + Ok(match s { + // Note the difference "general" vs "global" difference. The model name is "general", + // but the user-facing option name is "global" for consistency with other compilers. + "global-dynamic" => TlsModel::GeneralDynamic, + "local-dynamic" => TlsModel::LocalDynamic, + "initial-exec" => TlsModel::InitialExec, + "local-exec" => TlsModel::LocalExec, + _ => return Err(()), + }) + } +} + +impl ToJson for TlsModel { + fn to_json(&self) -> Json { + match *self { + TlsModel::GeneralDynamic => "global-dynamic", + TlsModel::LocalDynamic => "local-dynamic", + TlsModel::InitialExec => "initial-exec", + TlsModel::LocalExec => "local-exec", + } + .to_json() + } +} + pub enum LoadTargetError { BuiltinTargetNotFound(String), Other(String), @@ -660,7 +696,7 @@ pub struct TargetOptions { pub code_model: Option, /// TLS model to use. Options are "global-dynamic" (default), "local-dynamic", "initial-exec" /// and "local-exec". This is similar to the -ftls-model option in GCC/Clang. - pub tls_model: String, + pub tls_model: TlsModel, /// Do not emit code that uses the "red zone", if the ABI has one. Defaults to false. pub disable_redzone: bool, /// Eliminate frame pointers from stack frames if possible. Defaults to true. @@ -863,7 +899,7 @@ impl Default for TargetOptions { executables: false, relocation_model: RelocModel::Pic, code_model: None, - tls_model: "global-dynamic".to_string(), + tls_model: TlsModel::GeneralDynamic, disable_redzone: false, eliminate_frame_pointer: true, function_sections: true, @@ -1060,6 +1096,18 @@ impl Target { Some(Ok(())) })).unwrap_or(Ok(())) } ); + ($key_name:ident, TlsModel) => ( { + let name = (stringify!($key_name)).replace("_", "-"); + obj.find(&name[..]).and_then(|o| o.as_string().and_then(|s| { + match s.parse::() { + Ok(tls_model) => base.options.$key_name = tls_model, + _ => return Some(Err(format!("'{}' is not a valid TLS model. \ + Run `rustc --print tls-models` to \ + see the list of supported values.", s))), + } + Some(Ok(())) + })).unwrap_or(Ok(())) + } ); ($key_name:ident, PanicStrategy) => ( { let name = (stringify!($key_name)).replace("_", "-"); obj.find(&name[..]).and_then(|o| o.as_string().and_then(|s| { @@ -1200,7 +1248,7 @@ impl Target { key!(executables, bool); key!(relocation_model, RelocModel)?; key!(code_model, optional); - key!(tls_model); + key!(tls_model, TlsModel)?; key!(disable_redzone, bool); key!(eliminate_frame_pointer, bool); key!(function_sections, bool); diff --git a/src/librustc_target/spec/wasm32_base.rs b/src/librustc_target/spec/wasm32_base.rs index 08bade2abf4..bb19b9d00e8 100644 --- a/src/librustc_target/spec/wasm32_base.rs +++ b/src/librustc_target/spec/wasm32_base.rs @@ -1,4 +1,4 @@ -use super::{LinkerFlavor, LldFlavor, PanicStrategy, RelocModel, TargetOptions}; +use super::{LinkerFlavor, LldFlavor, PanicStrategy, RelocModel, TargetOptions, TlsModel}; use std::collections::BTreeMap; pub fn options() -> TargetOptions { @@ -138,7 +138,7 @@ pub fn options() -> TargetOptions { // `has_elf_tls`) and we need to get it to work by specifying // `local-exec` as that's all that's implemented in LLVM today for wasm. has_elf_tls: true, - tls_model: "local-exec".to_string(), + tls_model: TlsModel::LocalExec, // gdb scripts don't work on wasm blobs emit_debug_gdb_scripts: false, From 45dc4350c3119db37945fa72e8cae174949e0ee0 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sun, 26 Apr 2020 11:52:21 +0300 Subject: [PATCH 09/13] unstable-book: Document `-Z tls-model` --- .../src/compiler-flags/tls-model.md | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/doc/unstable-book/src/compiler-flags/tls-model.md diff --git a/src/doc/unstable-book/src/compiler-flags/tls-model.md b/src/doc/unstable-book/src/compiler-flags/tls-model.md new file mode 100644 index 00000000000..0aefaa7fb01 --- /dev/null +++ b/src/doc/unstable-book/src/compiler-flags/tls-model.md @@ -0,0 +1,25 @@ +# `tls_model` + +The tracking issue for this feature is: None. + +------------------------ + +Option `-Z tls-model` controls [TLS model](https://www.akkadia.org/drepper/tls.pdf) used to +generate code for accessing `#[thread_local]` `static` items. + +Supported values for this option are: + +- `global-dynamic` - General Dynamic TLS Model (alternatively called Global Dynamic) is the most +general option usable in all circumstances, even if the TLS data is defined in a shared library +loaded at runtime and is accessed from code outside of that library. +This is the default for most targets. +- `local-dynamic` - model usable if the TLS data is only accessed from the shared library or +executable it is defined in. The TLS data may be in a library loaded after startup (via `dlopen`). +- `initial-exec` - model usable if the TLS data is defined in the executable or in a shared library +loaded at program startup. +The TLS data must not be in a library loaded after startup (via `dlopen`). +- `local-exec` - model usable only if the TLS data is defined directly in the executable, +but not in a shared library, and is accessed only from that executable. + +`rustc` and LLVM may use a more optimized model than specified if they know that we are producing +and executable rather than a library, or that the `static` item is private enough. From b00afb5782c3c9a710f64e5c14f854946847ca65 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Sun, 26 Apr 2020 16:34:14 -0700 Subject: [PATCH 10/13] fix wasm build --- src/libstd/sys/wasm/pipe.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/libstd/sys/wasm/pipe.rs b/src/libstd/sys/wasm/pipe.rs index fb14dc59101..10d0925823e 100644 --- a/src/libstd/sys/wasm/pipe.rs +++ b/src/libstd/sys/wasm/pipe.rs @@ -12,6 +12,10 @@ impl AnonPipe { match self.0 {} } + pub fn is_read_vectored(&self) -> bool { + match self.0 {} + } + pub fn write(&self, _buf: &[u8]) -> io::Result { match self.0 {} } @@ -20,6 +24,10 @@ impl AnonPipe { match self.0 {} } + pub fn is_write_vectored(&self) -> bool { + match self.0 {} + } + pub fn diverge(&self) -> ! { match self.0 {} } From 116dca5d85b5f3655a804560fa665233e8373e45 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 27 Apr 2020 13:36:45 +0200 Subject: [PATCH 11/13] No need to whitelist E0750 anymore --- src/tools/tidy/src/error_codes_check.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/tidy/src/error_codes_check.rs b/src/tools/tidy/src/error_codes_check.rs index 243d41598f8..f7fd0c670d7 100644 --- a/src/tools/tidy/src/error_codes_check.rs +++ b/src/tools/tidy/src/error_codes_check.rs @@ -17,7 +17,7 @@ const WHITELIST: &[&str] = &[ // Some error codes don't have any tests apparently... const IGNORE_EXPLANATION_CHECK: &[&str] = - &["E0570", "E0601", "E0602", "E0639", "E0729", "E0749", "E0750", "E0751"]; + &["E0570", "E0601", "E0602", "E0639", "E0729", "E0749", "E0750"]; fn check_error_code_explanation( f: &str, From 3bce639fc087216caf3e0f0a23bc00d18a235887 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 27 Apr 2020 13:08:02 +0200 Subject: [PATCH 12/13] make recursive-zst test unleashed --- ...rr => recursive-zst-static.default.stderr} | 6 +++--- src/test/ui/consts/recursive-zst-static.rs | 3 +++ .../recursive-zst-static.unleash.stderr | 21 +++++++++++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) rename src/test/ui/consts/{recursive-zst-static.stderr => recursive-zst-static.default.stderr} (81%) create mode 100644 src/test/ui/consts/recursive-zst-static.unleash.stderr diff --git a/src/test/ui/consts/recursive-zst-static.stderr b/src/test/ui/consts/recursive-zst-static.default.stderr similarity index 81% rename from src/test/ui/consts/recursive-zst-static.stderr rename to src/test/ui/consts/recursive-zst-static.default.stderr index e21dcf691ab..d424b22f000 100644 --- a/src/test/ui/consts/recursive-zst-static.stderr +++ b/src/test/ui/consts/recursive-zst-static.default.stderr @@ -1,17 +1,17 @@ error[E0391]: cycle detected when const-evaluating `FOO` - --> $DIR/recursive-zst-static.rs:7:18 + --> $DIR/recursive-zst-static.rs:10:18 | LL | static FOO: () = FOO; | ^^^ | note: ...which requires const-evaluating `FOO`... - --> $DIR/recursive-zst-static.rs:7:1 + --> $DIR/recursive-zst-static.rs:10:1 | LL | static FOO: () = FOO; | ^^^^^^^^^^^^^^^^^^^^^ = note: ...which again requires const-evaluating `FOO`, completing the cycle note: cycle used when const-evaluating + checking `FOO` - --> $DIR/recursive-zst-static.rs:7:1 + --> $DIR/recursive-zst-static.rs:10:1 | LL | static FOO: () = FOO; | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/consts/recursive-zst-static.rs b/src/test/ui/consts/recursive-zst-static.rs index 768df58e1e3..29a467c006a 100644 --- a/src/test/ui/consts/recursive-zst-static.rs +++ b/src/test/ui/consts/recursive-zst-static.rs @@ -1,3 +1,6 @@ +// revisions: default unleash +//[unleash]compile-flags: -Zunleash-the-miri-inside-of-you + // This test ensures that we do not allow ZST statics to initialize themselves without ever // actually creating a value of that type. This is important, as the ZST may have private fields // that users can reasonably expect to only get initialized by their own code. Thus unsafe code diff --git a/src/test/ui/consts/recursive-zst-static.unleash.stderr b/src/test/ui/consts/recursive-zst-static.unleash.stderr new file mode 100644 index 00000000000..d424b22f000 --- /dev/null +++ b/src/test/ui/consts/recursive-zst-static.unleash.stderr @@ -0,0 +1,21 @@ +error[E0391]: cycle detected when const-evaluating `FOO` + --> $DIR/recursive-zst-static.rs:10:18 + | +LL | static FOO: () = FOO; + | ^^^ + | +note: ...which requires const-evaluating `FOO`... + --> $DIR/recursive-zst-static.rs:10:1 + | +LL | static FOO: () = FOO; + | ^^^^^^^^^^^^^^^^^^^^^ + = note: ...which again requires const-evaluating `FOO`, completing the cycle +note: cycle used when const-evaluating + checking `FOO` + --> $DIR/recursive-zst-static.rs:10:1 + | +LL | static FOO: () = FOO; + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0391`. From c68f23ff6d670e579e0951352e20a1495b66fce0 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Mon, 27 Apr 2020 04:50:03 -0700 Subject: [PATCH 13/13] fix wasi --- src/libstd/sys/wasi/net.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libstd/sys/wasi/net.rs b/src/libstd/sys/wasi/net.rs index 30b6b984f30..e186453588d 100644 --- a/src/libstd/sys/wasi/net.rs +++ b/src/libstd/sys/wasi/net.rs @@ -49,7 +49,7 @@ impl TcpStream { } pub fn is_read_vectored(&self) -> bool { - unsupported() + true } pub fn write(&self, _: &[u8]) -> io::Result { @@ -61,7 +61,7 @@ impl TcpStream { } pub fn is_write_vectored(&self) -> bool { - unsupported() + true } pub fn peer_addr(&self) -> io::Result {