Add projections check to EUV for escape analysis
This commit is contained in:
parent
b2523afae4
commit
604e6ba0e2
@ -106,14 +106,13 @@ fn is_argument(map: &hir::map::Map<'_>, id: HirId) -> bool {
|
||||
|
||||
impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
|
||||
fn consume(&mut self, cmt: &Place<'tcx>, mode: ConsumeMode) {
|
||||
if cmt.projections.is_empty() {
|
||||
if let PlaceBase::Local(lid) = cmt.base {
|
||||
if let ConsumeMode::Move = mode {
|
||||
// moved out or in. clearly can't be localized
|
||||
self.set.remove(&lid);
|
||||
}
|
||||
}
|
||||
let map = &self.cx.tcx.hir();
|
||||
if let PlaceBase::Local(lid) = cmt.base {
|
||||
if let Some(Node::Binding(_)) = map.find(cmt.hir_id) {
|
||||
if self.set.contains(&lid) {
|
||||
// let y = x where x is known
|
||||
@ -124,14 +123,18 @@ fn consume(&mut self, cmt: &Place<'tcx>, mode: ConsumeMode) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn borrow(&mut self, cmt: &Place<'tcx>, _: ty::BorrowKind) {
|
||||
if cmt.projections.is_empty() {
|
||||
if let PlaceBase::Local(lid) = cmt.base {
|
||||
self.set.remove(&lid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn mutate(&mut self, cmt: &Place<'tcx>) {
|
||||
if cmt.projections.is_empty() {
|
||||
let map = &self.cx.tcx.hir();
|
||||
if is_argument(map, cmt.hir_id) {
|
||||
// Skip closure arguments
|
||||
@ -146,6 +149,7 @@ fn mutate(&mut self, cmt: &Place<'tcx>) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> EscapeDelegate<'a, 'tcx> {
|
||||
|
Loading…
Reference in New Issue
Block a user