Skip to content

Fix control flow check for breaking with diverging values #77317

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

Merged
merged 3 commits into from
Oct 27, 2020

Conversation

varkor
Copy link
Member

@varkor varkor commented Sep 29, 2020

Fixes #77156.

@rust-highfive
Copy link
Contributor

r? @lcnr

(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 Sep 29, 2020
@varkor

This comment has been minimized.

@jyn514 jyn514 added A-control-flow Area: Control flow T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 29, 2020
@varkor varkor force-pushed the break-diverging-value branch from 974a61c to 6200e69 Compare September 29, 2020 10:45
@varkor
Copy link
Member Author

varkor commented Sep 29, 2020

This is now ready to review.

@lcnr
Copy link
Contributor

lcnr commented Sep 29, 2020

LGTM

don't have much experience with this part of the code though, so r? @eddyb for a final review/approval

@rust-highfive rust-highfive assigned eddyb and unassigned lcnr Sep 29, 2020
@LeSeulArtichaut LeSeulArtichaut added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 16, 2020
@eddyb
Copy link
Member

eddyb commented Oct 18, 2020

r? @nikomatsakis

@rust-highfive rust-highfive assigned nikomatsakis and unassigned eddyb Oct 18, 2020
@varkor varkor force-pushed the break-diverging-value branch from 6200e69 to d415fae Compare October 21, 2020 21:52
}

fn loop_break_return_2() -> i32 { //~ ERROR mismatched types
let loop_value = loop { break { return; () } };
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you change this to break { return 0; () }?

I think in this case I expect // ok, same as break return 0, do you agree?

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree. However, apparently break { return 0 } (and your example) behave differently than break return 0, so I shall have to investigate.

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this is because of the point that @eddyb raised earlier.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

That did fix it, thanks both. I added the test and it's working as expected now.

@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Collaborator

bors commented Oct 26, 2020

📌 Commit d1c2815 has been approved by nikomatsakis

@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 Oct 26, 2020
@bors
Copy link
Collaborator

bors commented Oct 27, 2020

⌛ Testing commit d1c2815 with merge 824f900...

@bors
Copy link
Collaborator

bors commented Oct 27, 2020

☀️ Test successful - checks-actions
Approved by: nikomatsakis
Pushing 824f900 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Oct 27, 2020
@bors bors merged commit 824f900 into rust-lang:master Oct 27, 2020
@rustbot rustbot added this to the 1.49.0 milestone Oct 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-control-flow Area: Control flow merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
9 participants