@@ -5,7 +5,8 @@ use rustc_middle::mir::*;
5
5
use crate :: { AnalysisDomain , GenKill , GenKillAnalysis } ;
6
6
7
7
/// A dataflow analysis that tracks whether a pointer or reference could possibly exist that points
8
- /// to a given local.
8
+ /// to a given local. This analysis ignores fake borrows, so it should not be used by
9
+ /// borrowck.
9
10
///
10
11
/// At present, this is used as a very limited form of alias analysis. For example,
11
12
/// `MaybeBorrowedLocals` is used to compute which locals are live during a yield expression for
@@ -91,13 +92,17 @@ where
91
92
self . super_rvalue ( rvalue, location) ;
92
93
93
94
match rvalue {
94
- Rvalue :: AddressOf ( _, borrowed_place) | Rvalue :: Ref ( _, _, borrowed_place) => {
95
+ // We ignore fake borrows as these get removed after analysis and shouldn't effect
96
+ // the layout of generators.
97
+ Rvalue :: AddressOf ( _, borrowed_place)
98
+ | Rvalue :: Ref ( _, BorrowKind :: Mut { .. } | BorrowKind :: Shared , borrowed_place) => {
95
99
if !borrowed_place. is_indirect ( ) {
96
100
self . trans . gen ( borrowed_place. local ) ;
97
101
}
98
102
}
99
103
100
104
Rvalue :: Cast ( ..)
105
+ | Rvalue :: Ref ( _, BorrowKind :: Shallow , _)
101
106
| Rvalue :: ShallowInitBox ( ..)
102
107
| Rvalue :: Use ( ..)
103
108
| Rvalue :: ThreadLocalRef ( ..)
0 commit comments