Skip to content

Commit 0ac8542

Browse files
committed
make mk_closure take a ClosureSubsts
1 parent 3349e7b commit 0ac8542

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
@@ -1981,11 +1981,9 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
19811981

19821982
pub fn mk_closure(self,
19831983
closure_id: DefId,
1984-
substs: &'tcx Substs<'tcx>)
1985-
-> Ty<'tcx> {
1986-
self.mk_closure_from_closure_substs(closure_id, ClosureSubsts {
1987-
substs,
1988-
})
1984+
substs: ClosureSubsts<'tcx>)
1985+
-> Ty<'tcx> {
1986+
self.mk_closure_from_closure_substs(closure_id, substs)
19891987
}
19901988

19911989
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
@@ -1163,14 +1163,19 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
11631163
return tcx.typeck_tables_of(def_id).node_id_to_type(hir_id);
11641164
}
11651165

1166-
tcx.mk_closure(def_id, Substs::for_item(
1167-
tcx, def_id,
1168-
|def, _| {
1169-
let region = def.to_early_bound_region_data();
1170-
tcx.mk_region(ty::ReEarlyBound(region))
1171-
},
1172-
|def, _| tcx.mk_param_from_def(def)
1173-
))
1166+
let substs = ty::ClosureSubsts {
1167+
substs: Substs::for_item(
1168+
tcx,
1169+
def_id,
1170+
|def, _| {
1171+
let region = def.to_early_bound_region_data();
1172+
tcx.mk_region(ty::ReEarlyBound(region))
1173+
},
1174+
|def, _| tcx.mk_param_from_def(def)
1175+
)
1176+
};
1177+
1178+
tcx.mk_closure(def_id, substs)
11741179
}
11751180

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

0 commit comments

Comments
 (0)