]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_middle/src/ty/mod.rs
Add helper function for Capture Esclations and expressions
[rust.git] / compiler / rustc_middle / src / ty / mod.rs
index 5f2d3b7818e7f9c8d95e907d563121532645b7bb..52b49184cf1869a1d82ff9c60c42d923279f060f 100644 (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