fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #66089 - Mark-Simulacrum:stable-next, r=Mark-Simulacrum4560ea788cb

1.39.0
1.6 KiB39 linesraw
1error[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   |
4LL |     std::fs::File::open("foo")?;
5   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot use the `?` operator in a function that returns `()`
6   |
7   = help: the trait `std::ops::Try` is not implemented for `()`
8   = note: required by `std::ops::Try::from_error`
9
10error[E0277]: the `?` operator can only be applied to values that implement `std::ops::Try`
11  --> $DIR/try-operator-on-main.rs:12:5
12   |
13LL |     ()?;
14   |     ^^^ the `?` operator cannot be applied to type `()`
15   |
16   = help: the trait `std::ops::Try` is not implemented for `()`
17   = note: required by `std::ops::Try::into_result`
18
19error[E0277]: the trait bound `(): std::ops::Try` is not satisfied
20  --> $DIR/try-operator-on-main.rs:15:25
21   |
22LL |     try_trait_generic::<()>();
23   |                         ^^ the trait `std::ops::Try` is not implemented for `()`
24...
25LL | fn try_trait_generic<T: Try>() -> T {
26   |    -----------------    --- required by this bound in `try_trait_generic`
27
28error[E0277]: the `?` operator can only be applied to values that implement `std::ops::Try`
29  --> $DIR/try-operator-on-main.rs:22:5
30   |
31LL |     ()?;
32   |     ^^^ the `?` operator cannot be applied to type `()`
33   |
34   = help: the trait `std::ops::Try` is not implemented for `()`
35   = note: required by `std::ops::Try::into_result`
36
37error: aborting due to 4 previous errors
38
39For more information about this error, try `rustc --explain E0277`.