Auto merge of #77873 - sexxi-goose:use_tuple_inference_for_closures, r=nikomatsakis
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. closes https://github.com/rust-lang/project-rfc-2229/issues/4 r? `@nikomatsakis`
This commit is contained in:
commit
93deabce03
18 changed files with 152 additions and 85 deletions
|
@ -1600,7 +1600,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
|
||||
ty::Closure(_, substs) => {
|
||||
// (*) binder moved here
|
||||
Where(ty::Binder::bind(substs.as_closure().upvar_tys().collect()))
|
||||
let ty = self.infcx.shallow_resolve(substs.as_closure().tupled_upvars_ty());
|
||||
if let ty::Infer(ty::TyVar(_)) = ty.kind() {
|
||||
// Not yet resolved.
|
||||
Ambiguous
|
||||
} else {
|
||||
Where(ty::Binder::bind(substs.as_closure().upvar_tys().collect()))
|
||||
}
|
||||
}
|
||||
|
||||
ty::Adt(..) | ty::Projection(..) | ty::Param(..) | ty::Opaque(..) => {
|
||||
|
@ -1669,11 +1675,15 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
tys.iter().map(|k| k.expect_ty()).collect()
|
||||
}
|
||||
|
||||
ty::Closure(_, ref substs) => substs.as_closure().upvar_tys().collect(),
|
||||
ty::Closure(_, ref substs) => {
|
||||
let ty = self.infcx.shallow_resolve(substs.as_closure().tupled_upvars_ty());
|
||||
vec![ty]
|
||||
}
|
||||
|
||||
ty::Generator(_, ref substs, _) => {
|
||||
let ty = self.infcx.shallow_resolve(substs.as_generator().tupled_upvars_ty());
|
||||
let witness = substs.as_generator().witness();
|
||||
substs.as_generator().upvar_tys().chain(iter::once(witness)).collect()
|
||||
vec![ty].into_iter().chain(iter::once(witness)).collect()
|
||||
}
|
||||
|
||||
ty::GeneratorWitness(types) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue