2021-04-17 13:56:07 -05:00
|
|
|
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
|
|
|
|
--> $DIR/try-operator-on-main.rs:7:31
|
2017-08-30 16:12:34 -05:00
|
|
|
|
|
2022-09-01 14:52:39 -05:00
|
|
|
LL | fn main() {
|
|
|
|
| --------- this function should return `Result` or `Option` to accept `?`
|
|
|
|
LL | // error for a `Try` type on a non-`Try` fn
|
|
|
|
LL | std::fs::File::open("foo")?;
|
|
|
|
| ^ cannot use the `?` operator in a function that returns `()`
|
2017-06-30 19:11:12 -05:00
|
|
|
|
|
2021-04-17 13:56:07 -05:00
|
|
|
= help: the trait `FromResidual<Result<Infallible, std::io::Error>>` is not implemented for `()`
|
2017-06-30 19:11:12 -05:00
|
|
|
|
2020-09-02 02:40:56 -05:00
|
|
|
error[E0277]: the `?` operator can only be applied to values that implement `Try`
|
2020-10-27 08:10:31 -05:00
|
|
|
--> $DIR/try-operator-on-main.rs:10:5
|
2017-08-30 16:12:34 -05:00
|
|
|
|
|
2019-03-09 06:03:44 -06:00
|
|
|
LL | ()?;
|
2018-01-26 13:34:12 -06:00
|
|
|
| ^^^ the `?` operator cannot be applied to type `()`
|
2017-08-31 13:46:03 -05:00
|
|
|
|
|
2020-09-02 02:40:56 -05:00
|
|
|
= help: the trait `Try` is not implemented for `()`
|
2021-04-17 13:56:07 -05:00
|
|
|
|
|
|
|
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
|
|
|
|
--> $DIR/try-operator-on-main.rs:10:7
|
|
|
|
|
|
2022-09-01 14:52:39 -05:00
|
|
|
LL | fn main() {
|
|
|
|
| --------- this function should return `Result` or `Option` to accept `?`
|
|
|
|
...
|
|
|
|
LL | ()?;
|
|
|
|
| ^ cannot use the `?` operator in a function that returns `()`
|
2021-04-17 13:56:07 -05:00
|
|
|
|
|
|
|
|
= help: the trait `FromResidual<_>` is not implemented for `()`
|
2017-08-31 13:46:03 -05:00
|
|
|
|
2020-09-02 02:40:56 -05:00
|
|
|
error[E0277]: the trait bound `(): Try` is not satisfied
|
2021-04-17 13:56:07 -05:00
|
|
|
--> $DIR/try-operator-on-main.rs:14:25
|
2017-08-31 13:46:03 -05:00
|
|
|
|
|
2019-03-09 06:03:44 -06:00
|
|
|
LL | try_trait_generic::<()>();
|
2020-09-02 02:40:56 -05:00
|
|
|
| ^^ the trait `Try` is not implemented for `()`
|
2021-07-31 11:26:55 -05:00
|
|
|
|
|
|
|
|
note: required by a bound in `try_trait_generic`
|
|
|
|
--> $DIR/try-operator-on-main.rs:17:25
|
|
|
|
|
|
2018-02-22 18:42:32 -06:00
|
|
|
LL | fn try_trait_generic<T: Try>() -> T {
|
2021-07-31 11:26:55 -05:00
|
|
|
| ^^^ required by this bound in `try_trait_generic`
|
2017-08-30 16:12:34 -05:00
|
|
|
|
2020-09-02 02:40:56 -05:00
|
|
|
error[E0277]: the `?` operator can only be applied to values that implement `Try`
|
2021-04-17 13:56:07 -05:00
|
|
|
--> $DIR/try-operator-on-main.rs:19:5
|
2017-08-31 13:46:03 -05:00
|
|
|
|
|
2019-03-09 06:03:44 -06:00
|
|
|
LL | ()?;
|
2018-01-26 13:34:12 -06:00
|
|
|
| ^^^ the `?` operator cannot be applied to type `()`
|
2017-08-31 13:46:03 -05:00
|
|
|
|
|
2020-09-02 02:40:56 -05:00
|
|
|
= help: the trait `Try` is not implemented for `()`
|
2017-08-31 13:46:03 -05:00
|
|
|
|
2021-04-17 13:56:07 -05:00
|
|
|
error: aborting due to 5 previous errors
|
2017-06-30 19:11:12 -05:00
|
|
|
|
2018-03-03 08:59:40 -06:00
|
|
|
For more information about this error, try `rustc --explain E0277`.
|