Commit 3488082
committed
Compute mutability of closure captures
When `capture_disjoint_fields` is not enabled, checking if the root variable
binding is mutable would suffice.
However with the feature enabled, the captured place might be mutable
because it dereferences a mutable reference.
This PR computes the mutability of each capture after capture analysis
in rustc_typeck. We store this in `ty::CapturedPlace` and then use
`ty::CapturedPlace::mutability` in mir_build and borrow_check.1 parent b421cd5 commit 3488082
4 files changed
+60
-22
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
661 | 661 | | |
662 | 662 | | |
663 | 663 | | |
664 | | - | |
| 664 | + | |
665 | 665 | | |
666 | 666 | | |
| 667 | + | |
667 | 668 | | |
| 669 | + | |
| 670 | + | |
668 | 671 | | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
669 | 675 | | |
670 | 676 | | |
671 | 677 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
173 | | - | |
| 173 | + | |
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
| 177 | + | |
182 | 178 | | |
183 | | - | |
184 | 179 | | |
185 | 180 | | |
186 | 181 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
851 | 851 | | |
852 | 852 | | |
853 | 853 | | |
854 | | - | |
| 854 | + | |
855 | 855 | | |
856 | 856 | | |
857 | 857 | | |
858 | 858 | | |
859 | 859 | | |
860 | 860 | | |
861 | | - | |
862 | | - | |
863 | | - | |
864 | | - | |
865 | | - | |
866 | | - | |
867 | | - | |
868 | | - | |
869 | | - | |
870 | 861 | | |
871 | 862 | | |
872 | 863 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
252 | 252 | | |
253 | 253 | | |
254 | 254 | | |
255 | | - | |
256 | | - | |
| 255 | + | |
| 256 | + | |
257 | 257 | | |
258 | 258 | | |
259 | 259 | | |
| |||
423 | 423 | | |
424 | 424 | | |
425 | 425 | | |
426 | | - | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
427 | 429 | | |
428 | 430 | | |
429 | 431 | | |
| |||
486 | 488 | | |
487 | 489 | | |
488 | 490 | | |
| 491 | + | |
489 | 492 | | |
490 | | - | |
| 493 | + | |
491 | 494 | | |
492 | 495 | | |
493 | 496 | | |
| |||
607 | 610 | | |
608 | 611 | | |
609 | 612 | | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
610 | 656 | | |
611 | 657 | | |
612 | 658 | | |
| |||
0 commit comments