(source: &str, pred: F)
| 286 | |
| 287 | // -- Control flow lowering ----------------------------------------------------- |
| 288 | |
| 289 | fn has_terminator<F>(source: &str, pred: F) -> bool |
| 290 | where |
| 291 | F: Fn(&IrTerminator) -> bool, |
| 292 | { |
| 293 | let result = CompilationPipeline::new() |
| 294 | .compile(source) |
| 295 | .unwrap_or_else(|e| panic!("expected ok, got: {e}")); |
| 296 | result |
| 297 | .ir_program |
| 298 | .functions |
| 299 | .iter() |
| 300 | .flat_map(|f| f.blocks.iter()) |
| 301 | .filter_map(|b| b.terminator.as_ref()) |
| 302 | .any(pred) |
| 303 | } |
| 304 | |
| 305 | #[test] |