diff options
| author | bors <bors@rust-lang.org> | 2020-07-27 11:07:32 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-07-27 11:07:32 +0000 |
| commit | 52d2c7ac948d6abdc18eb9e05a53d03ddcaffd98 (patch) | |
| tree | a30872c445cc554a5bff48f20e7afb134540c103 /src/libstd | |
| parent | 9af6b3d4e74cf31c21821430de755219bf239d96 (diff) | |
| parent | 7df242dd0900c9ac9bf79c184c72b0978ef9fa9e (diff) | |
| download | rust-52d2c7ac948d6abdc18eb9e05a53d03ddcaffd98.tar.gz rust-52d2c7ac948d6abdc18eb9e05a53d03ddcaffd98.zip | |
Auto merge of #74817 - JohnTitor:rollup-0fchdye, r=JohnTitor
Rollup of 6 pull requests Successful merges: - #74088 (Avoid writes without any data in `Write::write_all_vectored`) - #74598 (Fix sync_once_cell_does_not_leak_partially_constructed_boxes) - #74750 (Clean up some uses of logging in ui tests) - #74783 (python codes cleanup) - #74790 (Don't italicize comments in ayu theme) - #74799 (Fixed typo in `closure`) Failed merges: r? @ghost
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/io/mod.rs | 7 | ||||
| -rw-r--r-- | src/libstd/lazy.rs | 2 |
2 files changed, 7 insertions, 2 deletions
diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 797318d95b7..9eb54c2cc00 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -251,7 +251,6 @@ use crate::cmp; use crate::fmt; -use crate::mem; use crate::memchr; use crate::ops::{Deref, DerefMut}; use crate::ptr; @@ -1435,12 +1434,15 @@ pub trait Write { /// ``` #[unstable(feature = "write_all_vectored", issue = "70436")] fn write_all_vectored(&mut self, mut bufs: &mut [IoSlice<'_>]) -> Result<()> { + // Guarantee that bufs is empty if it contains no data, + // to avoid calling write_vectored if there is no data to be written. + bufs = IoSlice::advance(bufs, 0); while !bufs.is_empty() { match self.write_vectored(bufs) { Ok(0) => { return Err(Error::new(ErrorKind::WriteZero, "failed to write whole buffer")); } - Ok(n) => bufs = IoSlice::advance(mem::take(&mut bufs), n), + Ok(n) => bufs = IoSlice::advance(bufs, n), Err(ref e) if e.kind() == ErrorKind::Interrupted => {} Err(e) => return Err(e), } @@ -2958,6 +2960,7 @@ mod tests { #[rustfmt::skip] // Becomes unreadable otherwise. let tests: Vec<(_, &'static [u8])> = vec![ (vec![], &[]), + (vec![IoSlice::new(&[]), IoSlice::new(&[])], &[]), (vec![IoSlice::new(&[1])], &[1]), (vec![IoSlice::new(&[1, 2])], &[1, 2]), (vec![IoSlice::new(&[1, 2, 3])], &[1, 2, 3]), diff --git a/src/libstd/lazy.rs b/src/libstd/lazy.rs index 86e1cfae582..1705a4f77c5 100644 --- a/src/libstd/lazy.rs +++ b/src/libstd/lazy.rs @@ -827,6 +827,8 @@ mod tests { tx.send(msg).unwrap(); break; } + #[cfg(target_env = "sgx")] + crate::thread::yield_now(); } }); } |
