Implement FusedIterator for gen block

This commit is contained in:
Shoyu Vanilla 2024-03-22 00:48:36 +09:00
parent 03994e498d
commit ae4c5c891e
10 changed files with 105 additions and 7 deletions

View file

@ -2259,6 +2259,20 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
}
}
fn fused_iterator_conditions(
&mut self,
obligation: &PolyTraitObligation<'tcx>,
) -> BuiltinImplConditions<'tcx> {
let self_ty = self.infcx.shallow_resolve(obligation.self_ty().skip_binder());
if let ty::Coroutine(did, ..) = *self_ty.kind()
&& self.tcx().coroutine_is_gen(did)
{
BuiltinImplConditions::Where(ty::Binder::dummy(Vec::new()))
} else {
BuiltinImplConditions::None
}
}
/// For default impls, we need to break apart a type into its
/// "constituent types" -- meaning, the types that it contains.
///