2020-09-02 10:40:56 +03:00
|
|
|
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `Try`)
|
2018-12-25 08:56:47 -07:00
|
|
|
--> $DIR/try-operator-on-main.rs:9:5
|
2017-08-31 00:12:34 +03:00
|
|
|
|
|
2019-11-25 00:29:40 +03:00
|
|
|
LL | / fn main() {
|
|
|
|
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 `()`
|
|
|
|
LL | |
|
|
|
|
... |
|
|
|
|
LL | | try_trait_generic::<()>();
|
|
|
|
LL | | }
|
|
|
|
| |_- this function should return `Result` or `Option` to accept `?`
|
2017-06-30 17:11:12 -07:00
|
|
|
|
|
2020-09-02 10:40:56 +03:00
|
|
|
= help: the trait `Try` is not implemented for `()`
|
|
|
|
= note: required by `from_error`
|
2017-06-30 17:11:12 -07:00
|
|
|
|
2020-09-02 10:40:56 +03:00
|
|
|
error[E0277]: the `?` operator can only be applied to values that implement `Try`
|
2018-12-25 08:56:47 -07:00
|
|
|
--> $DIR/try-operator-on-main.rs:12:5
|
2017-08-31 00:12:34 +03:00
|
|
|
|
|
2019-03-09 15:03:44 +03:00
|
|
|
LL | ()?;
|
2018-01-26 11:34:12 -08:00
|
|
|
| ^^^ the `?` operator cannot be applied to type `()`
|
2017-08-31 21:46:03 +03:00
|
|
|
|
|
2020-09-02 10:40:56 +03:00
|
|
|
= help: the trait `Try` is not implemented for `()`
|
|
|
|
= note: required by `into_result`
|
2017-08-31 21:46:03 +03:00
|
|
|
|
2020-09-02 10:40:56 +03:00
|
|
|
error[E0277]: the trait bound `(): Try` is not satisfied
|
2019-09-20 11:58:20 -07:00
|
|
|
--> $DIR/try-operator-on-main.rs:15:25
|
2017-08-31 21:46:03 +03:00
|
|
|
|
|
2019-03-09 15:03:44 +03:00
|
|
|
LL | try_trait_generic::<()>();
|
2020-09-02 10:40:56 +03:00
|
|
|
| ^^ the trait `Try` is not implemented for `()`
|
2019-08-24 14:44:43 -07:00
|
|
|
...
|
2018-02-23 03:42:32 +03:00
|
|
|
LL | fn try_trait_generic<T: Try>() -> T {
|
2020-04-05 22:15:06 -07:00
|
|
|
| --- required by this bound in `try_trait_generic`
|
2017-08-31 00:12:34 +03:00
|
|
|
|
2020-09-02 10:40:56 +03:00
|
|
|
error[E0277]: the `?` operator can only be applied to values that implement `Try`
|
2018-12-25 08:56:47 -07:00
|
|
|
--> $DIR/try-operator-on-main.rs:22:5
|
2017-08-31 21:46:03 +03:00
|
|
|
|
|
2019-03-09 15:03:44 +03:00
|
|
|
LL | ()?;
|
2018-01-26 11:34:12 -08:00
|
|
|
| ^^^ the `?` operator cannot be applied to type `()`
|
2017-08-31 21:46:03 +03:00
|
|
|
|
|
2020-09-02 10:40:56 +03:00
|
|
|
= help: the trait `Try` is not implemented for `()`
|
|
|
|
= note: required by `into_result`
|
2017-08-31 21:46:03 +03:00
|
|
|
|
|
|
|
error: aborting due to 4 previous errors
|
2017-06-30 17:11:12 -07:00
|
|
|
|
2018-03-03 15:59:40 +01:00
|
|
|
For more information about this error, try `rustc --explain E0277`.
|