rust/library/core/tests
Yuki Okushi 5936ecc24f
Rollup merge of #85608 - scottmcm:stabilize-control-flow-enum-basics, r=m-ou-se
Stabilize `ops::ControlFlow` (just the type)

Tracking issue: https://github.com/rust-lang/rust/issues/75744 (which also tracks items *not* closed by this PR).

With the new `?` desugar implemented, [it's no longer possible to mix `Result` and `ControlFlow`](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=13feec97f5c96a9d791d97f7de2d49a6).  (At the time of making this PR, godbolt was still on the 2021-05-01 nightly, where you can see that [the mixing example compiled](https://rust.godbolt.org/z/13Ke54j16).)  That resolves the only blocker I know of, so I'd like to propose that `ControlFlow` be considered for stabilization.

Its basic existence was part of https://github.com/rust-lang/rfcs/pull/3058, where it got a bunch of positive comments (examples [1](https://github.com/rust-lang/rfcs/pull/3058#issuecomment-758277325) [2](https://github.com/rust-lang/rfcs/pull/3058#pullrequestreview-592106494) [3](https://github.com/rust-lang/rfcs/pull/3058#issuecomment-784444155) [4](https://github.com/rust-lang/rfcs/pull/3058#issuecomment-797031584)).  Its use in the compiler has been well received (https://github.com/rust-lang/rust/pull/78182#issuecomment-713695594), and there are ecosystem updates interested in using it (https://github.com/rust-itertools/itertools/issues/469#issuecomment-677729589, https://github.com/jonhoo/rust-imap/issues/194).

As this will need an FCP, picking a libs member manually:
r? `@m-ou-se`

## Stabilized APIs

```rust
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum ControlFlow<B, C = ()> {
    /// Exit the operation without running subsequent phases.
    Break(B),
    /// Move on to the next phase of the operation as normal.
    Continue(C),
}
```

As well as using `?` on a `ControlFlow<B, _>` in a function returning `ControlFlow<B, _>`.  (Note, in particular, that there's no `From::from`-conversion on the `Break` value, the way there is for `Err`s.)

## Existing APIs *not* stabilized here

All the associated methods and constants: `break_value`, `is_continue`, `map_break`, [`CONTINUE`](https://doc.rust-lang.org/nightly/std/ops/enum.ControlFlow.html#associatedconstant.CONTINUE), etc.

Some of the existing methods in nightly seem reasonable, some seem like they should be removed, and some need more discussion to decide.  But none of them are *essential*, so [as in the RFC](https://rust-lang.github.io/rfcs/3058-try-trait-v2.html#methods-on-controlflow), they're all omitted from this PR.

They can be considered separately later, as further usage demonstrates which are important.
2021-06-15 17:40:08 +09:00
..
fmt Format Struct { .. } on one line even with {:#?}. 2021-04-21 13:50:56 +02:00
hash
iter Update expressions where we can use array's IntoIterator implementation 2021-06-02 16:09:04 +06:00
num Preserve signed zero on roundtrip 2021-03-22 17:02:09 -07:00
ops Expand the docs for ops::ControlFlow a bit 2021-02-06 22:36:05 -08:00
alloc.rs
any.rs Add test for issue 84666. 2021-06-03 16:13:45 +02:00
array.rs Update expressions where we can use array's IntoIterator implementation 2021-06-02 16:09:04 +06:00
ascii.rs Make ui test that are run-pass and do not test the compiler itself library tests 2020-11-30 02:47:32 +01:00
atomic.rs enable atomic_min/max tests in Miri 2021-03-02 19:58:55 +01:00
bool.rs Make ui test that are run-pass and do not test the compiler itself library tests 2020-11-30 02:47:32 +01:00
cell.rs Constantify UnsafeCell::into_inner and related 2020-11-04 11:41:57 +01:00
char.rs Further simplification of to_digit 2021-06-10 20:16:35 +01:00
clone.rs Fix borrow and deref 2021-03-03 11:23:29 +01:00
cmp.rs Make ui test that are run-pass and do not test the compiler itself library tests 2020-11-30 02:47:32 +01:00
const_ptr.rs Revert tests added by PR 81167. 2021-06-04 16:44:28 -04:00
intrinsics.rs move test to intergrated test in library/core 2020-09-24 14:46:57 +00:00
lazy.rs
lib.rs Rollup merge of #85608 - scottmcm:stabilize-control-flow-enum-basics, r=m-ou-se 2021-06-15 17:40:08 +09:00
macros.rs Make ui test that are run-pass and do not test the compiler itself library tests 2020-11-30 02:47:32 +01:00
manually_drop.rs
mem.rs Allow use of deprecated std::raw in a test for that feature 2021-04-15 19:16:18 +02:00
nonzero.rs Added impl Rem<NonZeroU{0}> for u{0} which cannot panic 2020-12-17 18:42:19 +02:00
ops.rs Expand the docs for ops::ControlFlow a bit 2021-02-06 22:36:05 -08:00
option.rs Simple library test updates 2021-05-06 11:37:45 -07:00
pattern.rs
pin.rs Make some methods of Pin<&mut T> unstable const 2020-09-18 19:23:50 +02:00
ptr.rs Bump cfgs 2021-04-04 14:57:05 -04:00
result.rs Simple library test updates 2021-05-06 11:37:45 -07:00
slice.rs Implement indexing slices with pairs of ops::Bound<usize> 2021-04-13 09:57:24 -04:00
str.rs
str_lossy.rs
task.rs
time.rs Fixup tests: Duration::MIN -> ::ZERO 2020-10-27 13:57:51 -07:00
tuple.rs
unicode.rs Make ui test that are run-pass and do not test the compiler itself library tests 2020-11-30 02:47:32 +01:00