about summary refs log tree commit diff
diff options
context:
space:
mode:
authorcsmoe <csmoe@msn.com>2019-10-17 00:57:18 +0800
committercsmoe <csmoe@msn.com>2019-12-18 18:30:22 +0800
commitc1241bf7a71ed5175274d33516a29f1c4fe5a3a0 (patch)
tree123628666fb7032e0105f62abb05223a34f014e3
parent3ed3b8bb7b100afecf7d5f52eafbb70fec27f537 (diff)
downloadrust-c1241bf7a71ed5175274d33516a29f1c4fe5a3a0.tar.gz
rust-c1241bf7a71ed5175274d33516a29f1c4fe5a3a0.zip
add debuginfo in generator_interior
-rw-r--r--src/librustc/hir/mod.rs16
-rw-r--r--src/librustc_typeck/check/generator_interior.rs12
2 files changed, 22 insertions, 6 deletions
diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs
index 6b354b01518..474b5e33c2a 100644
--- a/src/librustc/hir/mod.rs
+++ b/src/librustc/hir/mod.rs
@@ -1857,6 +1857,22 @@ impl fmt::Display for YieldSource {
     }
 }
 
+impl core::convert::From<GeneratorKind> for YieldSource {
+    fn from(gen_kind: GeneratorKind) -> Self {
+        match gen_kind {
+            // Guess based on the kind of the current generator.
+            GeneratorKind::Gen => Self::Yield,
+            GeneratorKind::Async(_) => Self::Await,
+        }
+    }
+}
+
+#[derive(Copy, Clone, RustcEncodable, RustcDecodable, Debug, HashStable)]
+pub enum CaptureClause {
+    CaptureByValue,
+    CaptureByRef,
+}
+
 // N.B., if you change this, you'll probably want to change the corresponding
 // type structure in middle/ty.rs as well.
 #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)]
diff --git a/src/librustc_typeck/check/generator_interior.rs b/src/librustc_typeck/check/generator_interior.rs
index fcf6b22f74f..35d73d56964 100644
--- a/src/librustc_typeck/check/generator_interior.rs
+++ b/src/librustc_typeck/check/generator_interior.rs
@@ -32,7 +32,6 @@ impl<'a, 'tcx> InteriorVisitor<'a, 'tcx> {
         debug!("generator_interior: attempting to record type {:?} {:?} {:?} {:?}",
                ty, scope, expr, source_span);
 
-
         let live_across_yield = scope.map(|s| {
             self.region_scope_tree.yield_in_scope(s).and_then(|yield_data| {
                 // If we are recording an expression that is the last yield
@@ -54,15 +53,11 @@ impl<'a, 'tcx> InteriorVisitor<'a, 'tcx> {
         }).unwrap_or_else(|| Some(YieldData {
             span: DUMMY_SP,
             expr_and_pat_count: 0,
-            source: match self.kind { // Guess based on the kind of the current generator.
-                hir::GeneratorKind::Gen => hir::YieldSource::Yield,
-                hir::GeneratorKind::Async(_) => hir::YieldSource::Await,
-            },
+            source: self.kind.into(),
         }));
 
         if let Some(yield_data) = live_across_yield {
             let ty = self.fcx.resolve_vars_if_possible(&ty);
-
             debug!("type in expr = {:?}, scope = {:?}, type = {:?}, count = {}, yield_span = {:?}",
                    expr, scope, ty, self.expr_count, yield_data.span);
 
@@ -94,6 +89,11 @@ impl<'a, 'tcx> InteriorVisitor<'a, 'tcx> {
         } else {
             debug!("no type in expr = {:?}, count = {:?}, span = {:?}",
                    expr, self.expr_count, expr.map(|e| e.span));
+            let ty = self.fcx.resolve_vars_if_possible(&ty);
+            if let Some((unresolved_type, unresolved_type_span)) = self.fcx.unresolved_type_vars(&ty) {
+                debug!("remained unresolved_type = {:?}, unresolved_type_span: {:?}",
+                    unresolved_type, unresolved_type_span);
+            }
         }
     }
 }