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

Tracking issue for RFC 2086: Allow Irrefutable Patterns in if-let and while-let statements #44495

Closed
3 tasks done
aturon opened this issue Sep 11, 2017 · 37 comments
Closed
3 tasks done
Assignees
Labels
B-RFC-approved Blocker: Approved by a merged RFC but not yet implemented. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. finished-final-comment-period The final comment period is finished for this PR / Issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@aturon
Copy link
Member

aturon commented Sep 11, 2017

This is a tracking issue for the RFC "Allow Irrefutable Patterns in if-let and while-let statements" (rust-lang/rfcs#2086).

Steps:

@aturon aturon added B-RFC-approved Blocker: Approved by a merged RFC but not yet implemented. T-lang Relevant to the language team, which will review and decide on the PR/issue. labels Sep 11, 2017
@nikomatsakis nikomatsakis added E-needs-mentor T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 15, 2017
@nikomatsakis nikomatsakis added this to the impl period milestone Sep 15, 2017
@aturon aturon removed this from the impl period milestone Sep 15, 2017
@TimNN TimNN added the C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. label Sep 17, 2017
@arielb1 arielb1 self-assigned this Sep 18, 2017
@arielb1
Copy link
Contributor

arielb1 commented Sep 19, 2017

Mentoring Instructions

This is actually an easy one:

The code that emits the error message is the check_arms function here:

fn check_arms<'a, 'tcx>(cx: &mut MatchCheckCtxt<'a, 'tcx>,

It nicely contains branches for if let and while let, so we just need to adapt them to emit lints instead of errors. We emit lints using the lint_node function - you can see an example calls of it below in the function. Remember to add a feature gate.

You'll also want to declare the new lints you are using, which is done in:

declare_lint! {

Just add another declare_lint! for each new lint.

Feature Gates

I should add some version of this to the README.md, but until then:

Also, you'll want to feature gate the new feature, so that it can't be used accidentally until its stabilized. For that, add a feature gate to the list of feature gates here:


And link this tracking issue (#44495). You can test the feature in tcx.sess (e.g. tcx.sess.features.borrow().specialization). If it's not present, you should maintain the old behavior.

Don't forget to add tests, both for the new behavior and the old one (the test that the old behavior remains without a feature gate should be in src/test/compile-fail/feature-gate-YOUR-FEATURE.rs).

@arielb1 arielb1 added E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. and removed E-needs-mentor labels Sep 19, 2017
@Nokel81
Copy link
Contributor

Nokel81 commented Sep 19, 2017

I will now start on the implementation of this

@nikomatsakis
Copy link
Contributor

@Nokel81 just checking in -- how's it going? Any questions?

@Nokel81
Copy link
Contributor

Nokel81 commented Sep 25, 2017

No, school work came up but I should have a PR ready by Wednesday

@davidtwco
Copy link
Member

After discussion with @nikomatsakis in Gitter, I'm going to take a stab at this one.

@Nokel81
Copy link
Contributor

Nokel81 commented Oct 13, 2017

Okay, I just haven't had time to finish my implementation what with school

@davidtwco
Copy link
Member

If you've already started on this then I'm happy to leave it @Nokel81.

@Nokel81
Copy link
Contributor

Nokel81 commented Oct 13, 2017

It looks like I should have some time this weekend to finish it so from a time perspective I would prefer it if I could finish

@davidtwco
Copy link
Member

Sure thing.

@nikomatsakis
Copy link
Contributor

Anybody working on this actively?

@Nokel81
Copy link
Contributor

Nokel81 commented Oct 25, 2017

I am and I have what I believe to be a full solution but I have had trouble compiling rustc because I am on windows with VS2017. I even tried following the instructions for not VS2015 but that didn't seem to work

@nikomatsakis
Copy link
Contributor

@Nokel81 Sorry, missed that message -- perhaps give some more details of the problem you are encountering? (Alternatively, can you point us at your branch..?)

@nikomatsakis
Copy link
Contributor

(Though honestly the best thing is probably to hop on gitter or maybe #rust on IRC and ask about, since I at least don't know much about getting Rust to build on Windows.)

@Nokel81
Copy link
Contributor

Nokel81 commented Nov 1, 2017

Okay thanks. I will try that tomorrow

@nikomatsakis
Copy link
Contributor

@Nokel81 any luck?

@austinbes
Copy link

@Nokel81 If you're still having trouble building, I'm interested in taking a crack at this

@Nokel81
Copy link
Contributor

Nokel81 commented Nov 7, 2017

I believe that I have solved the building problem and should be able to get a PR tonight. Thanks for the offer though.

@rfcbot
Copy link

rfcbot commented Sep 15, 2018

Team member @Centril has proposed to merge this. The next step is review by the rest of the tagged teams:

No concerns currently listed.

Once a majority of reviewers approve (and none object), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Sep 15, 2018
@scottmcm
Copy link
Member

@rfcbot reviewed

That said, I still lean towards deny here. I don't think my "WIP reasoning" is a strong argument for warn here, because there obviously aren't any more alternatives that you could be intending to add later.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Sep 27, 2018
@rfcbot
Copy link

rfcbot commented Sep 27, 2018

🔔 This is now entering its final comment period, as per the review above. 🔔

@rfcbot rfcbot added final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. labels Sep 27, 2018
@Nokel81
Copy link
Contributor

Nokel81 commented Sep 27, 2018

I would lean towards deny for a single if let but warn for multiple if lets because of the set up process that multiple if lets can allow for

@rfcbot
Copy link

rfcbot commented Oct 7, 2018

The final comment period, with a disposition to merge, as per the review above, is now complete.

@rfcbot rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels Oct 7, 2018
@Centril
Copy link
Contributor

Centril commented Oct 7, 2018

@Nokel81 would you be willing to write up a stabilization PR?

@Nokel81
Copy link
Contributor

Nokel81 commented Oct 7, 2018

Sure, however, there was a little discussion on the level. Shall I go with what was proposed in the merge by you (that is Warn instead of Deny)

@Centril
Copy link
Contributor

Centril commented Oct 7, 2018

@Nokel81 Thank you.
What was proposed in the FCP merge proposal; that is: Warn.

@Nokel81
Copy link
Contributor

Nokel81 commented Oct 12, 2018

I will see if I can do this tonight

@Centril
Copy link
Contributor

Centril commented Oct 27, 2018

@Nokel81 any progress? :)

@Nokel81
Copy link
Contributor

Nokel81 commented Oct 27, 2018

@Centril I have made the code change but I wanted to make sure that I could build it before making the PR. My build fails (even without the code change so I think it is something to do with my environment) with the following error

error: failed to run custom build command for `alloc_jemalloc v0.0.0 (/home/sebastian/rust/src/liballoc_jemalloc)`                                      

@Nokel81
Copy link
Contributor

Nokel81 commented Nov 3, 2018

#55639

Would any of you be able to review the stabilization PR?

varkor added a commit to varkor/rust that referenced this issue Jan 12, 2019
This stabilises RFC 2086 (rust-lang#44495).

Co-Authored-By: Sebastian Malton <[email protected]>
Centril added a commit to Centril/rust that referenced this issue Jan 12, 2019
…rns, r=Centril

Stabilise irrefutable if-let and while-let patterns

This stabilises RFC 2086 (rust-lang#44495).

This replaces rust-lang#55639, as we want to stabilise this in time for the beta cut-off.

Closes rust-lang#55639.

r? @Centril
@Centril
Copy link
Contributor

Centril commented Jan 12, 2019

Stabilized in #57535.
Reference issue: rust-lang/reference#507.

Nothing left to do, so closing out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B-RFC-approved Blocker: Approved by a merged RFC but not yet implemented. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. finished-final-comment-period The final comment period is finished for this PR / Issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests