Basic generators work
This commit is contained in:
parent
998a816106
commit
c892b28c02
4 changed files with 98 additions and 34 deletions
|
@ -258,6 +258,19 @@ fn resolve_associated_item<'tcx>(
|
|||
debug_assert!(tcx.defaultness(trait_item_id).has_value());
|
||||
Some(Instance::new(trait_item_id, rcvr_args))
|
||||
}
|
||||
} else if Some(trait_ref.def_id) == lang_items.iterator_trait() {
|
||||
let ty::Coroutine(coroutine_def_id, args, _) = *rcvr_args.type_at(0).kind() else {
|
||||
bug!()
|
||||
};
|
||||
if Some(trait_item_id) == tcx.lang_items().next_fn() {
|
||||
// `Iterator::next` is generated by the compiler.
|
||||
Some(Instance { def: ty::InstanceDef::Item(coroutine_def_id), args })
|
||||
} else {
|
||||
// All other methods are default methods of the `Iterator` trait.
|
||||
// (this assumes that `ImplSource::Builtin` is only used for methods on `Iterator`)
|
||||
debug_assert!(tcx.defaultness(trait_item_id).has_value());
|
||||
Some(Instance::new(trait_item_id, rcvr_args))
|
||||
}
|
||||
} else if Some(trait_ref.def_id) == lang_items.gen_trait() {
|
||||
let ty::Coroutine(coroutine_def_id, args, _) = *rcvr_args.type_at(0).kind() else {
|
||||
bug!()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue