Commit fa62fbe
authored
Rollup merge of rust-lang#137257 - compiler-errors:fake-borrow-of-packed-field, r=oli-obk
Ignore fake borrows for packed field check
We should not emit unaligned packed field reference errors for the fake borrows that we generate during match lowering.
These fake borrows are there to ensure in *borrow-checking* that we don't modify the value being matched (which is why this only occurs when there's a match guard, in this case `if true`), but they are removed after the MIR is processed by `CleanupPostBorrowck`, since they're really just there to cause borrowck errors if necessary.
I modified `PlaceContext::is_borrow` since that's used by the packed field check:
https://github.com/rust-lang/rust/blob/17c1c329a5512d718b67ef6797538b154016cd34/compiler/rustc_mir_transform/src/check_packed_ref.rs#L40
It's only used in one other place, in the SROA optimization (by which fake borrows are removed, so it doesn't matter):
https://github.com/rust-lang/rust/blob/17c1c329a5512d718b67ef6797538b154016cd34/compiler/rustc_mir_dataflow/src/value_analysis.rs#L922
Fixes rust-lang#137250File tree
2 files changed
+31
-4
lines changed- compiler/rustc_middle/src/mir
- tests/ui/lint
2 files changed
+31
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1364 | 1364 | | |
1365 | 1365 | | |
1366 | 1366 | | |
1367 | | - | |
| 1367 | + | |
| 1368 | + | |
1368 | 1369 | | |
1369 | 1370 | | |
1370 | 1371 | | |
1371 | | - | |
1372 | | - | |
1373 | | - | |
| 1372 | + | |
| 1373 | + | |
1374 | 1374 | | |
1375 | 1375 | | |
1376 | 1376 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
0 commit comments