about summary refs log tree commit diff
path: root/src/libstd/sys
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-05-12 18:45:00 +0000
committerbors <bors@rust-lang.org>2018-05-12 18:45:00 +0000
commitff2ac35db93a80b2de5daa4f280bf1503d62c164 (patch)
treed267bc43ba84346d4592ed77f5d2a7084d299304 /src/libstd/sys
parentc0cea750a0a10a0ed5a101839e37968d87f8ef9d (diff)
parentda79ff3cc2265514483d2a5e1f4238c85baa70e9 (diff)
downloadrust-ff2ac35db93a80b2de5daa4f280bf1503d62c164.tar.gz
rust-ff2ac35db93a80b2de5daa4f280bf1503d62c164.zip
Auto merge of #50686 - Mark-Simulacrum:rollup, r=Mark-Simulacrum
Rollup of 13 pull requests

Successful merges:

 - #50544 (Cleanup some dependencies)
 - #50545 (Made some functions in time module const)
 - #50550 (use fmt::Result where applicable)
 - #50558 (Remove all reference to DepGraph::work_products)
 - #50602 (Update canonicalize docs)
 - #50607 (Allocate Symbol strings from an arena)
 - #50613 (Migrate the toolstate update bot to rust-highfive)
 - #50624 (fs::write: Add example writing a &str)
 - #50634 (Do not silently truncate offsets for `read_at`/`write_at` on emscripten)
 - #50644 (AppVeyor: Read back trace from crash dump on failure.)
 - #50661 (Ignore non .rs files for tidy libcoretest)
 - #50663 (rustc: Allow an edition's feature on that edition)
 - #50667 (rustc: Only suggest deleting `extern crate` if it works)

Failed merges:
Diffstat (limited to 'src/libstd/sys')
-rw-r--r--src/libstd/sys/redox/syscall/error.rs4
-rw-r--r--src/libstd/sys/unix/fd.rs18
2 files changed, 18 insertions, 4 deletions
diff --git a/src/libstd/sys/redox/syscall/error.rs b/src/libstd/sys/redox/syscall/error.rs
index d8d78d55016..1ef79547431 100644
--- a/src/libstd/sys/redox/syscall/error.rs
+++ b/src/libstd/sys/redox/syscall/error.rs
@@ -48,13 +48,13 @@ impl Error {
 }
 
 impl fmt::Debug for Error {
-    fn fmt(&self, f: &mut fmt::Formatter) -> result::Result<(), fmt::Error> {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         f.write_str(self.text())
     }
 }
 
 impl fmt::Display for Error {
-    fn fmt(&self, f: &mut fmt::Formatter) -> result::Result<(), fmt::Error> {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         f.write_str(self.text())
     }
 }
diff --git a/src/libstd/sys/unix/fd.rs b/src/libstd/sys/unix/fd.rs
index 5dafc3251e7..67546d06b4e 100644
--- a/src/libstd/sys/unix/fd.rs
+++ b/src/libstd/sys/unix/fd.rs
@@ -75,8 +75,15 @@ impl FileDesc {
         unsafe fn cvt_pread64(fd: c_int, buf: *mut c_void, count: usize, offset: i64)
             -> io::Result<isize>
         {
+            use convert::TryInto;
             use libc::pread64;
-            cvt(pread64(fd, buf, count, offset as i32))
+            // pread64 on emscripten actually takes a 32 bit offset
+            if let Ok(o) = offset.try_into() {
+                cvt(pread64(fd, buf, count, o))
+            } else {
+                Err(io::Error::new(io::ErrorKind::InvalidInput,
+                                   "cannot pread >2GB"))
+            }
         }
 
         #[cfg(not(any(target_os = "android", target_os = "emscripten")))]
@@ -116,8 +123,15 @@ impl FileDesc {
         unsafe fn cvt_pwrite64(fd: c_int, buf: *const c_void, count: usize, offset: i64)
             -> io::Result<isize>
         {
+            use convert::TryInto;
             use libc::pwrite64;
-            cvt(pwrite64(fd, buf, count, offset as i32))
+            // pwrite64 on emscripten actually takes a 32 bit offset
+            if let Ok(o) = offset.try_into() {
+                cvt(pwrite64(fd, buf, count, o))
+            } else {
+                Err(io::Error::new(io::ErrorKind::InvalidInput,
+                                   "cannot pwrite >2GB"))
+            }
         }
 
         #[cfg(not(any(target_os = "android", target_os = "emscripten")))]