1
Fork 0

Remove Upvar duplication

This cuts out an extra allocation and copying over from the already
cached closure capture information.
This commit is contained in:
Mark Rousskov 2023-11-26 08:39:57 -05:00
parent 3166210d68
commit d920dd8d38
10 changed files with 35 additions and 50 deletions

View file

@ -247,6 +247,13 @@ impl<'tcx> CapturedPlace<'tcx> {
.span
}
}
pub fn is_by_ref(&self) -> bool {
match self.info.capture_kind {
ty::UpvarCapture::ByValue => false,
ty::UpvarCapture::ByRef(..) => true,
}
}
}
#[derive(Copy, Clone, Debug, HashStable)]