]> git.lizzy.rs Git - rust.git/blob - src/test/ui/try-operator-on-main.stderr
Auto merge of #67000 - spastorino:remove-promoted-from-place, r=oli-obk
[rust.git] / src / test / ui / try-operator-on-main.stderr
1 error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `std::ops::Try`)
2   --> $DIR/try-operator-on-main.rs:9:5
3    |
4 LL | / fn main() {
5 LL | |     // error for a `Try` type on a non-`Try` fn
6 LL | |     std::fs::File::open("foo")?;
7    | |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot use the `?` operator in a function that returns `()`
8 LL | |
9 ...  |
10 LL | |     try_trait_generic::<()>();
11 LL | | }
12    | |_- this function should return `Result` or `Option` to accept `?`
13    |
14    = help: the trait `std::ops::Try` is not implemented for `()`
15    = note: required by `std::ops::Try::from_error`
16
17 error[E0277]: the `?` operator can only be applied to values that implement `std::ops::Try`
18   --> $DIR/try-operator-on-main.rs:12:5
19    |
20 LL |     ()?;
21    |     ^^^ the `?` operator cannot be applied to type `()`
22    |
23    = help: the trait `std::ops::Try` is not implemented for `()`
24    = note: required by `std::ops::Try::into_result`
25
26 error[E0277]: the trait bound `(): std::ops::Try` is not satisfied
27   --> $DIR/try-operator-on-main.rs:15:25
28    |
29 LL |     try_trait_generic::<()>();
30    |                         ^^ the trait `std::ops::Try` is not implemented for `()`
31 ...
32 LL | fn try_trait_generic<T: Try>() -> T {
33    |    -----------------    --- required by this bound in `try_trait_generic`
34
35 error[E0277]: the `?` operator can only be applied to values that implement `std::ops::Try`
36   --> $DIR/try-operator-on-main.rs:22:5
37    |
38 LL |     ()?;
39    |     ^^^ the `?` operator cannot be applied to type `()`
40    |
41    = help: the trait `std::ops::Try` is not implemented for `()`
42    = note: required by `std::ops::Try::into_result`
43
44 error: aborting due to 4 previous errors
45
46 For more information about this error, try `rustc --explain E0277`.