fork/rust

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

borsAuto merge of #71365 - Mark-Simulacrum:stable-next, r=Mark-Simulacrum4fb7144ed15

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