minor fixups as per PR feedback
This commit is contained in:
parent
543023c249
commit
62112f4dc1
2 changed files with 17 additions and 32 deletions
|
@ -537,10 +537,8 @@ impl<'tcx> CloneShimBuilder<'tcx> {
|
|||
let variant_index = VariantIdx::new(index);
|
||||
let dest = self.tcx.mk_place_downcast_unnamed(dest, variant_index);
|
||||
let src = self.tcx.mk_place_downcast_unnamed(src, variant_index);
|
||||
let start_block = self.block_index_offset(0);
|
||||
let clone_block = self.block_index_offset(1);
|
||||
cases.push((index as u128, start_block));
|
||||
self.block(
|
||||
let start_block = self.block(
|
||||
vec![self.make_statement(StatementKind::SetDiscriminant {
|
||||
place: Box::new(Place::return_place()),
|
||||
variant_index,
|
||||
|
@ -548,6 +546,7 @@ impl<'tcx> CloneShimBuilder<'tcx> {
|
|||
TerminatorKind::Goto { target: clone_block },
|
||||
false,
|
||||
);
|
||||
cases.push((index as u128, start_block));
|
||||
let _final_cleanup_block = self.clone_fields(dest, src, target, unwind, state_tys);
|
||||
}
|
||||
let discr_ty = substs.discr_ty(self.tcx);
|
||||
|
|
|
@ -1943,15 +1943,15 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
self.infcx.shallow_resolve(substs.as_generator().tupled_upvars_ty());
|
||||
let resolved_witness =
|
||||
self.infcx.shallow_resolve(substs.as_generator().witness());
|
||||
if {
|
||||
matches!(resolved_upvars.kind(), ty::Infer(ty::TyVar(_)))
|
||||
|| matches!(resolved_witness.kind(), ty::Infer(ty::TyVar(_)))
|
||||
} {
|
||||
if resolved_upvars.is_ty_var() || resolved_witness.is_ty_var() {
|
||||
// Not yet resolved.
|
||||
Ambiguous
|
||||
} else {
|
||||
let mut all = substs.as_generator().upvar_tys().collect::<Vec<_>>();
|
||||
all.push(substs.as_generator().witness());
|
||||
let all = substs
|
||||
.as_generator()
|
||||
.upvar_tys()
|
||||
.chain(iter::once(substs.as_generator().witness()))
|
||||
.collect::<Vec<_>>();
|
||||
Where(obligation.predicate.rebind(all))
|
||||
}
|
||||
} else {
|
||||
|
@ -1961,31 +1961,17 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
|
||||
ty::GeneratorWitness(binder) => {
|
||||
let witness_tys = binder.skip_binder();
|
||||
let mut iter = witness_tys.iter();
|
||||
loop {
|
||||
match iter.next() {
|
||||
Some(witness_ty) => {
|
||||
let resolved = self.infcx.shallow_resolve(witness_ty);
|
||||
if matches!(resolved.kind(), ty::Infer(ty::TyVar(_))) {
|
||||
break Ambiguous;
|
||||
}
|
||||
}
|
||||
Option::None => {
|
||||
// (*) binder moved here
|
||||
let all_vars = self.tcx().mk_bound_variable_kinds(
|
||||
obligation
|
||||
.predicate
|
||||
.bound_vars()
|
||||
.iter()
|
||||
.chain(binder.bound_vars().iter()),
|
||||
);
|
||||
break Where(ty::Binder::bind_with_vars(
|
||||
witness_tys.to_vec(),
|
||||
all_vars,
|
||||
));
|
||||
}
|
||||
for witness_ty in witness_tys.iter() {
|
||||
let resolved = self.infcx.shallow_resolve(witness_ty);
|
||||
if resolved.is_ty_var() {
|
||||
return Ambiguous;
|
||||
}
|
||||
}
|
||||
// (*) binder moved here
|
||||
let all_vars = self.tcx().mk_bound_variable_kinds(
|
||||
obligation.predicate.bound_vars().iter().chain(binder.bound_vars().iter()),
|
||||
);
|
||||
Where(ty::Binder::bind_with_vars(witness_tys.to_vec(), all_vars))
|
||||
}
|
||||
|
||||
ty::Closure(_, substs) => {
|
||||
|
|
Loading…
Add table
Reference in a new issue