#![feature(control_flow_enum)] use std::ops::ControlFlow; fn result_to_result() -> Result { Ok(Err(123_i32)?) //~^ ERROR `?` couldn't convert the error to `u8` } fn option_to_result() -> Result { Some(3)?; //~^ ERROR the `?` operator can only be used on `Result`s, not `Option`s, in a function that returns `Result` Ok(10) } fn control_flow_to_result() -> Result { Ok(ControlFlow::Break(123)?) //~^ ERROR the `?` operator can only be used on `Result`s in a function that returns `Result` } fn result_to_option() -> Option { Some(Err("hello")?) //~^ ERROR the `?` operator can only be used on `Option`s, not `Result`s, in a function that returns `Option` } fn control_flow_to_option() -> Option { Some(ControlFlow::Break(123)?) //~^ ERROR the `?` operator can only be used on `Option`s in a function that returns `Option` } fn result_to_control_flow() -> ControlFlow { ControlFlow::Continue(Err("hello")?) //~^ ERROR the `?` operator can only be used on `ControlFlow`s in a function that returns `ControlFlow` } fn option_to_control_flow() -> ControlFlow { Some(3)?; //~^ ERROR the `?` operator can only be used on `ControlFlow`s in a function that returns `ControlFlow` ControlFlow::Break(10) } fn control_flow_to_control_flow() -> ControlFlow { ControlFlow::Break(4_u8)?; //~^ ERROR the `?` operator in a function that returns `ControlFlow` can only be used on other `ControlFlow`s ControlFlow::Continue(()) } fn main() {}