diff options
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/io/stdio.rs | 45 | ||||
| -rw-r--r-- | src/libstd/lib.rs | 4 | ||||
| -rw-r--r-- | src/libstd/os/fortanix_sgx/mod.rs | 2 | ||||
| -rw-r--r-- | src/libstd/sys/mod.rs | 2 | ||||
| -rw-r--r-- | src/libstd/sys/sgx/abi/usercalls/alloc.rs | 7 | ||||
| -rw-r--r-- | src/libstd/sys/sgx/abi/usercalls/mod.rs | 3 | ||||
| -rw-r--r-- | src/libstd/sys/sgx/rwlock.rs | 3 | ||||
| -rw-r--r-- | src/libstd/sys/windows/stdio.rs | 4 |
8 files changed, 60 insertions, 10 deletions
diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs index d2494693230..4068c0f9c7d 100644 --- a/src/libstd/io/stdio.rs +++ b/src/libstd/io/stdio.rs @@ -131,6 +131,11 @@ fn handle_ebadf<T>(r: io::Result<T>, default: T) -> io::Result<T> { /// /// [`io::stdin`]: fn.stdin.html /// [`BufRead`]: trait.BufRead.html +/// +/// ### Note: Windows Portability Consideration +/// When operating in a console, the Windows implementation of this stream does not support +/// non-UTF-8 byte sequences. Attempting to read bytes that are not valid UTF-8 will return +/// an error. #[stable(feature = "rust1", since = "1.0.0")] pub struct Stdin { inner: Arc<Mutex<BufReader<Maybe<StdinRaw>>>>, @@ -144,6 +149,11 @@ pub struct Stdin { /// [`Read`]: trait.Read.html /// [`BufRead`]: trait.BufRead.html /// [`Stdin::lock`]: struct.Stdin.html#method.lock +/// +/// ### Note: Windows Portability Consideration +/// When operating in a console, the Windows implementation of this stream does not support +/// non-UTF-8 byte sequences. Attempting to read bytes that are not valid UTF-8 will return +/// an error. #[stable(feature = "rust1", since = "1.0.0")] pub struct StdinLock<'a> { inner: MutexGuard<'a, BufReader<Maybe<StdinRaw>>>, @@ -157,6 +167,11 @@ pub struct StdinLock<'a> { /// /// [lock]: struct.Stdin.html#method.lock /// +/// ### Note: Windows Portability Consideration +/// When operating in a console, the Windows implementation of this stream does not support +/// non-UTF-8 byte sequences. Attempting to read bytes that are not valid UTF-8 will return +/// an error. +/// /// # Examples /// /// Using implicit synchronization: @@ -328,6 +343,11 @@ impl<'a> fmt::Debug for StdinLock<'a> { /// /// Created by the [`io::stdout`] method. /// +/// ### Note: Windows Portability Consideration +/// When operating in a console, the Windows implementation of this stream does not support +/// non-UTF-8 byte sequences. Attempting to write bytes that are not valid UTF-8 will return +/// an error. +/// /// [`lock`]: #method.lock /// [`io::stdout`]: fn.stdout.html #[stable(feature = "rust1", since = "1.0.0")] @@ -343,6 +363,11 @@ pub struct Stdout { /// This handle implements the [`Write`] trait, and is constructed via /// the [`Stdout::lock`] method. /// +/// ### Note: Windows Portability Consideration +/// When operating in a console, the Windows implementation of this stream does not support +/// non-UTF-8 byte sequences. Attempting to write bytes that are not valid UTF-8 will return +/// an error. +/// /// [`Write`]: trait.Write.html /// [`Stdout::lock`]: struct.Stdout.html#method.lock #[stable(feature = "rust1", since = "1.0.0")] @@ -358,6 +383,11 @@ pub struct StdoutLock<'a> { /// /// [Stdout::lock]: struct.Stdout.html#method.lock /// +/// ### Note: Windows Portability Consideration +/// When operating in a console, the Windows implementation of this stream does not support +/// non-UTF-8 byte sequences. Attempting to write bytes that are not valid UTF-8 will return +/// an error. +/// /// # Examples /// /// Using implicit synchronization: @@ -476,6 +506,11 @@ impl<'a> fmt::Debug for StdoutLock<'a> { /// For more information, see the [`io::stderr`] method. /// /// [`io::stderr`]: fn.stderr.html +/// +/// ### Note: Windows Portability Consideration +/// When operating in a console, the Windows implementation of this stream does not support +/// non-UTF-8 byte sequences. Attempting to write bytes that are not valid UTF-8 will return +/// an error. #[stable(feature = "rust1", since = "1.0.0")] pub struct Stderr { inner: Arc<ReentrantMutex<RefCell<Maybe<StderrRaw>>>>, @@ -487,6 +522,11 @@ pub struct Stderr { /// the [`Stderr::lock`] method. /// /// [`Stderr::lock`]: struct.Stderr.html#method.lock +/// +/// ### Note: Windows Portability Consideration +/// When operating in a console, the Windows implementation of this stream does not support +/// non-UTF-8 byte sequences. Attempting to write bytes that are not valid UTF-8 will return +/// an error. #[stable(feature = "rust1", since = "1.0.0")] pub struct StderrLock<'a> { inner: ReentrantMutexGuard<'a, RefCell<Maybe<StderrRaw>>>, @@ -496,6 +536,11 @@ pub struct StderrLock<'a> { /// /// This handle is not buffered. /// +/// ### Note: Windows Portability Consideration +/// When operating in a console, the Windows implementation of this stream does not support +/// non-UTF-8 byte sequences. Attempting to write bytes that are not valid UTF-8 will return +/// an error. +/// /// # Examples /// /// Using implicit synchronization: diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 244caf28ec7..8ecba3ecd68 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -196,9 +196,7 @@ //! [primitive types]: ../book/ch03-02-data-types.html #![stable(feature = "rust1", since = "1.0.0")] -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/", +#![doc(html_root_url = "https://doc.rust-lang.org/nightly/", html_playground_url = "https://play.rust-lang.org/", issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/", test(no_crate_inject, attr(deny(warnings))), diff --git a/src/libstd/os/fortanix_sgx/mod.rs b/src/libstd/os/fortanix_sgx/mod.rs index c6106b9f827..bd6f4b4465b 100644 --- a/src/libstd/os/fortanix_sgx/mod.rs +++ b/src/libstd/os/fortanix_sgx/mod.rs @@ -16,7 +16,7 @@ pub mod usercalls { /// Primitives for allocating memory in userspace as well as copying data /// to and from user memory. pub mod alloc { - pub use sys::abi::usercalls::alloc; + pub use sys::abi::usercalls::alloc::*; } /// Lowest-level interfaces to usercalls and usercall ABI type definitions. diff --git a/src/libstd/sys/mod.rs b/src/libstd/sys/mod.rs index f398a2a6225..99ef74179c2 100644 --- a/src/libstd/sys/mod.rs +++ b/src/libstd/sys/mod.rs @@ -54,6 +54,7 @@ cfg_if! { cfg_if! { if #[cfg(any(unix, target_os = "redox"))] { // On unix we'll document what's already available + #[stable(feature = "rust1", since = "1.0.0")] pub use self::ext as unix_ext; } else if #[cfg(any(target_os = "cloudabi", target_arch = "wasm32", @@ -77,6 +78,7 @@ cfg_if! { if #[cfg(windows)] { // On windows we'll just be documenting what's already available #[allow(missing_docs)] + #[stable(feature = "rust1", since = "1.0.0")] pub use self::ext as windows_ext; } else if #[cfg(any(target_os = "cloudabi", target_arch = "wasm32", diff --git a/src/libstd/sys/sgx/abi/usercalls/alloc.rs b/src/libstd/sys/sgx/abi/usercalls/alloc.rs index 8d0013a235a..2efbaa9b148 100644 --- a/src/libstd/sys/sgx/abi/usercalls/alloc.rs +++ b/src/libstd/sys/sgx/abi/usercalls/alloc.rs @@ -537,7 +537,12 @@ impl UserRef<super::raw::ByteBuffer> { pub fn copy_user_buffer(&self) -> Vec<u8> { unsafe { let buf = self.to_enclave(); - User::from_raw_parts(buf.data as _, buf.len).to_enclave() + if buf.len > 0 { + User::from_raw_parts(buf.data as _, buf.len).to_enclave() + } else { + // Mustn't look at `data` or call `free` if `len` is `0`. + Vec::with_capacity(0) + } } } } diff --git a/src/libstd/sys/sgx/abi/usercalls/mod.rs b/src/libstd/sys/sgx/abi/usercalls/mod.rs index 4e889c172ef..bae044b906b 100644 --- a/src/libstd/sys/sgx/abi/usercalls/mod.rs +++ b/src/libstd/sys/sgx/abi/usercalls/mod.rs @@ -22,7 +22,8 @@ pub fn read(fd: Fd, buf: &mut [u8]) -> IoResult<usize> { #[unstable(feature = "sgx_platform", issue = "56975")] pub fn read_alloc(fd: Fd) -> IoResult<Vec<u8>> { unsafe { - let mut userbuf = alloc::User::<ByteBuffer>::uninitialized(); + let userbuf = ByteBuffer { data: ::ptr::null_mut(), len: 0 }; + let mut userbuf = alloc::User::new_from_enclave(&userbuf); raw::read_alloc(fd, userbuf.as_raw_mut_ptr()).from_sgx_result()?; Ok(userbuf.copy_user_buffer()) } diff --git a/src/libstd/sys/sgx/rwlock.rs b/src/libstd/sys/sgx/rwlock.rs index 43ceae7d33b..33163a556c1 100644 --- a/src/libstd/sys/sgx/rwlock.rs +++ b/src/libstd/sys/sgx/rwlock.rs @@ -19,9 +19,6 @@ unsafe fn rw_lock_size_assert(r: RWLock) { mem::transmute::<RWLock, [u8; 128]>(r); } -//unsafe impl Send for RWLock {} -//unsafe impl Sync for RWLock {} // FIXME - impl RWLock { pub const fn new() -> RWLock { RWLock { diff --git a/src/libstd/sys/windows/stdio.rs b/src/libstd/sys/windows/stdio.rs index a4f4bd22cd9..0ea19a85525 100644 --- a/src/libstd/sys/windows/stdio.rs +++ b/src/libstd/sys/windows/stdio.rs @@ -188,7 +188,9 @@ impl Output { } fn invalid_encoding() -> io::Error { - io::Error::new(io::ErrorKind::InvalidData, "text was not valid unicode") + io::Error::new(io::ErrorKind::InvalidData, + "Windows stdio in console mode does not support non-UTF-8 byte sequences; \ + see https://github.com/rust-lang/rust/issues/23344") } fn readconsole_input_control(wakeup_mask: c::ULONG) -> c::CONSOLE_READCONSOLE_CONTROL { |
