rust/src/test/ui/try-operator-on-main.stderr

47 lines
1.6 KiB
Text
Raw Normal View History

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
|
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 `?`
|
= help: the trait `Try` is not implemented for `()`
= note: required by `from_error`
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
|
2019-03-09 15:03:44 +03:00
LL | ()?;
| ^^^ the `?` operator cannot be applied to type `()`
|
= help: the trait `Try` is not implemented for `()`
= note: required by `into_result`
error[E0277]: the trait bound `(): Try` is not satisfied
--> $DIR/try-operator-on-main.rs:15:25
|
2019-03-09 15:03:44 +03:00
LL | try_trait_generic::<()>();
| ^^ the trait `Try` is not implemented for `()`
...
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`
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
|
2019-03-09 15:03:44 +03:00
LL | ()?;
| ^^^ the `?` operator cannot be applied to type `()`
|
= help: the trait `Try` is not implemented for `()`
= note: required by `into_result`
error: aborting due to 4 previous errors
2018-03-03 15:59:40 +01:00
For more information about this error, try `rustc --explain E0277`.