File tree 2 files changed +29
-3
lines changed
compiler/rustc_middle/src/mir
2 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -1394,9 +1394,8 @@ impl PlaceContext {
1394
1394
pub fn is_borrow ( self ) -> bool {
1395
1395
matches ! (
1396
1396
self ,
1397
- PlaceContext :: NonMutatingUse (
1398
- NonMutatingUseContext :: SharedBorrow | NonMutatingUseContext :: FakeBorrow
1399
- ) | PlaceContext :: MutatingUse ( MutatingUseContext :: Borrow )
1397
+ PlaceContext :: NonMutatingUse ( NonMutatingUseContext :: SharedBorrow )
1398
+ | PlaceContext :: MutatingUse ( MutatingUseContext :: Borrow )
1400
1399
)
1401
1400
}
1402
1401
Original file line number Diff line number Diff line change
1
+ //@ check-pass
2
+
3
+ // Regression test for <https://github.com/rust-lang/rust/issues/137250>.
4
+
5
+ // Ensure that we don't emit unaligned packed field reference errors for the fake
6
+ // borrows that we generate during match lowering. These fake borrows are there to
7
+ // ensure in *borrow-checking* that we don't modify the value being matched, but
8
+ // they are removed after the MIR is processed by `CleanupPostBorrowck`.
9
+
10
+ #[ repr( packed) ]
11
+ pub struct Packed ( i32 ) ;
12
+
13
+ fn f ( x : Packed ) {
14
+ match & x {
15
+ Packed ( 4 ) => { } ,
16
+ _ if true => { } ,
17
+ _ => { }
18
+ }
19
+
20
+ match x {
21
+ Packed ( 4 ) => { } ,
22
+ _ if true => { } ,
23
+ _ => { }
24
+ }
25
+ }
26
+
27
+ fn main ( ) { }
You can’t perform that action at this time.
0 commit comments