File: try-block-bad-type.stderr

package info (click to toggle)
rustc 1.85.0%2Bdfsg3-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, sid, trixie
  • size: 893,396 kB
  • sloc: xml: 158,127; python: 35,830; javascript: 19,497; cpp: 19,002; sh: 17,245; ansic: 13,127; asm: 4,376; makefile: 1,051; perl: 29; lisp: 29; ruby: 19; sql: 11
file content (46 lines) | stat: -rw-r--r-- 2,063 bytes parent folder | download | duplicates (3)
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
error[E0277]: `?` couldn't convert the error to `TryFromSliceError`
  --> $DIR/try-block-bad-type.rs:7:16
   |
LL |         Err("")?;
   |         -------^ the trait `From<&str>` is not implemented for `TryFromSliceError`
   |         |
   |         this can't be annotated with `?` because it has type `Result<_, &str>`
   |
   = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
   = help: the trait `From<&str>` is not implemented for `TryFromSliceError`
           but trait `From<Infallible>` is implemented for it
   = help: for that trait implementation, expected `Infallible`, found `&str`
   = note: required for `Result<u32, TryFromSliceError>` to implement `FromResidual<Result<Infallible, &str>>`

error[E0271]: type mismatch resolving `<Result<i32, i32> as Try>::Output == &str`
  --> $DIR/try-block-bad-type.rs:12:9
   |
LL |         ""
   |         ^^ expected `&str`, found `i32`

error[E0271]: type mismatch resolving `<Result<i32, i32> as Try>::Output == ()`
  --> $DIR/try-block-bad-type.rs:15:39
   |
LL |     let res: Result<i32, i32> = try { };
   |                                       ^ expected `()`, found `i32`

error[E0277]: a `try` block must return `Result` or `Option` (or another type that implements `Try`)
  --> $DIR/try-block-bad-type.rs:17:25
   |
LL |     let res: () = try { };
   |                         ^ could not wrap the final value of the block as `()` doesn't implement `Try`
   |
   = help: the trait `Try` is not implemented for `()`

error[E0277]: a `try` block must return `Result` or `Option` (or another type that implements `Try`)
  --> $DIR/try-block-bad-type.rs:20:26
   |
LL |     let res: i32 = try { 5 };
   |                          ^ could not wrap the final value of the block as `i32` doesn't implement `Try`
   |
   = help: the trait `Try` is not implemented for `i32`

error: aborting due to 5 previous errors

Some errors have detailed explanations: E0271, E0277.
For more information about an error, try `rustc --explain E0271`.