File tree Expand file tree Collapse file tree 2 files changed +31
-4
lines changed
compiler/rustc_middle/src/mir Expand file tree Collapse file tree 2 files changed +31
-4
lines changed Original file line number Diff line number Diff line change @@ -1364,13 +1364,13 @@ impl PlaceContext {
13641364 matches ! ( self , PlaceContext :: MutatingUse ( MutatingUseContext :: Drop ) )
13651365 }
13661366
1367- /// Returns `true` if this place context represents a borrow.
1367+ /// Returns `true` if this place context represents a borrow, excluding fake borrows
1368+ /// (which are an artifact of borrowck and not actually borrows in runtime MIR).
13681369 pub fn is_borrow ( self ) -> bool {
13691370 matches ! (
13701371 self ,
1371- PlaceContext :: NonMutatingUse (
1372- NonMutatingUseContext :: SharedBorrow | NonMutatingUseContext :: FakeBorrow
1373- ) | PlaceContext :: MutatingUse ( MutatingUseContext :: Borrow )
1372+ PlaceContext :: NonMutatingUse ( NonMutatingUseContext :: SharedBorrow )
1373+ | PlaceContext :: MutatingUse ( MutatingUseContext :: Borrow )
13741374 )
13751375 }
13761376
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