]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_typeck/check/generator_interior.rs
update async-await send/sync test
[rust.git] / src / librustc_typeck / check / generator_interior.rs
index f004d04fdfeba1528ce02c75e90d6c0ac9003d32..7185de76fcbb6184324fe01f3325c72a391b0fb2 100644 (file)
@@ -4,19 +4,21 @@
 //! types computed here.
 
 use super::FnCtxt;
-use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor};
+use rustc::hir::map::Map;
 use rustc::middle::region::{self, YieldData};
 use rustc::ty::{self, Ty};
 use rustc_data_structures::fx::FxHashMap;
 use rustc_hir as hir;
 use rustc_hir::def::{CtorKind, DefKind, Res};
 use rustc_hir::def_id::DefId;
+use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
 use rustc_hir::{Expr, ExprKind, Pat, PatKind};
 use rustc_span::Span;
 
 struct InteriorVisitor<'a, 'tcx> {
     fcx: &'a FnCtxt<'a, 'tcx>,
     types: FxHashMap<ty::GeneratorInteriorTypeCause<'tcx>, usize>,
+    exprs: Vec<Option<hir::HirId>>,
     region_scope_tree: &'tcx region::ScopeTree,
     expr_count: usize,
     kind: hir::GeneratorKind,
@@ -98,6 +100,7 @@ fn record(
                         scope_span,
                     })
                     .or_insert(entries);
+                self.exprs.push(expr.map(|e| e.hir_id));
             }
         } else {
             debug!(
@@ -135,6 +138,7 @@ pub fn resolve_interior<'a, 'tcx>(
         expr_count: 0,
         kind,
         prev_unresolved_span: None,
+        exprs: vec![],
     };
     intravisit::walk_body(&mut visitor, body);
 
@@ -169,7 +173,8 @@ pub fn resolve_interior<'a, 'tcx>(
     });
 
     // Store the generator types and spans into the tables for this generator.
-    let interior_types = types.iter().map(|t| t.0.clone()).collect::<Vec<_>>();
+    let interior_types =
+        types.iter().zip(visitor.exprs).map(|(t, e)| (t.0.clone(), e)).collect::<Vec<_>>();
     visitor.fcx.inh.tables.borrow_mut().generator_interior_types = interior_types;
 
     // Extract type components
@@ -193,7 +198,9 @@ pub fn resolve_interior<'a, 'tcx>(
 // librustc/middle/region.rs since `expr_count` is compared against the results
 // there.
 impl<'a, 'tcx> Visitor<'tcx> for InteriorVisitor<'a, 'tcx> {
-    fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
+    type Map = Map<'tcx>;
+
+    fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
         NestedVisitorMap::None
     }