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
aturon opened this Issue Sep 11, 2017 · 37 comments

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:

@arielb1

This comment has been minimized.

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 and removed E-needs-mentor labels Sep 19, 2017

@Nokel81

This comment has been minimized.

Copy link
Contributor

Nokel81 commented Sep 19, 2017

I will now start on the implementation of this

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Sep 25, 2017

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

@Nokel81

This comment has been minimized.

Copy link
Contributor

Nokel81 commented Sep 25, 2017

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

@davidtwco

This comment has been minimized.

Copy link
Member

davidtwco commented Oct 13, 2017

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

@Nokel81

This comment has been minimized.

Copy link
Contributor

Nokel81 commented Oct 13, 2017

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

@davidtwco

This comment has been minimized.

Copy link
Member

davidtwco commented Oct 13, 2017

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

@Nokel81

This comment has been minimized.

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

This comment has been minimized.

Copy link
Member

davidtwco commented Oct 13, 2017

Sure thing.

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Oct 25, 2017

Anybody working on this actively?

@Nokel81

This comment has been minimized.

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

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Nov 1, 2017

@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

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Nov 1, 2017

(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

This comment has been minimized.

Copy link
Contributor

Nokel81 commented Nov 1, 2017

Okay thanks. I will try that tomorrow

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Nov 7, 2017

@Nokel81 any luck?

@austinbes

This comment has been minimized.

Copy link

austinbes commented Nov 7, 2017

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

@Nokel81

This comment has been minimized.

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.

@Centril

This comment has been minimized.

Copy link
Contributor

Centril commented Sep 15, 2018

@rfcbot merge

This was implemented in #49469 which was merged on 2018-06-26 which was 11 weeks ago (more than enough...). I thus propose that we stabilize it with an amendment to make the default lint level Warn instead of Deny (reasons outlined in #44495 (comment)).

Unstable book:

Tests:

@rfcbot

This comment has been minimized.

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.

@scottmcm

This comment has been minimized.

Copy link
Member

scottmcm commented Sep 27, 2018

@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

This comment has been minimized.

Copy link

rfcbot commented Sep 27, 2018

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

@Nokel81

This comment has been minimized.

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

This comment has been minimized.

Copy link

rfcbot commented Oct 7, 2018

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

@Centril

This comment has been minimized.

Copy link
Contributor

Centril commented Oct 7, 2018

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

@Nokel81

This comment has been minimized.

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

This comment has been minimized.

Copy link
Contributor

Centril commented Oct 7, 2018

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

@Nokel81

This comment has been minimized.

Copy link
Contributor

Nokel81 commented Oct 12, 2018

I will see if I can do this tonight

@Centril

This comment has been minimized.

Copy link
Contributor

Centril commented Oct 27, 2018

@Nokel81 any progress? :)

@Nokel81

This comment has been minimized.

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

This comment has been minimized.

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

Stabilise irrefutable if-let and while-let patterns
This stabilises RFC 2086 (rust-lang#44495).

Co-Authored-By: Sebastian Malton <sebastian@malton.name>

bors added a commit that referenced this issue Jan 12, 2019

Auto merge of #57535 - varkor:stabilise-if-while-let-patterns, r=Centril
Stabilise irrefutable if-let and while-let patterns

This stabilises RFC 2086 (#44495).

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

Closes #55639.

r? @Centril

Centril added a commit to Centril/rust that referenced this issue Jan 12, 2019

Rollup merge of rust-lang#57535 - varkor:stabilise-if-while-let-patte…
…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

This comment has been minimized.

Copy link
Contributor

Centril commented Jan 12, 2019

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

Nothing left to do, so closing out.

@Centril Centril closed this Jan 12, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.