rustc: rename closure_type to fn_sig.
This commit is contained in:
parent
f590a44ce6
commit
8e53a03d15
14 changed files with 29 additions and 26 deletions
|
|
@ -1369,7 +1369,11 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
Some(self.tcx.closure_kind(def_id))
|
||||
}
|
||||
|
||||
pub fn closure_type(&self, def_id: DefId) -> ty::PolyFnSig<'tcx> {
|
||||
/// Obtain the signature of a function or closure.
|
||||
/// For closures, unlike `tcx.fn_sig(def_id)`, this method will
|
||||
/// work during the type-checking of the enclosing function and
|
||||
/// return the closure signature in its partially inferred state.
|
||||
pub fn fn_sig(&self, def_id: DefId) -> ty::PolyFnSig<'tcx> {
|
||||
if let Some(tables) = self.in_progress_tables {
|
||||
if let Some(id) = self.tcx.hir.as_local_node_id(def_id) {
|
||||
if let Some(&ty) = tables.borrow().closure_tys.get(&id) {
|
||||
|
|
@ -1378,7 +1382,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
self.tcx.closure_type(def_id)
|
||||
self.tcx.fn_sig(def_id)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1149,7 +1149,7 @@ fn confirm_closure_candidate<'cx, 'gcx, 'tcx>(
|
|||
-> Progress<'tcx>
|
||||
{
|
||||
let closure_typer = selcx.closure_typer();
|
||||
let closure_type = closure_typer.closure_type(vtable.closure_def_id)
|
||||
let closure_type = closure_typer.fn_sig(vtable.closure_def_id)
|
||||
.subst(selcx.tcx(), vtable.substs.substs);
|
||||
let Normalized {
|
||||
value: closure_type,
|
||||
|
|
|
|||
|
|
@ -2799,7 +2799,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
substs: ty::ClosureSubsts<'tcx>)
|
||||
-> ty::PolyTraitRef<'tcx>
|
||||
{
|
||||
let closure_type = self.infcx.closure_type(closure_def_id)
|
||||
let closure_type = self.infcx.fn_sig(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(),
|
||||
|
|
|
|||
|
|
@ -875,13 +875,12 @@ define_maps! { <'tcx>
|
|||
/// for trans. This is also the only query that can fetch non-local MIR, at present.
|
||||
[] optimized_mir: Mir(DefId) -> &'tcx mir::Mir<'tcx>,
|
||||
|
||||
/// Records the type of each closure. The def ID is the ID of the
|
||||
/// Type of each closure. The def ID is the ID of the
|
||||
/// expression defining the closure.
|
||||
[] closure_kind: ItemSignature(DefId) -> ty::ClosureKind,
|
||||
|
||||
/// Records the type of each closure. The def ID is the ID of the
|
||||
/// expression defining the closure.
|
||||
[] closure_type: ItemSignature(DefId) -> ty::PolyFnSig<'tcx>,
|
||||
/// The signature of functions and closures.
|
||||
[] fn_sig: ItemSignature(DefId) -> ty::PolyFnSig<'tcx>,
|
||||
|
||||
/// Caches CoerceUnsized kinds for impls on custom types.
|
||||
[] coerce_unsized_info: ItemSignature(DefId)
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ provide! { <'tcx> tcx, def_id, cdata,
|
|||
mir_const_qualif => { cdata.mir_const_qualif(def_id.index) }
|
||||
typeck_tables_of => { cdata.item_body_tables(def_id.index, tcx) }
|
||||
closure_kind => { cdata.closure_kind(def_id.index) }
|
||||
closure_type => { cdata.closure_ty(def_id.index, tcx) }
|
||||
fn_sig => { cdata.fn_sig(def_id.index, tcx) }
|
||||
inherent_impls => { Rc::new(cdata.get_inherent_implementations_for_type(def_id.index)) }
|
||||
is_const_fn => { cdata.is_const_fn(def_id.index) }
|
||||
is_foreign_item => { cdata.is_foreign_item(def_id.index) }
|
||||
|
|
|
|||
|
|
@ -1084,12 +1084,12 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn closure_ty(&self,
|
||||
closure_id: DefIndex,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>)
|
||||
-> ty::PolyFnSig<'tcx> {
|
||||
pub fn fn_sig(&self,
|
||||
closure_id: DefIndex,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>)
|
||||
-> ty::PolyFnSig<'tcx> {
|
||||
match self.entry(closure_id).kind {
|
||||
EntryKind::Closure(data) => data.decode(self).ty.decode((self, tcx)),
|
||||
EntryKind::Closure(data) => data.decode(self).sig.decode((self, tcx)),
|
||||
_ => bug!(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1175,7 +1175,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
|
|||
|
||||
let data = ClosureData {
|
||||
kind: tcx.closure_kind(def_id),
|
||||
ty: self.lazy(&tcx.closure_type(def_id)),
|
||||
sig: self.lazy(&tcx.fn_sig(def_id)),
|
||||
};
|
||||
|
||||
Entry {
|
||||
|
|
|
|||
|
|
@ -553,6 +553,6 @@ impl_stable_hash_for!(struct MethodData { fn_data, container, has_self });
|
|||
#[derive(RustcEncodable, RustcDecodable)]
|
||||
pub struct ClosureData<'tcx> {
|
||||
pub kind: ty::ClosureKind,
|
||||
pub ty: Lazy<ty::PolyFnSig<'tcx>>,
|
||||
pub sig: Lazy<ty::PolyFnSig<'tcx>>,
|
||||
}
|
||||
impl_stable_hash_for!(struct ClosureData<'tcx> { kind, ty });
|
||||
impl_stable_hash_for!(struct ClosureData<'tcx> { kind, sig });
|
||||
|
|
|
|||
|
|
@ -500,7 +500,7 @@ pub fn ty_fn_sig<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
|||
ty::TyFnPtr(sig) => sig,
|
||||
ty::TyClosure(def_id, substs) => {
|
||||
let tcx = ccx.tcx();
|
||||
let sig = tcx.closure_type(def_id).subst(tcx, substs.substs);
|
||||
let sig = tcx.fn_sig(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) {
|
||||
|
|
|
|||
|
|
@ -579,7 +579,7 @@ impl<'a, 'tcx> MirConstContext<'a, 'tcx> {
|
|||
.find(|it| it.kind == ty::AssociatedKind::Method)
|
||||
.unwrap().def_id;
|
||||
// Now create its substs [Closure, Tuple]
|
||||
let input = tcx.closure_type(def_id)
|
||||
let input = tcx.fn_sig(def_id)
|
||||
.subst(tcx, substs.substs).input(0);
|
||||
let input = tcx.erase_late_bound_regions_and_normalize(&input);
|
||||
let substs = tcx.mk_substs([operand.ty, input]
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ fn fn_once_adapter_instance<'a, 'tcx>(
|
|||
let self_ty = tcx.mk_closure_from_closure_substs(
|
||||
closure_did, substs);
|
||||
|
||||
let sig = tcx.closure_type(closure_did).subst(tcx, substs.substs);
|
||||
let sig = tcx.fn_sig(closure_did).subst(tcx, substs.substs);
|
||||
let sig = tcx.erase_late_bound_regions_and_normalize(&sig);
|
||||
assert_eq!(sig.inputs().len(), 1);
|
||||
let substs = tcx.mk_substs([
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
// 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).subst(self.tcx, substs.substs);
|
||||
let closure_ty = self.fn_sig(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)
|
||||
|
|
|
|||
|
|
@ -639,7 +639,7 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> {
|
|||
// `extern "rust-call" fn((arg0,arg1,...)) -> _`
|
||||
// to
|
||||
// `fn(arg0,arg1,...) -> _`
|
||||
let sig = self.closure_type(def_id_a).subst(self.tcx, substs_a.substs);
|
||||
let sig = self.fn_sig(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, _) => {
|
||||
|
|
|
|||
|
|
@ -718,16 +718,16 @@ pub fn provide(providers: &mut Providers) {
|
|||
typeck_item_bodies,
|
||||
typeck_tables_of,
|
||||
has_typeck_tables,
|
||||
closure_type,
|
||||
fn_sig,
|
||||
closure_kind,
|
||||
adt_destructor,
|
||||
..*providers
|
||||
};
|
||||
}
|
||||
|
||||
fn closure_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
def_id: DefId)
|
||||
-> ty::PolyFnSig<'tcx> {
|
||||
fn fn_sig<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
def_id: DefId)
|
||||
-> ty::PolyFnSig<'tcx> {
|
||||
let node_id = tcx.hir.as_local_node_id(def_id).unwrap();
|
||||
tcx.typeck_tables_of(def_id).closure_tys[&node_id]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue