-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Include label in the span of loops #27065
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
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nrc (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. 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. |
If you put the label on a separate line from the loop’s body, you can test that an arbitrary error’s span starts on the line of the label: fn main() {
let _: i32 =
'a: //~ ERROR mismatched types
loop { break };
let _: i32 =
'b: //~ ERROR mismatched types
while true { break };
let _: i32 =
'c: //~ ERROR mismatched types
for _ in None { break };
} (I haven’t actually tested this, but it should work.) |
Thanks @P1start, that worked beautifully. The test even helped me catch a case I forgot about (while let). |
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// Regression test for #27042. |
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.
Could you say what is actually being tested here (the issue number is clear from the file name).
r=me modulo the test comment nit |
Updated! |
@bors r+ |
📌 Commit 1296360 has been approved by |
This closes #27042. I'd love to know if there's a way to make a regression test for this!
This closes #27042.
I'd love to know if there's a way to make a regression test for this!