Add helper function for Capture Esclations and expressions

Co-authored-by: Dhruv Jauhar <dhruvjhr@gmail.com>
This commit is contained in:
Aman Arora 2020-10-17 01:49:11 -04:00
parent 58e8f8fd2c
commit 145312075f
3 changed files with 110 additions and 67 deletions

View file

@ -765,7 +765,23 @@ pub struct UpvarBorrow<'tcx> {
#[derive(PartialEq, Clone, Debug, Copy, TyEncodable, TyDecodable, HashStable)]
pub struct CaptureInfo<'tcx> {
/// Expr Id pointing to use that resulting in selecting the current capture kind
/// Expr Id pointing to use that resulted in selecting the current capture kind
///
/// If the user doesn't enable feature `capture_disjoint_fields` (RFC 2229) then, it is
/// possible that we don't see the use of a particular place resulting in expr_id being
/// None. In such case we fallback on uvpars_mentioned for span.
///
/// Eg:
/// ```rust
/// let x = ...;
///
/// let c = || {
/// let _ = x
/// }
/// ```
///
/// In this example, if `capture_disjoint_fields` is **not** set, then x will be captured,
/// but we won't see it being used during capture analysis, since it's essentially a discard.
pub expr_id: Option<hir::HirId>,
/// Capture mode that was selected