reference
reference copied to clipboard
Update rust reference info about closures
This PR updates the closure types page so it includes up to date information on the new behavior introduced by RFC2229/Edition 2021
cc: @arora-aman r? @nikomatsakis
Closes #1066
@roxelo / @arora-aman / @nikomatsakis Is there an update on how this is going? It looks like niko left some comments that may not have been addressed?
@roxelo / @arora-aman / @nikomatsakis Is there an update on how this is going? It looks like niko left some comments that may not have been addressed?
@ehuss I think they have been addressed, github didn't auto resolve them because lines were added instead of them being changed.
There was one style change that josh left that I have now committed. Hopefully tests pass given Edition 2021 has been stabilized
I should have time tomorrow to fix the style errors.
Just saw this now, can help if needed @arora-aman
@Veykril or @HKalbasi Would either of you be interested in helping to get this PR over the line? Are either of you familiar with how they are implemented? I am not familiar with how closures are implemented in rustc. I could start reviewing all of the RFC 2229 PR's and reviewing all of the current implementation, but I have been dragging because that sounds like weeks of work. It would help to have someone else to ask questions to and to help with reviewing.
I guess I can help since I reimplemented this in rust-analyzer and got more or less familiar with the rustc implementation. What should I do?
Thanks! I'm not sure exactly how to make progress, but perhaps some questions might help to get started:
- Have you carefully reviewed this PR? If not, would you be willing to give it a detailed examination? Are there any details missing?
- Can you point me to a rough outline of the areas in rustc that I would need to look at to understand the text of this PR?
- How difficult do you think it would be for me to figure it out? I'm moderately familiar with rustc, but not this area (nor type inference or type checking, which I'm not sure is relevant here). I'm not sure if I'm vastly over- or under-estimating how hard this is to review.
I can try to review the comment you left and push changes where I feel confident in them, but if I end up having questions it would be helpful to have someone to ask.
Hopefully there aren't too many gray areas where it isn't clear if some behavior was intended or not.
Have you carefully reviewed this PR? If not, would you be willing to give it a detailed examination? Are there any details missing?
Not yet, but will do it in the following days when I found time.
Can you point me to a rough outline of the areas in rustc that I would need to look at to understand the text of this PR?
The whole thing happens in expr_use_visitor.rs and upvars.rs. The entry point is the analyze_closure in upvars.rs, which calls ExprUseVisitor::consume_body to collect all of the places, and then aggregates them, applies some changes and optimizations, trims the places in old editions and computes the closure kind.
How difficult do you think it would be for me to figure it out? I'm moderately familiar with rustc, but not this area (nor type inference or type checking, which I'm not sure is relevant here). I'm not sure if I'm vastly over- or under-estimating how hard this is to review.
It's pretty straightforward, specially if you are familiar with the Place concept. I think you won't have difficulties in finding the corresponding code for any part of text, but checking that if every small detail is covered might becomes a little difficult.