fix: fix the capture behavior of if let in closures#154210
fix: fix the capture behavior of if let in closures#154210Embers-of-the-Fire wants to merge 5 commits intorust-lang:mainfrom
if let in closures#154210Conversation
|
r? @mati865 rustbot has assigned @mati865. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
Could you add a test case that's a bit more like #153982, so that there's also a field that doesn't get captured in the first place? |
|
cc @Nadrieril |
There was a problem hiding this comment.
So, this is technically a breaking change, much like #138961, right? It'd be nice to have a proof-of-concept test on which the borrow checker will start erroring, at which point we'd probably wanna do a crater run...
|
@bors try |
This comment has been minimized.
This comment has been minimized.
…e, r=<try> fix: fix the capture behavior of `if let` in closures
|
I'm wondering which mode we should run crater in. Would |
AFAIK |
|
Since this PR changes the drop order in some cases, it is technically conceivable that some code would have an observable change in behavior after this PR gets merged. It is also technically possible that a crate's test suite would notice this. I would however be extremely surprised if someone has written such code and made a test suite good enough to be able to detect this – previous experience with crater runs for similar adjustments confirms this. If it was my call to make, I'd run a But my call to make it is not. |
|
It can technically change run time behavior by changing drop order. I think that's kind of unlikely to be relied on though. |
|
Based on the discussion above, I'm going with just @craterbot run mode=check-only |
|
👌 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
If this can change runtime behavior (ergo, a stable breaking change), then IMO this definitely justifies a full build-and-test not just check-only. I imagine lang would likewise want as much of the full picture as possible on ecosystem impact when making the accept/reject call. |
|
@craterbot cancel |
|
🗑️ Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
|
I'm not a good person to review it. Does anybody from this thread want to take it over? Thanks in advance. |
There was a problem hiding this comment.
@mati865 I don't have reviewer permissions, but the change looks good to me, and it's touching pretty much the one file in the entire compiler which I'd say I'm actually qualified to review.
Otherwise, I suppose @Nadrieril would surely be familiar with this code?
|
r? me Looks good to me, I am happy to merge implementation-wise. Not sure what to make of the crater run, should we rerun on the spurious results again? |
|
I'm also unsure whether this needs t-lang input: this is clearly a bug in the compiler, where the behavior differs from the merged RFC. I'll tentatively say this is purely t-compiler territory unless the breaking changes are big. |
Signed-off-by: Embers-of-the-Fire <stellarishs@163.com>
def1d0a to
60dd108
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@craterbot run mode=build-and-test crates=https://crater-reports.s3.amazonaws.com/pr-154210-1/retry-regressed-list.txt p=1 |
|
👌 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
I didn't follow the entire discussion but it's labelled as requiring a fcp from lang team. |
|
🚧 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
|
🎉 Experiment
Footnotes
|
|
All the crater regressions I've looked at look unrelated to this PR |
|
@rustbot labels +I-lang-nominated I'm unsure if this a T-lang FCP, but nominated just in case. In edition 2021+, |
View all comments
Closes #153982.
TL;DR This patch adds the missing capture behavior change for
if letstatements introduced in RFC 2229.This patch converts
into
so that
if letnow behaves likelet.