You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Tracking issue for RFC 2086: Allow Irrefutable Patterns in if-let and while-let statements #44495
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:
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).
@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)`
Activity
arielb1 commentedon Sep 19, 2017
Mentoring Instructions
This is actually an easy one:
The code that emits the error message is the
check_armsfunction here:rust/src/librustc_const_eval/check_match.rs
Line 317 in 325ba23
It nicely contains branches for
if letandwhile let, so we just need to adapt them to emit lints instead of errors. We emit lints using thelint_nodefunction - 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:
rust/src/librustc/lint/builtin.rs
Line 19 in 325ba23
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:
rust/src/libsyntax/feature_gate.rs
Line 388 in 325ba23
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).Nokel81 commentedon Sep 19, 2017
I will now start on the implementation of this
nikomatsakis commentedon Sep 25, 2017
@Nokel81 just checking in -- how's it going? Any questions?
Nokel81 commentedon Sep 25, 2017
No, school work came up but I should have a PR ready by Wednesday
35 remaining items
rfcbot commentedon Oct 7, 2018
The final comment period, with a disposition to merge, as per the review above, is now complete.
Centril commentedon Oct 7, 2018
@Nokel81 would you be willing to write up a stabilization PR?
Nokel81 commentedon 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
Warninstead ofDeny)Centril commentedon Oct 7, 2018
@Nokel81 Thank you.
What was proposed in the FCP merge proposal; that is:
Warn.Nokel81 commentedon Oct 12, 2018
I will see if I can do this tonight
Centril commentedon Oct 27, 2018
@Nokel81 any progress? :)
Nokel81 commentedon 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
Nokel81 commentedon Nov 3, 2018
#55639
Would any of you be able to review the stabilization PR?
Stabilise irrefutable if-let and while-let patterns
Rollup merge of rust-lang#57535 - varkor:stabilise-if-while-let-patte…
Centril commentedon Jan 12, 2019
Stabilized in #57535.
Reference issue: rust-lang/reference#507.
Nothing left to do, so closing out.