addressing Niko's comments
This commit is contained in:
parent
15d8e8fb2b
commit
69e491815d
@ -647,9 +647,15 @@ fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>,
|
||||
let fn_def_id = tcx_hir.local_def_id(fn_id);
|
||||
|
||||
// Gather the upvars of a closure, if any.
|
||||
let upvar_decls: Vec<_> = match hir_tables.upvar_list.get(&fn_def_id) {
|
||||
Some(upvars) => upvars
|
||||
.iter()
|
||||
// In analyze_closure() in upvar.rs we gathered a list of upvars used by a
|
||||
// closure and we stored in a map called upvar_list in TypeckTables indexed
|
||||
// with the closure's DefId. Here, we run through that vec of UpvarIds for
|
||||
// the given closure and use the necessary information to create UpvarDecl.
|
||||
let upvar_decls: Vec<_> = hir_tables
|
||||
.upvar_list
|
||||
.get(&fn_def_id)
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.map(|upvar_id| {
|
||||
let var_hir_id = upvar_id.var_path.hir_id;
|
||||
let var_node_id = tcx_hir.hir_to_node_id(var_hir_id);
|
||||
@ -680,9 +686,7 @@ fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>,
|
||||
}
|
||||
decl
|
||||
})
|
||||
.collect(),
|
||||
_ => vec![],
|
||||
};
|
||||
.collect();
|
||||
|
||||
let mut builder = Builder::new(hir,
|
||||
span,
|
||||
|
@ -20,16 +20,16 @@ use syntax_pos::Span;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Entry point
|
||||
/// During type inference, partially inferred types are
|
||||
/// represented using Type variables (ty::Infer). These don't appear in
|
||||
/// the final TypeckTables since all of the types should have been
|
||||
/// inferred once typeck_tables_of is done.
|
||||
/// When type inference is running however, having to update the typeck
|
||||
/// tables every time a new type is inferred would be unreasonably slow,
|
||||
/// so instead all of the replacement happens at the end in
|
||||
/// resolve_type_vars_in_body, which creates a new TypeTables which
|
||||
/// doesn't contain any inference types.
|
||||
|
||||
// During type inference, partially inferred types are
|
||||
// represented using Type variables (ty::Infer). These don't appear in
|
||||
// the final TypeckTables since all of the types should have been
|
||||
// inferred once typeck_tables_of is done.
|
||||
// When type inference is running however, having to update the typeck
|
||||
// tables every time a new type is inferred would be unreasonably slow,
|
||||
// so instead all of the replacement happens at the end in
|
||||
// resolve_type_vars_in_body, which creates a new TypeTables which
|
||||
// doesn't contain any inference types.
|
||||
impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
pub fn resolve_type_vars_in_body(&self, body: &'gcx hir::Body) -> &'gcx ty::TypeckTables<'gcx> {
|
||||
let item_id = self.tcx.hir().body_owner(body.id());
|
||||
|
Loading…
Reference in New Issue
Block a user