Skip to content

Commit 8e53a03

Browse files
committed
rustc: rename closure_type to fn_sig.
1 parent f590a44 commit 8e53a03

File tree

14 files changed

+29
-26
lines changed

14 files changed

+29
-26
lines changed

src/librustc/infer/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,7 +1369,11 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
13691369
Some(self.tcx.closure_kind(def_id))
13701370
}
13711371

1372-
pub fn closure_type(&self, def_id: DefId) -> ty::PolyFnSig<'tcx> {
1372+
/// Obtain the signature of a function or closure.
1373+
/// For closures, unlike `tcx.fn_sig(def_id)`, this method will
1374+
/// work during the type-checking of the enclosing function and
1375+
/// return the closure signature in its partially inferred state.
1376+
pub fn fn_sig(&self, def_id: DefId) -> ty::PolyFnSig<'tcx> {
13731377
if let Some(tables) = self.in_progress_tables {
13741378
if let Some(id) = self.tcx.hir.as_local_node_id(def_id) {
13751379
if let Some(&ty) = tables.borrow().closure_tys.get(&id) {
@@ -1378,7 +1382,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
13781382
}
13791383
}
13801384

1381-
self.tcx.closure_type(def_id)
1385+
self.tcx.fn_sig(def_id)
13821386
}
13831387
}
13841388

