-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Point at cause for expectation in return type type error #57723
Conversation
r? @davidtwco (rust_highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CC @zackmdavis
| ^^^^ expected i32, found u32 | ||
| | ||
= note: expected type `i32` | ||
found type `u32` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these errors also point at the impl Trait
return type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think they could and that would be a tad better but the errors aren't much worse off for the lack of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
filed #57743
@@ -2,7 +2,7 @@ error[E0308]: mismatched types | |||
--> $DIR/liveness-forgot-ret.rs:3:19 | |||
| | |||
LL | fn f(a: isize) -> isize { if god_exists(a) { return 5; }; } | |||
| - ^^^^^ expected isize, found () - expected because of this statement | |||
| - ^^^^^ expected isize, found () |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yay, drive by fixes :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. r=me if you aren't going to make any further changes or improvements relating to the other review comments.
@bors r=davidtwco @davidtwco I'll mull on it and maybe have a follow up PR adding that. It should be a fairly small change, but the wording will be tricky to get right. Let's land this as it fixes a regression as well. |
📌 Commit 2e06d9c has been approved by |
Point at cause for expectation in return type type error Various improvements and fixes for type errors in return expressions. Fix rust-lang#57664.
Various improvements and fixes for type errors in return expressions.
Fix #57664.