Skip to content
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

Merged
merged 7 commits into from
Jan 19, 2019

Conversation

estebank
Copy link
Contributor

@estebank estebank commented Jan 18, 2019

Various improvements and fixes for type errors in return expressions.

Fix #57664.

@rust-highfive
Copy link
Collaborator

r? @davidtwco

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 18, 2019
@estebank estebank changed the title [WIP] Point at cause for expectation in return type type error Point at cause for expectation in return type type error Jan 18, 2019
@rust-highfive

This comment has been minimized.

Copy link
Contributor Author

@estebank estebank left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

| ^^^^ expected i32, found u32
|
= note: expected type `i32`
found type `u32`
Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Contributor Author

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 ()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay, drive by fixes :)

Copy link
Member

@davidtwco davidtwco left a 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.

@estebank
Copy link
Contributor Author

@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.

@bors
Copy link
Contributor

bors commented Jan 18, 2019

📌 Commit 2e06d9c has been approved by davidtwco

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 18, 2019
Centril added a commit to Centril/rust that referenced this pull request Jan 19, 2019
Point at cause for expectation in return type type error

Various improvements and fixes for type errors in return expressions.

Fix rust-lang#57664.
bors added a commit that referenced this pull request Jan 19, 2019
Rollup of 4 pull requests

Successful merges:

 - #57452 (Improve docs for Formatter)
 - #57689 (Redo `hir::Stmt`)
 - #57723 (Point at cause for expectation in return type type error)
 - #57736 (Remove delay_span_bug from qualify_min_const_fn)

Failed merges:

r? @ghost
@bors bors merged commit 2e06d9c into rust-lang:master Jan 19, 2019
@estebank estebank deleted the fix branch November 9, 2023 05:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Diagnostics: mismatched types show wrong because of this statement
4 participants