Hello!
Just stumbled upon disjoint capture : Rust Playground produces
4
0
1
The answer is 42
2
3
5
on 2021 edition, while 2015 and 2018 produce
4
0
1
2
3
5
I understand why this optimization was introduced. But. Shouldn't it produce warning? Cases like Send
, Sync
etc. can be tracked by compiler. But moving drop
execution point simply breaks code in certain cases. At runtime.
UPDATE: If you replace u32
with any non-copy type like string, it works just as expected: Rust Playground . Looks like footgun to me.
Thanks
2 Likes
Could be a hole in the rust_2021_incompatible_closure_captures
, or at least, I couldn't get that lint to fire.
Perhaps related to this:
opened 02:33PM - 17 Aug 21 UTC
A-closures
T-compiler
A-edition-2021
In a small crater run for the 2021 edition migrations, a few problems shows up w… ith closures no longer compiling after migration:
- https://crater-reports.s3.amazonaws.com/pr-87190-2/try%23d8627d19850b63702b76089d7b055730e9ddca14/reg/finality-grandpa-0.14.3/log.txt
- https://crater-reports.s3.amazonaws.com/pr-87190-2/try%23d8627d19850b63702b76089d7b055730e9ddca14/reg/tantivy-0.15.3/log.txt
- https://crater-reports.s3.amazonaws.com/pr-87190-2/try%23d8627d19850b63702b76089d7b055730e9ddca14/reg/tetsy-finality-grandpa-0.13.0/log.txt
3 Likes
system
Closed
July 25, 2023, 7:41pm
3
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.