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

Fix error message for mismatched types #41547

Merged

Conversation

alexeyzab
Copy link
Contributor

This addresses #41425 by implementing the changes mentioned in the
following comment:
#41425 (comment)

This addresses rust-lang#41425 by implementing the changes mentioned in the
following comment:
rust-lang#41425 (comment)
@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @arielb1 (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

This adjusts several lines to be shorter than 100 characters.
// `break`, we want to call the `()` "expected"
// since it is implied by the syntax.
assert!(expression_ty.is_nil());
let (expected, found) = if label_expression_as_expected {
(expression_ty, self.final_ty.unwrap_or(self.expected_ty))
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: you dropped half of a comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This part of the comment was meant to be deleted per #41425 (comment). Should I rephrase the remaining part?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can leave the comment, or amend some text like "(Note not all force-units work this way.)"

15 | | }
| |_^ expected (), found i32
|
= note: expected type `i32`
Copy link
Contributor

Choose a reason for hiding this comment

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

why are the note and label the other way around?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not entirely sure as well. @nikomatsakis Should the label be reversed too?

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch @arielb1. To fix that you have to change this line (part of fn coerce_inner(), not found in the diff):

fcx.eq_types(true, cause, expression_ty, self.merged_ty())

to be something like this:

fcx.eq_types(label_expression_as_expected, cause, expression_ty, self.merged_ty())

That true argument indicates that the a value (first type) ought to be marked as "expected". That is no longer always true.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great, thanks for pointing this out!

@aidanhs aidanhs added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 26, 2017
@arielb1
Copy link
Contributor

arielb1 commented May 2, 2017

@bors r+

@bors
Copy link
Contributor

bors commented May 2, 2017

📌 Commit c741bc8 has been approved by arielb1

@bors
Copy link
Contributor

bors commented May 2, 2017

⌛ Testing commit c741bc8 with merge 96e2c34...

bors added a commit that referenced this pull request May 2, 2017
…sage, r=arielb1

Fix error message for mismatched types

This addresses #41425 by implementing the changes mentioned in the
following comment:
#41425 (comment)
@bors
Copy link
Contributor

bors commented May 2, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: arielb1
Pushing 96e2c34 to master...

@bors bors merged commit c741bc8 into rust-lang:master May 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants