about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc/hir/mod.rs12
-rw-r--r--src/librustc_typeck/check/generator_interior.rs11
2 files changed, 12 insertions, 11 deletions
diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs
index 474b5e33c2a..2cffcc5bfad 100644
--- a/src/librustc/hir/mod.rs
+++ b/src/librustc/hir/mod.rs
@@ -1857,9 +1857,9 @@ impl fmt::Display for YieldSource {
     }
 }
 
-impl core::convert::From<GeneratorKind> for YieldSource {
-    fn from(gen_kind: GeneratorKind) -> Self {
-        match gen_kind {
+impl From<GeneratorKind> for YieldSource {
+    fn from(kind: GeneratorKind) -> Self {
+        match kind {
             // Guess based on the kind of the current generator.
             GeneratorKind::Gen => Self::Yield,
             GeneratorKind::Async(_) => Self::Await,
@@ -1867,12 +1867,6 @@ impl core::convert::From<GeneratorKind> for YieldSource {
     }
 }
 
-#[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 35d73d56964..607efca88dd 100644
--- a/src/librustc_typeck/check/generator_interior.rs
+++ b/src/librustc_typeck/check/generator_interior.rs
@@ -19,6 +19,7 @@ struct InteriorVisitor<'a, 'tcx> {
     region_scope_tree: &'tcx region::ScopeTree,
     expr_count: usize,
     kind: hir::GeneratorKind,
+    prev_unresolved_span: Option<Span>,
 }
 
 impl<'a, 'tcx> InteriorVisitor<'a, 'tcx> {
@@ -69,9 +70,12 @@ impl<'a, 'tcx> InteriorVisitor<'a, 'tcx> {
                                    yield_data.source);
 
                 // If unresolved type isn't a ty_var then unresolved_type_span is None
+                let span = self.prev_unresolved_span.unwrap_or_else(
+                    || unresolved_type_span.unwrap_or(source_span)
+                );
                 self.fcx.need_type_info_err_in_generator(
                     self.kind,
-                    unresolved_type_span.unwrap_or(source_span),
+                    span,
                     unresolved_type,
                 )
                     .span_note(yield_data.span, &*note)
@@ -90,9 +94,11 @@ impl<'a, 'tcx> InteriorVisitor<'a, 'tcx> {
             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) {
+            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);
+                self.prev_unresolved_span = unresolved_type_span;
             }
         }
     }
@@ -112,6 +118,7 @@ pub fn resolve_interior<'a, 'tcx>(
         region_scope_tree: fcx.tcx.region_scope_tree(def_id),
         expr_count: 0,
         kind,
+        prev_unresolved_span: None,
     };
     intravisit::walk_body(&mut visitor, body);