Skip to content

Commit c1f1bc6

Browse files
canndrewcrlf0710
authored andcommitted
fix GeneratorWitness: Clone check
1 parent a5cb3cc commit c1f1bc6

File tree

1 file changed

+14
-9
lines changed
  • compiler/rustc_trait_selection/src/traits/select

1 file changed

+14
-9
lines changed

compiler/rustc_trait_selection/src/traits/select/mod.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1958,18 +1958,23 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
19581958
}
19591959

19601960
ty::GeneratorWitness(binder) => {
1961-
let tys = self.tcx().erase_late_bound_regions(binder);
1962-
let mut iter = tys.iter();
1961+
let witness_tys = binder.skip_binder();
1962+
let mut iter = witness_tys.iter();
19631963
loop {
1964-
let ty = match iter.next() {
1965-
Some(ty) => ty,
1964+
match iter.next() {
1965+
Some(witness_ty) => {
1966+
let resolved = self.infcx.shallow_resolve(witness_ty);
1967+
if matches!(resolved.kind(), ty::Infer(ty::TyVar(_))) {
1968+
break Ambiguous;
1969+
}
1970+
},
19661971
Option::None => {
1967-
break Where(obligation.predicate.rebind(tys.to_vec()))
1972+
// (*) binder moved here
1973+
let all_vars = self.tcx().mk_bound_variable_kinds(
1974+
obligation.predicate.bound_vars().iter().chain(binder.bound_vars().iter())
1975+
);
1976+
break Where(ty::Binder::bind_with_vars(witness_tys.to_vec(), all_vars));
19681977
},
1969-
};
1970-
let resolved = self.infcx.shallow_resolve(ty);
1971-
if matches!(resolved.kind(), ty::Infer(ty::TyVar(_))) {
1972-
break Ambiguous;
19731978
}
19741979
}
19751980
}

0 commit comments

Comments
 (0)