@@ -5,7 +5,8 @@ use rustc_middle::mir::*;
55use crate :: { AnalysisDomain , GenKill , GenKillAnalysis } ;
66
77/// 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.
910///
1011/// At present, this is used as a very limited form of alias analysis. For example,
1112/// `MaybeBorrowedLocals` is used to compute which locals are live during a yield expression for
@@ -91,13 +92,17 @@ where
9192 self . super_rvalue ( rvalue, location) ;
9293
9394 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) => {
9599 if !borrowed_place. is_indirect ( ) {
96100 self . trans . gen ( borrowed_place. local ) ;
97101 }
98102 }
99103
100104 Rvalue :: Cast ( ..)
105+ | Rvalue :: Ref ( _, BorrowKind :: Shallow , _)
101106 | Rvalue :: ShallowInitBox ( ..)
102107 | Rvalue :: Use ( ..)
103108 | Rvalue :: ThreadLocalRef ( ..)
0 commit comments