Skip to content

Commit 0e8c69e

Browse files
committed
fix GeneratorWitness: Clone check
1 parent 0451205 commit 0e8c69e

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
@@ -1917,18 +1917,23 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
19171917
}
19181918

19191919
ty::GeneratorWitness(binder) => {
1920-
let tys = self.tcx().erase_late_bound_regions(binder);
1921-
let mut iter = tys.iter();
1920+
let witness_tys = binder.skip_binder();
1921+
let mut iter = witness_tys.iter();
19221922
loop {
1923-
let ty = match iter.next() {
1924-
Some(ty) => ty,
1923+
match iter.next() {
1924+
Some(witness_ty) => {
1925+
let resolved = self.infcx.shallow_resolve(witness_ty);
1926+
if matches!(resolved.kind(), ty::Infer(ty::TyVar(_))) {
1927+
break Ambiguous;
1928+
}
1929+
},
19251930
Option::None => {
1926-
break Where(obligation.predicate.rebind(tys.to_vec()))
1931+
// (*) binder moved here
1932+
let all_vars = self.tcx().mk_bound_variable_kinds(
1933+
obligation.predicate.bound_vars().iter().chain(binder.bound_vars().iter())
1934+
);
1935+
break Where(ty::Binder::bind_with_vars(witness_tys.to_vec(), all_vars));
19271936
},
1928-
};
1929-
let resolved = self.infcx.shallow_resolve(ty);
1930-
if matches!(resolved.kind(), ty::Infer(ty::TyVar(_))) {
1931-
break Ambiguous;
19321937
}
19331938
}
19341939
}

0 commit comments

Comments
 (0)