2018-08-30 12:18:55 +00:00
|
|
|
// run-pass
|
2018-09-25 21:51:35 +00:00
|
|
|
#![allow(dead_code)]
|
2016-03-12 07:18:26 +00:00
|
|
|
// 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<A: Iterator, B: Iterator> {
|
|
|
|
state: State,
|
|
|
|
a: A,
|
|
|
|
b: B
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<A, B> Foo<A, B>
|
|
|
|
where A: Iterator, B: Iterator<Item=A::Item>
|
|
|
|
{
|
|
|
|
// This is the function we care about
|
|
|
|
fn next(&mut self) -> Option<A::Item> {
|
|
|
|
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(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-08 13:10:16 +00:00
|
|
|
// Make sure we actually codegen a version of the function
|
2019-05-28 18:47:21 +00:00
|
|
|
pub fn do_stuff(mut f: Foo<Box<dyn Iterator<Item=u32>>, Box<dyn Iterator<Item=u32>>>) {
|
2016-03-12 07:18:26 +00:00
|
|
|
let _x = f.next();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|