//@ run-pass #![allow(dead_code)] // This code produces a CFG with critical edges that, if we don't // handle properly, will cause invalid codegen. #![feature(rustc_attrs)] enum State { Both, Front, Back } pub struct Foo { state: State, a: A, b: B } impl Foo where A: Iterator, B: Iterator { // This is the function we care about fn next(&mut self) -> Option { match self.state { State::Both => match self.a.next() { elt @ Some(..) => elt, None => { self.state = State::Back; self.b.next() } }, State::Front => self.a.next(), State::Back => self.b.next(), } } } // Make sure we actually codegen a version of the function pub fn do_stuff(mut f: Foo>, Box>>) { let _x = f.next(); } fn main() {}