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

47 lines
1.6 KiB
Plaintext

error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `Try`)
--> $DIR/try-operator-on-main.rs:7: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`
--> $DIR/try-operator-on-main.rs:10:5
|
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:13:25
|
LL | try_trait_generic::<()>();
| ^^ the trait `Try` is not implemented for `()`
...
LL | fn try_trait_generic<T: Try>() -> T {
| --- required by this bound in `try_trait_generic`
error[E0277]: the `?` operator can only be applied to values that implement `Try`
--> $DIR/try-operator-on-main.rs:20:5
|
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
For more information about this error, try `rustc --explain E0277`.