Skip to content

Commit d9a15cc

Browse files
committed
rustc_typeck: move comment about inference variables to where it makes sense.
1 parent 3fd397b commit d9a15cc

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/librustc_typeck/check/closure.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
7777
let generator_types =
7878
check_fn(self, self.param_env, liberated_sig, decl, expr.hir_id, body, gen).1;
7979

80-
// Create type variables (for now) to represent the transformed
81-
// types of upvars. These will be unified during the upvar
82-
// inference phase (`upvar.rs`).
8380
let base_substs =
8481
InternalSubsts::identity_for_item(self.tcx, self.tcx.closure_base_def_id(expr_def_id));
8582
// HACK(eddyb) this hardcodes indices into substs but it should rely on
@@ -93,6 +90,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
9390
GenericParamDefKind::Type { .. } => if param.index as usize == tupled_upvars_idx {
9491
self.tcx.mk_tup(self.tcx.upvars(expr_def_id).iter().flat_map(|upvars| {
9592
upvars.iter().map(|(&var_hir_id, _)| {
93+
// Create type variables (for now) to represent the transformed
94+
// types of upvars. These will be unified during the upvar
95+
// inference phase (`upvar.rs`).
9696
self.infcx.next_ty_var(TypeVariableOrigin {
9797
// FIXME(eddyb) distinguish upvar inference variables from the rest.
9898
kind: TypeVariableOriginKind::ClosureSynthetic,
@@ -101,6 +101,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
101101
})
102102
}))
103103
} else {
104+
// Create type variables (for now) to represent the various
105+
// pieces of information kept in `{Closure,Generic}Substs`.
106+
// They will either be unified below, or later during the upvar
107+
// inference phase (`upvar.rs`)
104108
self.infcx.next_ty_var(TypeVariableOrigin {
105109
kind: TypeVariableOriginKind::ClosureSynthetic,
106110
span: expr.span,

0 commit comments

Comments
 (0)