Address comments
This commit is contained in:
parent
3c46fd67f8
commit
a64ad51ff7
3 changed files with 27 additions and 42 deletions
|
@ -96,26 +96,14 @@ fn compute_components(
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::Closure(_, ref substs) => {
|
ty::Closure(_, ref substs) => {
|
||||||
if substs.as_closure().is_valid() {
|
let tupled_ty = substs.as_closure().tupled_upvars_ty();
|
||||||
for upvar_ty in substs.as_closure().upvar_tys() {
|
compute_components(tcx, tupled_ty, out, visited);
|
||||||
compute_components(tcx, upvar_ty, out, visited);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
let tupled_ty = substs.as_closure().tupled_upvars_ty();
|
|
||||||
compute_components(tcx, tupled_ty, out, visited);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::Generator(_, ref substs, _) => {
|
ty::Generator(_, ref substs, _) => {
|
||||||
// Same as the closure case
|
// Same as the closure case
|
||||||
if substs.as_generator().is_valid() {
|
let tupled_ty = substs.as_generator().tupled_upvars_ty();
|
||||||
for upvar_ty in substs.as_generator().upvar_tys() {
|
compute_components(tcx, tupled_ty, out, visited);
|
||||||
compute_components(tcx, upvar_ty, out, visited);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
let tupled_ty = substs.as_generator().tupled_upvars_ty();
|
|
||||||
compute_components(tcx, tupled_ty, out, visited);
|
|
||||||
}
|
|
||||||
|
|
||||||
// We ignore regions in the generator interior as we don't
|
// We ignore regions in the generator interior as we don't
|
||||||
// want these to affect region inference
|
// want these to affect region inference
|
||||||
|
|
|
@ -441,7 +441,6 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||||
|
|
||||||
for required_region in required_region_bounds {
|
for required_region in required_region_bounds {
|
||||||
concrete_ty.visit_with(&mut ConstrainOpaqueTypeRegionVisitor {
|
concrete_ty.visit_with(&mut ConstrainOpaqueTypeRegionVisitor {
|
||||||
infcx: self,
|
|
||||||
op: |r| self.sub_regions(infer::CallReturn(span), required_region, r),
|
op: |r| self.sub_regions(infer::CallReturn(span), required_region, r),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -510,7 +509,6 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
concrete_ty.visit_with(&mut ConstrainOpaqueTypeRegionVisitor {
|
concrete_ty.visit_with(&mut ConstrainOpaqueTypeRegionVisitor {
|
||||||
infcx: self,
|
|
||||||
op: |r| self.sub_regions(infer::CallReturn(span), least_region, r),
|
op: |r| self.sub_regions(infer::CallReturn(span), least_region, r),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -545,7 +543,6 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||||
);
|
);
|
||||||
|
|
||||||
concrete_ty.visit_with(&mut ConstrainOpaqueTypeRegionVisitor {
|
concrete_ty.visit_with(&mut ConstrainOpaqueTypeRegionVisitor {
|
||||||
infcx: self,
|
|
||||||
op: |r| {
|
op: |r| {
|
||||||
self.member_constraint(
|
self.member_constraint(
|
||||||
opaque_type_def_id,
|
opaque_type_def_id,
|
||||||
|
@ -686,12 +683,11 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||||
//
|
//
|
||||||
// We ignore any type parameters because impl trait values are assumed to
|
// We ignore any type parameters because impl trait values are assumed to
|
||||||
// capture all the in-scope type parameters.
|
// capture all the in-scope type parameters.
|
||||||
struct ConstrainOpaqueTypeRegionVisitor<'cx, 'tcx, OP> {
|
struct ConstrainOpaqueTypeRegionVisitor<OP> {
|
||||||
infcx: &'cx InferCtxt<'cx, 'tcx>,
|
|
||||||
op: OP,
|
op: OP,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'cx, 'tcx, OP> TypeVisitor<'tcx> for ConstrainOpaqueTypeRegionVisitor<'cx, 'tcx, OP>
|
impl<'tcx, OP> TypeVisitor<'tcx> for ConstrainOpaqueTypeRegionVisitor<OP>
|
||||||
where
|
where
|
||||||
OP: FnMut(ty::Region<'tcx>),
|
OP: FnMut(ty::Region<'tcx>),
|
||||||
{
|
{
|
||||||
|
@ -721,36 +717,28 @@ where
|
||||||
ty::Closure(_, ref substs) => {
|
ty::Closure(_, ref substs) => {
|
||||||
// Skip lifetime parameters of the enclosing item(s)
|
// Skip lifetime parameters of the enclosing item(s)
|
||||||
|
|
||||||
let ty = self.infcx.shallow_resolve(substs.as_closure().tupled_upvars_ty());
|
substs.as_closure().tupled_upvars_ty().visit_with(self);
|
||||||
if let ty::Infer(ty::TyVar(_)) = ty.kind() {
|
|
||||||
// Not yet resolved.
|
|
||||||
ty.super_visit_with(self);
|
|
||||||
} else {
|
|
||||||
for upvar_ty in substs.as_closure().upvar_tys() {
|
|
||||||
upvar_ty.visit_with(self);
|
|
||||||
}
|
|
||||||
|
|
||||||
substs.as_closure().sig_as_fn_ptr_ty().visit_with(self);
|
for upvar_ty in substs.as_closure().upvar_tys() {
|
||||||
|
upvar_ty.visit_with(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
substs.as_closure().sig_as_fn_ptr_ty().visit_with(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::Generator(_, ref substs, _) => {
|
ty::Generator(_, ref substs, _) => {
|
||||||
// Skip lifetime parameters of the enclosing item(s)
|
// Skip lifetime parameters of the enclosing item(s)
|
||||||
// Also skip the witness type, because that has no free regions.
|
// Also skip the witness type, because that has no free regions.
|
||||||
|
|
||||||
let ty = self.infcx.shallow_resolve(substs.as_generator().tupled_upvars_ty());
|
substs.as_generator().tupled_upvars_ty().visit_with(self);
|
||||||
if let ty::Infer(ty::TyVar(_)) = ty.kind() {
|
|
||||||
// Not yet resolved.
|
|
||||||
ty.super_visit_with(self);
|
|
||||||
} else {
|
|
||||||
for upvar_ty in substs.as_generator().upvar_tys() {
|
|
||||||
upvar_ty.visit_with(self);
|
|
||||||
}
|
|
||||||
|
|
||||||
substs.as_generator().return_ty().visit_with(self);
|
for upvar_ty in substs.as_generator().upvar_tys() {
|
||||||
substs.as_generator().yield_ty().visit_with(self);
|
upvar_ty.visit_with(self);
|
||||||
substs.as_generator().resume_ty().visit_with(self);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
substs.as_generator().return_ty().visit_with(self);
|
||||||
|
substs.as_generator().yield_ty().visit_with(self);
|
||||||
|
substs.as_generator().resume_ty().visit_with(self);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
ty.super_visit_with(self);
|
ty.super_visit_with(self);
|
||||||
|
|
|
@ -214,6 +214,11 @@ fn dtorck_constraint_for_ty<'tcx>(
|
||||||
if !substs.as_closure().is_valid() {
|
if !substs.as_closure().is_valid() {
|
||||||
// By the time this code runs, all type variables ought to
|
// By the time this code runs, all type variables ought to
|
||||||
// be fully resolved.
|
// be fully resolved.
|
||||||
|
|
||||||
|
tcx.sess.delay_span_bug(
|
||||||
|
span,
|
||||||
|
&format!("upvar_tys for closure not found. Expected capture information for closure {}", ty,),
|
||||||
|
);
|
||||||
return Err(NoSolution);
|
return Err(NoSolution);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,6 +257,10 @@ fn dtorck_constraint_for_ty<'tcx>(
|
||||||
if !substs.as_generator().is_valid() {
|
if !substs.as_generator().is_valid() {
|
||||||
// By the time this code runs, all type variables ought to
|
// By the time this code runs, all type variables ought to
|
||||||
// be fully resolved.
|
// be fully resolved.
|
||||||
|
tcx.sess.delay_span_bug(
|
||||||
|
span,
|
||||||
|
&format!("upvar_tys for generator not found. Expected capture information for generator {}", ty,),
|
||||||
|
);
|
||||||
return Err(NoSolution);
|
return Err(NoSolution);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue