MCPcopy Create free account
hub / github.com/Rust-GPU/rust-gpu / visit

Function visit

crates/rustc_codegen_spirv/src/linker/inline.rs:222–259  ·  view source on GitHub ↗
(
        sess: &Session,
        module: &Module,
        current: usize,
        discovered: &mut Vec<bool>,
        finished: &mut Vec<bool>,
        has_recursion: &mut Option<ErrorGuaranteed>,
  

Source from the content-addressed store, hash-verified

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,

Callers 1

deny_recursion_in_moduleFunction · 0.70

Calls 4

callsFunction · 0.85
get_namesFunction · 0.85
get_nameFunction · 0.85
errMethod · 0.80

Tested by

no test coverage detected