/// All the existential types that are restricted to concrete types
/// by this function
pub concrete_existential_types: FxHashMap<DefId, Ty<'tcx>>,
+
+ /// Given the closure ID this map provides the list of UpvarIDs used by it.
+ /// The upvarID contains the HIR node ID and it also contains the full path
+ /// leading to the member of the struct or tuple that is used instead of the
+ /// entire variable.
+ pub upvar_list: ty::UpvarListMap<'tcx>,
}
impl<'tcx> TypeckTables<'tcx> {
tainted_by_errors: false,
free_region_map: Default::default(),
concrete_existential_types: Default::default(),
+ upvar_list: Default::default(),
}
}
tainted_by_errors,
ref free_region_map,
ref concrete_existential_types,
+ ref upvar_list,
+
} = *self;
hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
tainted_by_errors.hash_stable(hcx, hasher);
free_region_map.hash_stable(hcx, hasher);
concrete_existential_types.hash_stable(hcx, hasher);
+ upvar_list.hash_stable(hcx, hasher);
})
}
}
};
self.tcx.with_freevars(closure_node_id, |freevars| {
+ let mut freevar_list: Vec<ty::UpvarId> = Vec::new();
for freevar in freevars {
let upvar_id = ty::UpvarId {
var_path: ty::UpvarPath {
- hir_id : self.tcx.hir().node_to_hir_id(freevar.var_id()),
+ hir_id: self.tcx.hir().node_to_hir_id(freevar.var_id()),
},
closure_expr_id: LocalDefId::from_def_id(closure_def_id),
};
debug!("seed upvar_id {:?}", upvar_id);
+ freevar_list.push(upvar_id);
let capture_kind = match capture_clause {
hir::CaptureByValue => ty::UpvarCapture::ByValue,
.upvar_capture_map
.insert(upvar_id, capture_kind);
}
+ self.tables
+ .borrow_mut()
+ .upvar_list
+ .insert(closure_def_id, freevar_list);
});
let body_owner_def_id = self.tcx.hir().body_owner_def_id(body.id());
self.param_env,
region_scope_tree,
&self.tables.borrow(),
- ).consume_body(body);
+ )
+ .consume_body(body);
if let Some(closure_substs) = infer_kind {
// Unify the (as yet unbound) type variable in the closure
let var_hir_id = tcx.hir().node_to_hir_id(var_node_id);
let freevar_ty = self.node_ty(var_hir_id);
let upvar_id = ty::UpvarId {
- var_path: ty::UpvarPath {
- hir_id: var_hir_id,
- },
+ var_path: ty::UpvarPath { hir_id: var_hir_id },
closure_expr_id: LocalDefId::from_def_id(closure_def_index),
};
let capture = self.tables.borrow().upvar_capture(upvar_id);
},
),
}
- }).collect()
+ })
+ .collect()
})
}
}