Some(self.tcx.closure_kind(def_id))
}
- pub fn closure_type(&self,
- def_id: DefId,
- substs: ty::ClosureSubsts<'tcx>)
- -> ty::PolyFnSig<'tcx>
- {
+ pub fn closure_type(&self, def_id: DefId) -> ty::PolyFnSig<'tcx> {
if let InferTables::InProgress(tables) = self.tables {
if let Some(id) = self.tcx.hir.as_local_node_id(def_id) {
- if let Some(ty) = tables.borrow().closure_tys.get(&id) {
- return ty.subst(self.tcx, substs.substs);
+ if let Some(&ty) = tables.borrow().closure_tys.get(&id) {
+ return ty;
}
}
}
- self.tcx.closure_type(def_id, substs)
+ self.tcx.closure_type(def_id)
}
}
body: &hir::Body)
{
let fn_ty = self.ir.tcx.item_type(self.ir.tcx.hir.local_def_id(id));
- let fn_ret = match fn_ty.sty {
- ty::TyClosure(closure_def_id, substs) =>
- self.ir.tcx.closure_type(closure_def_id, substs).output(),
- _ => fn_ty.fn_ret()
+ let fn_sig = match fn_ty.sty {
+ ty::TyClosure(closure_def_id, substs) => {
+ self.ir.tcx.closure_type(closure_def_id)
+ .subst(self.ir.tcx, substs.substs)
+ }
+ _ => fn_ty.fn_sig()
};
+ let fn_ret = fn_sig.output();
+
// within the fn body, late-bound regions are liberated
// and must outlive the *call-site* of the function.
let fn_ret =
-> Progress<'tcx>
{
let closure_typer = selcx.closure_typer();
- let closure_type = closure_typer.closure_type(vtable.closure_def_id, vtable.substs);
+ let closure_type = closure_typer.closure_type(vtable.closure_def_id)
+ .subst(selcx.tcx(), vtable.substs.substs);
let Normalized {
value: closure_type,
obligations
substs: ty::ClosureSubsts<'tcx>)
-> ty::PolyTraitRef<'tcx>
{
- let closure_type = self.infcx.closure_type(closure_def_id, substs);
+ let closure_type = self.infcx.closure_type(closure_def_id)
+ .subst(self.tcx(), substs.substs);
let ty::Binder((trait_ref, _)) =
self.tcx().closure_trait_ref_and_return_type(obligation.predicate.def_id(),
obligation.predicate.0.self_ty(), // (1)
self.maps.closure_kind(self, def_id)
}
- pub fn closure_type(self,
- def_id: DefId,
- substs: ClosureSubsts<'tcx>)
- -> ty::PolyFnSig<'tcx>
- {
- if let Some(ty) = self.maps.closure_type.borrow().get(&def_id) {
- return ty.subst(self, substs.substs);
- }
-
- self.maps.closure_type(self, def_id).subst(self, substs.substs)
+ pub fn closure_type(self, def_id: DefId) -> ty::PolyFnSig<'tcx> {
+ self.maps.closure_type(self, def_id)
}
/// Given the def_id of an impl, return the def_id of the trait it implements.
let data = ClosureData {
kind: tcx.closure_kind(def_id),
- ty: self.lazy(&tcx.maps.closure_type.borrow()[&def_id]),
+ ty: self.lazy(&tcx.closure_type(def_id)),
};
Entry {
use llvm::{self, ValueRef, get_params};
use rustc::hir::def_id::DefId;
-use rustc::ty::subst::Substs;
+use rustc::ty::subst::{Substs, Subst};
use rustc::traits;
use abi::{Abi, FnType};
use attributes;
let ref_closure_ty = tcx.mk_imm_ref(tcx.mk_region(ty::ReErased), closure_ty);
// Make a version with the type of by-ref closure.
- let sig = tcx.closure_type(def_id, substs);
+ let sig = tcx.closure_type(def_id).subst(tcx, substs.substs);
let sig = tcx.erase_late_bound_regions_and_normalize(&sig);
assert_eq!(sig.abi, Abi::RustCall);
let llref_fn_ty = tcx.mk_fn_ptr(ty::Binder(tcx.mk_fn_sig(
use value::Value;
use rustc::ty::{self, Ty, TyCtxt};
use rustc::ty::layout::Layout;
+use rustc::ty::subst::Subst;
use rustc::traits::{self, SelectionContext, Reveal};
use rustc::hir;
ty::TyFnPtr(sig) => sig,
ty::TyClosure(def_id, substs) => {
let tcx = ccx.tcx();
- let sig = tcx.closure_type(def_id, substs);
+ let sig = tcx.closure_type(def_id).subst(tcx, substs.substs);
let env_region = ty::ReLateBound(ty::DebruijnIndex::new(1), ty::BrEnv);
let env_ty = match tcx.closure_kind(def_id) {
use rustc::mir::tcx::LvalueTy;
use rustc::ty::{self, layout, Ty, TyCtxt, TypeFoldable};
use rustc::ty::cast::{CastTy, IntTy};
-use rustc::ty::subst::{Kind, Substs};
+use rustc::ty::subst::{Kind, Substs, Subst};
use rustc_data_structures::indexed_vec::{Idx, IndexVec};
use {abi, adt, base, Disr, machine};
use callee::Callee;
.find(|it| it.kind == ty::AssociatedKind::Method)
.unwrap().def_id;
// Now create its substs [Closure, Tuple]
- let input = tcx.closure_type(def_id, substs).input(0);
+ let input = tcx.closure_type(def_id)
+ .subst(tcx, substs.substs).input(0);
let substs = tcx.mk_substs([operand.ty, input.skip_binder()]
.iter().cloned().map(Kind::from));
Callee::def(self.ccx, call_once, substs)
use rustc::ty::{self, Ty};
use rustc::ty::cast::{CastTy, IntTy};
use rustc::ty::layout::Layout;
-use rustc::ty::subst::Kind;
+use rustc::ty::subst::{Kind, Subst};
use rustc::mir::tcx::LvalueTy;
use rustc::mir;
use middle::lang_items::ExchangeMallocFnLangItem;
.find(|it| it.kind == ty::AssociatedKind::Method)
.unwrap().def_id;
// Now create its substs [Closure, Tuple]
- let input = bcx.tcx().closure_type(def_id, substs).input(0);
+ let input = bcx.tcx().closure_type(def_id)
+ .subst(bcx.tcx(), substs.substs).input(0);
let substs = bcx.tcx().mk_substs([operand.ty, input.skip_binder()]
.iter().cloned().map(Kind::from));
OperandValue::Immediate(
use hir::def_id::{DefId, LOCAL_CRATE};
use rustc::{infer, traits};
use rustc::ty::{self, TyCtxt, LvaluePreference, Ty};
+use rustc::ty::subst::Subst;
use syntax::abi;
use syntax::symbol::Symbol;
use syntax_pos::Span;
// haven't yet decided on whether the closure is fn vs
// fnmut vs fnonce. If so, we have to defer further processing.
if self.closure_kind(def_id).is_none() {
- let closure_ty = self.closure_type(def_id, substs);
+ let closure_ty = self.closure_type(def_id).subst(self.tcx, substs.substs);
let fn_sig = self.replace_late_bound_regions_with_fresh_var(call_expr.span,
infer::FnCall,
&closure_ty)
use rustc::ty::fold::TypeFoldable;
use rustc::ty::error::TypeError;
use rustc::ty::relate::RelateResult;
+use rustc::ty::subst::Subst;
use syntax::abi;
use syntax::feature_gate;
use util::common::indent;
// `extern "rust-call" fn((arg0,arg1,...)) -> _`
// to
// `fn(arg0,arg1,...) -> _`
- let sig = self.closure_type(def_id_a, substs_a);
+ let sig = self.closure_type(def_id_a).subst(self.tcx, substs_a.substs);
let converted_sig = sig.map_bound(|s| {
let params_iter = match s.inputs()[0].sty {
ty::TyTuple(params, _) => {