rust/src/libcore/iter
bors 0fb6e3994f Auto merge of #51564 - SimonSapin:try-int, r=alexcrichton
Implement always-fallible TryFrom for usize/isize conversions that are infallible on some platforms

This reverts commit 837d6c7023 "Remove TryFrom impls that might become conditionally-infallible with a portability lint".

This fixes #49415 by adding (restoring) missing `TryFrom` impls for integer conversions to or from `usize` or `isize`, by making them always fallible at the type system level (that is, with `Error=TryFromIntError`) even though they happen to be infallible on some platforms (for some values of `size_of::<usize>()`).

They had been removed to allow the possibility to conditionally having some of them be infallible `From` impls instead, depending on the platforms, and have the [portability lint](https://github.com/rust-lang/rfcs/pull/1868) warn when they are used in code that is not already opting into non-portability. For example `#[allow(some_lint)] usize::from(x: u64)` would be valid on code that only targets 64-bit platforms.

This PR gives up on this possiblity for two reasons:

* Based on discussion with @aturon, it seems that the portability lint is not happening any time soon. It’s better to have the conversions be available *at all* than keep blocking them for so long. Portability-lint-gated platform-specific APIs can always be added separately later.

* For code that is fine with fallibility, the alternative would force it to opt into "non-portability" even though there would be no real portability issue.
2018-07-03 04:08:02 +00:00
..
iterator.rs Rollup merge of #51511 - Centril:feature/stabilize_iterator_flatten, r=SimonSapin 2018-07-01 21:18:43 +02:00
mod.rs Rollup merge of #51511 - Centril:feature/stabilize_iterator_flatten, r=SimonSapin 2018-07-01 21:18:43 +02:00
range.rs Revert "Remove TryFrom impls that might become conditionally-infallible with a portability lint" 2018-06-06 13:52:22 +02:00
sources.rs Stabilize iterator_repeat_with 2018-06-02 15:52:09 -06:00
traits.rs Add message to rustc_on_unimplemented attributes in core 2018-06-19 15:19:13 -07:00