(
sess: &Session,
module: &Module,
current: usize,
discovered: &mut Vec<bool>,
finished: &mut Vec<bool>,
has_recursion: &mut Option<ErrorGuaranteed>,
| 220 | } |
| 221 | |
| 222 | fn visit( |
| 223 | sess: &Session, |
| 224 | module: &Module, |
| 225 | current: usize, |
| 226 | discovered: &mut Vec<bool>, |
| 227 | finished: &mut Vec<bool>, |
| 228 | has_recursion: &mut Option<ErrorGuaranteed>, |
| 229 | func_to_index: &FxHashMap<Word, usize>, |
| 230 | ) { |
| 231 | discovered[current] = true; |
| 232 | |
| 233 | for next in calls(&module.functions[current], func_to_index) { |
| 234 | if discovered[next] { |
| 235 | let names = get_names(module); |
| 236 | let current_name = get_name(&names, module.functions[current].def_id().unwrap()); |
| 237 | let next_name = get_name(&names, module.functions[next].def_id().unwrap()); |
| 238 | *has_recursion = Some(sess.err(format!( |
| 239 | "module has recursion, which is not allowed: `{current_name}` calls `{next_name}`" |
| 240 | ))); |
| 241 | break; |
| 242 | } |
| 243 | |
| 244 | if !finished[next] { |
| 245 | visit( |
| 246 | sess, |
| 247 | module, |
| 248 | next, |
| 249 | discovered, |
| 250 | finished, |
| 251 | has_recursion, |
| 252 | func_to_index, |
| 253 | ); |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | discovered[current] = false; |
| 258 | finished[current] = true; |
| 259 | } |
| 260 | |
| 261 | fn calls<'a>( |
| 262 | func: &'a Function, |
no test coverage detected