RFC 1859 laid out specific error messages for the ? operator, but currently they are not implemented (and instead the compiler's internal desugaring is revealed).
UPDATE: Many parts of this are done, but not all. Here is a post with examples that are not yet great.
UPDATE 2: to close this ticket we need to improve the output of a single case left to point at the return type to explain where usize is coming from.
Original text:
try! in main has long been an issue, to the point of trying to adjust the language to support it: rust-lang/rfcs#1176
I was trying out ? today, and hit this error:
error[E0308]: mismatched types
--> src/main.rs:5:13
|
5 | let f = File::open("hello.txt")?;
| ^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found enum `std::result::Result`
|
= note: expected type `()`
= note: found type `std::result::Result<_, _>`
That's the only line, inside of a main() function. Even though I know about this pitfall, and have been using Rust for a long time, I asked a question about it on IRC.
Can we print a better diagnostic here that points out it's the return type of the function that's looking for ()?
RFC 1859 laid out specific error messages for the
?operator, but currently they are not implemented (and instead the compiler's internal desugaring is revealed).UPDATE: Many parts of this are done, but not all. Here is a post with examples that are not yet great.
UPDATE 2: to close this ticket we need to improve the output of a single case left to point at the return type to explain where
usizeis coming from.Original text:
try!in main has long been an issue, to the point of trying to adjust the language to support it: rust-lang/rfcs#1176I was trying out
?today, and hit this error:That's the only line, inside of a
main()function. Even though I know about this pitfall, and have been using Rust for a long time, I asked a question about it on IRC.Can we print a better diagnostic here that points out it's the return type of the function that's looking for
()?