Commit 6e5b49a
committed
no_consume_or_assign ref_element_addr should not have any destroys
This fixes an issue when doing move-checking on a read accessor,
where the field is only borrowed. After the MoveOnlyAddressChecker
ran on it, it'd inject a destroy that didn't get "claimed":
```
%2 = ref_element_addr %0 : $ListOfFiles, #ListOfFiles.file
%3 = mark_must_check [no_consume_or_assign] %2 : $*File
%4 = begin_access [read] [dynamic] %3 : $*File
%5 = load_borrow %4 : $*File
yield %5 : $File, resume bb1, unwind bb2
bb1:
end_borrow %5 : $File
end_access %4 : $*File
destroy_addr %2 : $*File // BAD
%9 = tuple ()
return %9 : $()
```
The approach of this fix is to recognize that at the point we're
injecting destroys, we would have emitted diagnostics and stopped
already if there were any consuming uses that we need to clean-up
after, since we're in `no_consume_or_assign` checking mode here
when just reading the field.1 parent 355b7dc commit 6e5b49a
1 file changed
+16
-2
lines changedLines changed: 16 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
959 | 959 | | |
960 | 960 | | |
961 | 961 | | |
962 | | - | |
| 962 | + | |
| 963 | + | |
963 | 964 | | |
964 | 965 | | |
965 | 966 | | |
| |||
1845 | 1846 | | |
1846 | 1847 | | |
1847 | 1848 | | |
| 1849 | + | |
1848 | 1850 | | |
1849 | 1851 | | |
1850 | 1852 | | |
1851 | 1853 | | |
| 1854 | + | |
| 1855 | + | |
| 1856 | + | |
| 1857 | + | |
| 1858 | + | |
| 1859 | + | |
| 1860 | + | |
| 1861 | + | |
| 1862 | + | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
1852 | 1866 | | |
1853 | 1867 | | |
1854 | 1868 | | |
| |||
2113 | 2127 | | |
2114 | 2128 | | |
2115 | 2129 | | |
2116 | | - | |
| 2130 | + | |
2117 | 2131 | | |
2118 | 2132 | | |
2119 | 2133 | | |
| |||
0 commit comments