While type checking a function, the intermediate types for the
expressions, blocks, and so forth contained within the function are
-stored in `fcx.node_types` and `fcx.item_substs`. These types
+stored in `fcx.node_types` and `fcx.node_substs`. These types
may contain unresolved type variables. After type checking is
complete, the functions in the writeback module are used to take the
types from this table, resolve them, and then write them into their
}
}
- pub fn write_substs(&self, node_id: ast::NodeId, substs: ty::ItemSubsts<'tcx>) {
- if !substs.substs.is_noop() {
+ pub fn write_substs(&self, node_id: ast::NodeId, substs: &'tcx Substs<'tcx>) {
+ if !substs.is_noop() {
debug!("write_substs({}, {:?}) in fcx {}",
node_id,
substs,
self.tag());
- self.tables.borrow_mut().item_substs.insert(node_id, substs);
+ self.tables.borrow_mut().node_substs.insert(node_id, substs);
}
}
}
}
- pub fn opt_node_ty_substs<F>(&self,
- id: ast::NodeId,
- f: F) where
- F: FnOnce(&ty::ItemSubsts<'tcx>),
- {
- if let Some(s) = self.tables.borrow().item_substs.get(&id) {
- f(s);
- }
- }
-
/// Registers an obligation for checking later, during regionck, that the type `ty` must
/// outlive the region `r`.
pub fn register_region_obligation(&self,
// We always require that the type provided as the value for
// a type parameter outlives the moment of instantiation.
- self.opt_node_ty_substs(expr.id, |item_substs| {
- self.add_wf_bounds(&item_substs.substs, expr);
- });
+ let substs = self.tables.borrow().node_substs(expr.id);
+ self.add_wf_bounds(substs, expr);
ty
}
let ty = self.local_ty(span, nid);
let ty = self.normalize_associated_types_in(span, &ty);
self.write_ty(node_id, ty);
- self.write_substs(node_id, ty::ItemSubsts {
- substs: self.tcx.intern_substs(&[])
- });
return ty;
}
_ => {}
debug!("instantiate_value_path: type of {:?} is {:?}",
node_id,
ty_substituted);
- self.write_substs(node_id, ty::ItemSubsts {
- substs: substs
- });
+ self.write_substs(node_id, substs);
ty_substituted
}