src/librustc/traits/project.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1149,7 +1149,7 @@ fn confirm_closure_candidate<'cx, 'gcx, 'tcx>(
11491149
-> Progress<'tcx>
11501150
{
11511151
let closure_typer = selcx.closure_typer();
1152-
let closure_type = closure_typer.closure_type(vtable.closure_def_id)
1152+
let closure_type = closure_typer.fn_sig(vtable.closure_def_id)
11531153
.subst(selcx.tcx(), vtable.substs.substs);
11541154
let Normalized {
11551155
value: closure_type,

src/librustc/traits/select.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2799,7 +2799,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
27992799
substs: ty::ClosureSubsts<'tcx>)
28002800
-> ty::PolyTraitRef<'tcx>
28012801
{
2802-
let closure_type = self.infcx.closure_type(closure_def_id)
2802+
let closure_type = self.infcx.fn_sig(closure_def_id)
28032803
.subst(self.tcx(), substs.substs);
28042804
let ty::Binder((trait_ref, _)) =
28052805
self.tcx().closure_trait_ref_and_return_type(obligation.predicate.def_id(),

src/librustc/ty/maps.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -875,13 +875,12 @@ define_maps! { <'tcx>
875875
/// for trans. This is also the only query that can fetch non-local MIR, at present.
876876
[] optimized_mir: Mir(DefId) -> &'tcx mir::Mir<'tcx>,
877877

878-
/// Records the type of each closure. The def ID is the ID of the
878+
/// Type of each closure. The def ID is the ID of the
879879
/// expression defining the closure.
880880
[] closure_kind: ItemSignature(DefId) -> ty::ClosureKind,
881881

882-
/// Records the type of each closure. The def ID is the ID of the
883-
/// expression defining the closure.
884-
[] closure_type: ItemSignature(DefId) -> ty::PolyFnSig<'tcx>,
882+
/// The signature of functions and closures.
883+
[] fn_sig: ItemSignature(DefId) -> ty::PolyFnSig<'tcx>,
885884

886885
/// Caches CoerceUnsized kinds for impls on custom types.
887886
[] coerce_unsized_info: ItemSignature(DefId)

src/librustc_metadata/cstore_impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ provide! { <'tcx> tcx, def_id, cdata,
106106
mir_const_qualif => { cdata.mir_const_qualif(def_id.index) }
107107
typeck_tables_of => { cdata.item_body_tables(def_id.index, tcx) }
108108
closure_kind => { cdata.closure_kind(def_id.index) }
109-
closure_type => { cdata.closure_ty(def_id.index, tcx) }
109+
fn_sig => { cdata.fn_sig(def_id.index, tcx) }
110110
inherent_impls => { Rc::new(cdata.get_inherent_implementations_for_type(def_id.index)) }
111111
is_const_fn => { cdata.is_const_fn(def_id.index) }
112112
is_foreign_item => { cdata.is_foreign_item(def_id.index) }

src/librustc_metadata/decoder.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,12 +1084,12 @@ impl<'a, 'tcx> CrateMetadata {
10841084
}
10851085
}
10861086

1087-
pub fn closure_ty(&self,
1088-
closure_id: DefIndex,
1089-
tcx: TyCtxt<'a, 'tcx, 'tcx>)
1090-
-> ty::PolyFnSig<'tcx> {
1087+
pub fn fn_sig(&self,
1088+
closure_id: DefIndex,
1089+
tcx: TyCtxt<'a, 'tcx, 'tcx>)
1090+
-> ty::PolyFnSig<'tcx> {
10911091
match self.entry(closure_id).kind {
1092-
EntryKind::Closure(data) => data.decode(self).ty.decode((self, tcx)),
1092+
EntryKind::Closure(data) => data.decode(self).sig.decode((self, tcx)),
10931093
_ => bug!(),
10941094
}
10951095
}

src/librustc_metadata/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1175,7 +1175,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
11751175

11761176
let data = ClosureData {
11771177
kind: tcx.closure_kind(def_id),
1178-
ty: self.lazy(&tcx.closure_type(def_id)),
1178+
sig: self.lazy(&tcx.fn_sig(def_id)),
11791179
};
11801180

11811181
Entry {

src/librustc_metadata/schema.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,6 @@ impl_stable_hash_for!(struct MethodData { fn_data, container, has_self });
553553
#[derive(RustcEncodable, RustcDecodable)]
554554
pub struct ClosureData<'tcx> {
555555
pub kind: ty::ClosureKind,
556-
pub ty: Lazy<ty::PolyFnSig<'tcx>>,
556+
pub sig: Lazy<ty::PolyFnSig<'tcx>>,
557557
}
558-
impl_stable_hash_for!(struct ClosureData<'tcx> { kind, ty });
558+
impl_stable_hash_for!(struct ClosureData<'tcx> { kind, sig });

src/librustc_trans/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ pub fn ty_fn_sig<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
500500
ty::TyFnPtr(sig) => sig,
501501
ty::TyClosure(def_id, substs) => {
502502
let tcx = ccx.tcx();
503-
let sig = tcx.closure_type(def_id).subst(tcx, substs.substs);
503+
let sig = tcx.fn_sig(def_id).subst(tcx, substs.substs);
504504

505505
let env_region = ty::ReLateBound(ty::DebruijnIndex::new(1), ty::BrEnv);
506506
let env_ty = match tcx.closure_kind(def_id) {

src/librustc_trans/mir/constant.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ impl<'a, 'tcx> MirConstContext<'a, 'tcx> {
579579
.find(|it| it.kind == ty::AssociatedKind::Method)
580580
.unwrap().def_id;
581581
// Now create its substs [Closure, Tuple]
582-
let input = tcx.closure_type(def_id)
582+
let input = tcx.fn_sig(def_id)
583583
.subst(tcx, substs.substs).input(0);
584584
let input = tcx.erase_late_bound_regions_and_normalize(&input);
585585
let substs = tcx.mk_substs([operand.ty, input]

src/librustc_trans/monomorphize.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ fn fn_once_adapter_instance<'a, 'tcx>(
4040
let self_ty = tcx.mk_closure_from_closure_substs(
4141
closure_did, substs);
4242

43-
let sig = tcx.closure_type(closure_did).subst(tcx, substs.substs);
43+
let sig = tcx.fn_sig(closure_did).subst(tcx, substs.substs);
4444
let sig = tcx.erase_late_bound_regions_and_normalize(&sig);
4545
assert_eq!(sig.inputs().len(), 1);
4646
let substs = tcx.mk_substs([

src/librustc_typeck/check/callee.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
108108
// haven't yet decided on whether the closure is fn vs
109109
// fnmut vs fnonce. If so, we have to defer further processing.
110110
if self.closure_kind(def_id).is_none() {
111-
let closure_ty = self.closure_type(def_id).subst(self.tcx, substs.substs);
111+
let closure_ty = self.fn_sig(def_id).subst(self.tcx, substs.substs);
112112
let fn_sig = self.replace_late_bound_regions_with_fresh_var(call_expr.span,
113113
infer::FnCall,
114114
&closure_ty)

src/librustc_typeck/check/coercion.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> {
639639
// `extern "rust-call" fn((arg0,arg1,...)) -> _`
640640
// to
641641
// `fn(arg0,arg1,...) -> _`
642-
let sig = self.closure_type(def_id_a).subst(self.tcx, substs_a.substs);
642+
let sig = self.fn_sig(def_id_a).subst(self.tcx, substs_a.substs);
643643
let converted_sig = sig.map_bound(|s| {
644644
let params_iter = match s.inputs()[0].sty {
645645
ty::TyTuple(params, _) => {

src/librustc_typeck/check/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -718,16 +718,16 @@ pub fn provide(providers: &mut Providers) {
718718
typeck_item_bodies,
719719
typeck_tables_of,
720720
has_typeck_tables,
721-
closure_type,
721+
fn_sig,
722722
closure_kind,
723723
adt_destructor,
724724
..*providers
725725
};
726726
}
727727

728-
fn closure_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
729-
def_id: DefId)
730-
-> ty::PolyFnSig<'tcx> {
728+
fn fn_sig<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
729+
def_id: DefId)
730+
-> ty::PolyFnSig<'tcx> {
731731
let node_id = tcx.hir.as_local_node_id(def_id).unwrap();
732732
tcx.typeck_tables_of(def_id).closure_tys[&node_id]
733733
}

0 commit comments

Comments
 (0)