-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
Conversation
r? @lcnr (rust_highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
974a61c
to
6200e69
Compare
This is now ready to review. |
LGTM don't have much experience with this part of the code though, so r? @eddyb for a final review/approval |
6200e69
to
d415fae
Compare
src/test/ui/break-diverging-value.rs
Outdated
} | ||
|
||
fn loop_break_return_2() -> i32 { //~ ERROR mismatched types | ||
let loop_value = loop { break { return; () } }; |
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.
Can you change this to break { return 0; () }
?
I think in this case I expect // ok
, same as break return 0
, do you agree?
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 agree. However, apparently break { return 0 }
(and your example) behave differently than break return 0
, so I shall have to investigate.
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 believe this is because of the point that @eddyb raised earlier.
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.
See this comment
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.
That did fix it, thanks both. I added the test and it's working as expected now.
@bors r+ |
📌 Commit d1c2815 has been approved by |
☀️ Test successful - checks-actions |
Fixes #77156.