Replace tuple of infer vars for upvar_tys with single infer var
This commit allows us to decide the number of captures required after completing capture ananysis, which is required as part of implementing RFC-2229. Co-authored-by: Aman Arora <me@aman-arora.com> Co-authored-by: Jenny Wills <wills.jenniferg@gmail.com>
This commit is contained in:
parent
25d2d09da7
commit
dc183702da
23 changed files with 178 additions and 95 deletions
|
@ -210,12 +210,20 @@ fn dtorck_constraint_for_ty<'tcx>(
|
|||
Ok::<_, NoSolution>(())
|
||||
})?,
|
||||
|
||||
ty::Closure(_, substs) => rustc_data_structures::stack::ensure_sufficient_stack(|| {
|
||||
for ty in substs.as_closure().upvar_tys() {
|
||||
dtorck_constraint_for_ty(tcx, span, for_ty, depth + 1, ty, constraints)?;
|
||||
ty::Closure(_, substs) => {
|
||||
if !substs.as_closure().is_valid() {
|
||||
// By the time this code runs, all type variables ought to
|
||||
// be fully resolved.
|
||||
return Err(NoSolution);
|
||||
}
|
||||
Ok::<_, NoSolution>(())
|
||||
})?,
|
||||
|
||||
rustc_data_structures::stack::ensure_sufficient_stack(|| {
|
||||
for ty in substs.as_closure().upvar_tys() {
|
||||
dtorck_constraint_for_ty(tcx, span, for_ty, depth + 1, ty, constraints)?;
|
||||
}
|
||||
Ok::<_, NoSolution>(())
|
||||
})?
|
||||
}
|
||||
|
||||
ty::Generator(_, substs, _movability) => {
|
||||
// rust-lang/rust#49918: types can be constructed, stored
|
||||
|
@ -241,6 +249,12 @@ fn dtorck_constraint_for_ty<'tcx>(
|
|||
// derived from lifetimes attached to the upvars and resume
|
||||
// argument, and we *do* incorporate those here.
|
||||
|
||||
if !substs.as_generator().is_valid() {
|
||||
// By the time this code runs, all type variables ought to
|
||||
// be fully resolved.
|
||||
return Err(NoSolution);
|
||||
}
|
||||
|
||||
constraints.outlives.extend(
|
||||
substs
|
||||
.as_generator()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue