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
if clauses following an if let are compiled to match guards #41272
Optionally, one or more else if (not else if let) blocks can be placed in the same match using pattern guards on _. This could be done to simplify the code when pretty-printing the expansion result. Otherwise, this is an unnecessary transformation.
This doesn't feel like a compelling reason, particularly since the desugaring is not otherwise user visible. I would call this a bug.
This is a great mentoring bug! I'm going to write up some very quick pointers for now. Please reach out for more details. In short, the code that needs to be changed is in the "HIR lowering", which converts from the AST (what the user wrote) to the compiler's internal HIR (also an abstract syntax tree, but somewhat desugared). The code in question is in lowering.rs, specifically right around here. There is also some more logic. You'll want to change how it is desugaring along the lines that @eddyb suggested in this comment.
Activity
eddyb commentedon Apr 13, 2017
Where this happens. I don't know why we do this, the "else" part of "if" or "if-let" is an arbitrary expression:
This seems simpler, less error prone and it won't hit arbitrary limitations specific to
matchguards.nikomatsakis commentedon Apr 13, 2017
The RFC states:
This doesn't feel like a compelling reason, particularly since the desugaring is not otherwise user visible. I would call this a bug.
nikomatsakis commentedon Apr 13, 2017
triage: P-medium
nikomatsakis commentedon Apr 13, 2017
This is a great mentoring bug! I'm going to write up some very quick pointers for now. Please reach out for more details. In short, the code that needs to be changed is in the "HIR lowering", which converts from the AST (what the user wrote) to the compiler's internal HIR (also an abstract syntax tree, but somewhat desugared). The code in question is in lowering.rs, specifically right around here. There is also some more logic. You'll want to change how it is desugaring along the lines that @eddyb suggested in this comment.
cuviper commentedon Apr 14, 2017
I'm interested in taking this bug.
eddyb commentedon Apr 14, 2017
@suchithjn225 Sure thing! Let us know how far you get with #41272 (comment). We're also on IRC.
cuviper commentedon Apr 14, 2017
@suchithjn225 I'll yield to you -- good luck!
Auto merge of #41316 - suchithjn225:issue-41272, r=eddyb
Rollup merge of rust-lang#136536 - DuskyElf:master, r=jieyouxu
Rollup merge of rust-lang#136536 - DuskyElf:master, r=jieyouxu
Rollup merge of rust-lang#136536 - DuskyElf:master, r=jieyouxu
Unrolled build for rust-lang#136536