1 #![feature(control_flow_enum)]
3 use std::ops::ControlFlow;
5 fn result_to_result() -> Result<u64, u8> {
7 //~^ ERROR `?` couldn't convert the error to `u8`
10 fn option_to_result() -> Result<u64, String> {
12 //~^ ERROR the `?` operator can only be used on `Result`s, not `Option`s, in a function that returns `Result`
16 fn control_flow_to_result() -> Result<u64, String> {
17 Ok(ControlFlow::Break(123)?)
18 //~^ ERROR the `?` operator can only be used on `Result`s in a function that returns `Result`
21 fn result_to_option() -> Option<u16> {
23 //~^ ERROR the `?` operator can only be used on `Option`s, not `Result`s, in a function that returns `Option`
26 fn control_flow_to_option() -> Option<u64> {
27 Some(ControlFlow::Break(123)?)
28 //~^ ERROR the `?` operator can only be used on `Option`s in a function that returns `Option`
31 fn result_to_control_flow() -> ControlFlow<String> {
32 ControlFlow::Continue(Err("hello")?)
33 //~^ ERROR the `?` operator can only be used on `ControlFlow`s in a function that returns `ControlFlow`
36 fn option_to_control_flow() -> ControlFlow<u64> {
38 //~^ ERROR the `?` operator can only be used on `ControlFlow`s in a function that returns `ControlFlow`
39 ControlFlow::Break(10)
42 fn control_flow_to_control_flow() -> ControlFlow<i64> {
43 ControlFlow::Break(4_u8)?;
44 //~^ ERROR the `?` operator in a function that returns `ControlFlow<B, _>` can only be used on other `ControlFlow<B, _>`s
45 ControlFlow::Continue(())