Goal
Given the following rust code:
fn main() {
let fct = get_fct();
let fct = forward_fct(fct);
fct();
}
fn foo() {
bar()
}
fn bar() {
}
fn get_fct() -> impl Fn() {
foo
}
fn forward_fct<Fct: Fn()>(fct: Fct) -> Fct {
fct
}
Currently, this is what is being generated

General algorithm
This is what I am planning to do. This may change in the future if my understanding of the problem space changes.
First, for each functions (and function-like object like closure), locate all function call. Then for each arguments of the called function track if they come from the argument or the function being analyzed, a constant, or from the return value of another function called in the analyzed function. Multiple source are possible, and the control flow is ignored. Once done for all functions, we can walk back to the source of all arguments, and all indirect calls.
Goal
Given the following rust code:
Currently, this is what is being generated
impl Traitinstead of the concrete typesrustdoc) to run it on a whole projectFn/FnMut/FnOncetraitsrustdoc)Barfrom aFoo? → highlight the callgraphfoo(), including through function pointers and traits"General algorithm
This is what I am planning to do. This may change in the future if my understanding of the problem space changes.
First, for each functions (and function-like object like closure), locate all function call. Then for each arguments of the called function track if they come from the argument or the function being analyzed, a constant, or from the return value of another function called in the analyzed function. Multiple source are possible, and the control flow is ignored. Once done for all functions, we can walk back to the source of all arguments, and all indirect calls.