Skip to content

Commit 12b67c6

Browse files
committed
make mk_closure take a ClosureSubsts
1 parent 7d018a2 commit 12b67c6

File tree

4 files changed

+19
-16
lines changed

4 files changed

+19
-16
lines changed

src/librustc/infer/freshen.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for TypeFreshener<'a, 'gcx, 'tcx> {
256256
let closure_sig = this.infcx.fn_sig(def_id);
257257
(tcx.mk_fn_ptr(closure_sig.fold_with(this)), tcx.types.char)
258258
},
259-
|substs| tcx.mk_closure(def_id, substs)
259+
|substs| tcx.mk_closure(def_id, ty::ClosureSubsts { substs })
260260
)
261261
}
262262

src/librustc/ty/context.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1986,11 +1986,9 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
19861986

19871987
pub fn mk_closure(self,
19881988
closure_id: DefId,
1989-
substs: &'tcx Substs<'tcx>)
1990-
-> Ty<'tcx> {
1991-
self.mk_closure_from_closure_substs(closure_id, ClosureSubsts {
1992-
substs,
1993-
})
1989+
substs: ClosureSubsts<'tcx>)
1990+
-> Ty<'tcx> {
1991+
self.mk_closure_from_closure_substs(closure_id, substs)
19941992
}
19951993

19961994
pub fn mk_closure_from_closure_substs(self,

src/librustc_typeck/check/closure.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
103103
.next_ty_var(TypeVariableOrigin::ClosureSynthetic(expr.span))
104104
},
105105
);
106+
let substs = ty::ClosureSubsts { substs };
106107
let closure_type = self.tcx.mk_closure(expr_def_id, substs);
107108

108109
if let Some(interior) = interior {
109-
let closure_substs = ty::ClosureSubsts { substs: substs };
110-
return self.tcx.mk_generator(expr_def_id, closure_substs, interior);
110+
return self.tcx.mk_generator(expr_def_id, substs, interior);
111111
}
112112

113113
debug!(

src/librustc_typeck/collect.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,14 +1135,19 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
11351135
return tcx.typeck_tables_of(def_id).node_id_to_type(hir_id);
11361136
}
11371137

1138-
tcx.mk_closure(def_id, Substs::for_item(
1139-
tcx, def_id,
1140-
|def, _| {
1141-
let region = def.to_early_bound_region_data();
1142-
tcx.mk_region(ty::ReEarlyBound(region))
1143-
},
1144-
|def, _| tcx.mk_param_from_def(def)
1145-
))
1138+
let substs = ty::ClosureSubsts {
1139+
substs: Substs::for_item(
1140+
tcx,
1141+
def_id,
1142+
|def, _| {
1143+
let region = def.to_early_bound_region_data();
1144+
tcx.mk_region(ty::ReEarlyBound(region))
1145+
},
1146+
|def, _| tcx.mk_param_from_def(def)
1147+
)
1148+
};
1149+
1150+
tcx.mk_closure(def_id, substs)
11461151
}
11471152

11481153
NodeExpr(_) => match tcx.hir.get(tcx.hir.get_parent_node(node_id)) {

0 commit comments

Comments
 (0)