2018-03-28 04:25:52 -05:00
|
|
|
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `std::ops::Try`)
|
2018-12-25 09:56:47 -06:00
|
|
|
--> $DIR/try-operator-on-main.rs:9:5
|
2017-08-30 16:12:34 -05:00
|
|
|
|
|
2019-11-24 15:29:40 -06: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 19:11:12 -05:00
|
|
|
|
|
2017-08-31 05:06:13 -05:00
|
|
|
= help: the trait `std::ops::Try` is not implemented for `()`
|
2017-06-30 19:11:12 -05:00
|
|
|
= note: required by `std::ops::Try::from_error`
|
|
|
|
|
2017-08-31 14:52:49 -05:00
|
|
|
error[E0277]: the `?` operator can only be applied to values that implement `std::ops::Try`
|
2018-12-25 09:56:47 -06:00
|
|
|
--> $DIR/try-operator-on-main.rs:12: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
|
|
|
|
|
2017-08-31 14:52:49 -05:00
|
|
|
= help: the trait `std::ops::Try` is not implemented for `()`
|
2017-08-31 13:46:03 -05:00
|
|
|
= note: required by `std::ops::Try::into_result`
|
|
|
|
|
|
|
|
error[E0277]: the trait bound `(): std::ops::Try` is not satisfied
|
2019-09-20 13:58:20 -05:00
|
|
|
--> $DIR/try-operator-on-main.rs:15:25
|
2017-08-31 13:46:03 -05:00
|
|
|
|
|
2019-03-09 06:03:44 -06:00
|
|
|
LL | try_trait_generic::<()>();
|
2019-09-20 13:58:20 -05:00
|
|
|
| ^^ the trait `std::ops::Try` is not implemented for `()`
|
2019-08-24 16:44:43 -05:00
|
|
|
...
|
2018-02-22 18:42:32 -06:00
|
|
|
LL | fn try_trait_generic<T: Try>() -> T {
|
2019-09-04 12:17:59 -05:00
|
|
|
| ----------------- --- required by this bound in `try_trait_generic`
|
2017-08-30 16:12:34 -05:00
|
|
|
|
2017-08-31 14:52:49 -05:00
|
|
|
error[E0277]: the `?` operator can only be applied to values that implement `std::ops::Try`
|
2018-12-25 09:56:47 -06:00
|
|
|
--> $DIR/try-operator-on-main.rs:22: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
|
|
|
|
|
2017-08-31 14:52:49 -05:00
|
|
|
= help: the trait `std::ops::Try` is not implemented for `()`
|
2017-08-31 13:46:03 -05:00
|
|
|
= note: required by `std::ops::Try::into_result`
|
|
|
|
|
|
|
|
error: aborting due to 4 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`.
|