diff options
| author | Simon Sapin <simon.sapin@exyr.org> | 2018-06-06 12:54:25 +0200 |
|---|---|---|
| committer | Simon Sapin <simon.sapin@exyr.org> | 2018-06-06 13:52:22 +0200 |
| commit | e7c122c5b58d4db2262b1f4325d9fe82d1423ad8 (patch) | |
| tree | 91dd354fef357efc9e1ee8dcf558ea49f95cb87c /src/libstd/io | |
| parent | 4a9c58c6bd0e609538053a35685e206f66019820 (diff) | |
| download | rust-e7c122c5b58d4db2262b1f4325d9fe82d1423ad8.tar.gz rust-e7c122c5b58d4db2262b1f4325d9fe82d1423ad8.zip | |
Revert "Remove TryFrom impls that might become conditionally-infallible with a portability lint"
This reverts commit 837d6c70233715a0ae8e15c703d40e3046a2f36a. Fixes https://github.com/rust-lang/rust/issues/49415
Diffstat (limited to 'src/libstd/io')
| -rw-r--r-- | src/libstd/io/cursor.rs | 20 |
1 files changed, 2 insertions, 18 deletions
diff --git a/src/libstd/io/cursor.rs b/src/libstd/io/cursor.rs index 8ac52572810..aadd33b3954 100644 --- a/src/libstd/io/cursor.rs +++ b/src/libstd/io/cursor.rs @@ -10,6 +10,7 @@ use io::prelude::*; +use core::convert::TryInto; use cmp; use io::{self, Initializer, SeekFrom, Error, ErrorKind}; @@ -259,26 +260,9 @@ fn slice_write(pos_mut: &mut u64, slice: &mut [u8], buf: &[u8]) -> io::Result<us Ok(amt) } -/// Compensate removal of some impls per -/// https://github.com/rust-lang/rust/pull/49305#issuecomment-376293243 -#[cfg(any(target_pointer_width = "16", - target_pointer_width = "32"))] -fn try_into(n: u64) -> Result<usize, ()> { - if n <= (<usize>::max_value() as u64) { - Ok(n as usize) - } else { - Err(()) - } -} - -#[cfg(any(target_pointer_width = "64"))] -fn try_into(n: u64) -> Result<usize, ()> { - Ok(n as usize) -} - // Resizing write implementation fn vec_write(pos_mut: &mut u64, vec: &mut Vec<u8>, buf: &[u8]) -> io::Result<usize> { - let pos: usize = try_into(*pos_mut).map_err(|_| { + let pos: usize = (*pos_mut).try_into().map_err(|_| { Error::new(ErrorKind::InvalidInput, "cursor position exceeds maximum possible vector length") })?; |
