File: try-operator-on-main.stderr

package info (click to toggle)
rustc-web 1.78.0%2Bdfsg1-2~deb12u3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,245,420 kB
  • sloc: xml: 147,985; javascript: 18,022; sh: 11,083; python: 10,265; ansic: 6,172; cpp: 5,023; asm: 4,390; makefile: 4,269
file content (53 lines) | stat: -rw-r--r-- 2,102 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
  --> $DIR/try-operator-on-main.rs:7:31
   |
LL | fn main() {
   | --------- this function should return `Result` or `Option` to accept `?`
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 `()`
   |
   = help: the trait `FromResidual<Result<Infallible, std::io::Error>>` is not implemented for `()`

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 `()`

error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
  --> $DIR/try-operator-on-main.rs:10:7
   |
LL | fn main() {
   | --------- this function should return `Result` or `Option` to accept `?`
...
LL |     ()?;
   |       ^ cannot use the `?` operator in a function that returns `()`
   |
   = help: the trait `FromResidual<_>` is not implemented for `()`

error[E0277]: the trait bound `(): Try` is not satisfied
  --> $DIR/try-operator-on-main.rs:14:25
   |
LL |     try_trait_generic::<()>();
   |                         ^^ the trait `Try` is not implemented for `()`
   |
note: required by a bound in `try_trait_generic`
  --> $DIR/try-operator-on-main.rs:17:25
   |
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:19:5
   |
LL |     ()?;
   |     ^^^ the `?` operator cannot be applied to type `()`
   |
   = help: the trait `Try` is not implemented for `()`

error: aborting due to 5 previous errors

For more information about this error, try `rustc --explain E0277`.