Skip to content

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

Merged
merged 1 commit into from
Jul 20, 2015
Merged

Include label in the span of loops #27065

merged 1 commit into from
Jul 20, 2015

Conversation

marcusklaas
Copy link
Contributor

This closes #27042.

I'd love to know if there's a way to make a regression test for this!

@rust-highfive
Copy link
Contributor

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.

@ftxqxd
Copy link
Contributor

ftxqxd commented Jul 16, 2015

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

@marcusklaas
Copy link
Contributor Author

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.
Copy link
Member

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

@nrc
Copy link
Member

nrc commented Jul 16, 2015

r=me modulo the test comment nit

@marcusklaas
Copy link
Contributor Author

Updated!

@nrc
Copy link
Member

nrc commented Jul 19, 2015

@bors r+

@bors
Copy link
Collaborator

bors commented Jul 19, 2015

📌 Commit 1296360 has been approved by nrc

bors added a commit that referenced this pull request Jul 20, 2015
This closes #27042.

I'd love to know if there's a way to make a regression test for this!
@bors
Copy link
Collaborator

bors commented Jul 20, 2015

⌛ Testing commit 1296360 with merge be23d44...

@bors bors merged commit 1296360 into rust-lang:master Jul 20, 2015
@marcusklaas marcusklaas deleted the loop-label branch July 24, 2015 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bad span for labeled loops
5 participants